aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-08-31 17:29:22 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-08-31 17:29:22 +0800
commit417fa7dd1361f6e685499b81740893559f01e590 (patch)
tree0cae3ac28459545a544b8ed500c6bf2fec9e04ee
parent1a00a2fd39c0780cc10d050237f38aa198cc6651 (diff)
Add lcm ns instance operate
After operate ns instance,need update ns instance in aai, so add create、delete、query function. Change-Id: Ie4b9bb7c811adbc7953beabb17aac01b61d9711b Issue-ID: VFC-202 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--lcm/pub/msapi/aai.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/lcm/pub/msapi/aai.py b/lcm/pub/msapi/aai.py
index 2f8cf935..4483836d 100644
--- a/lcm/pub/msapi/aai.py
+++ b/lcm/pub/msapi/aai.py
@@ -37,4 +37,33 @@ def call_aai(resource, method, content=''):
content=content,
additional_headers=additional_headers)
+def create_ns_aai(global_customer_id, service_type, service_instance_id, data):
+ resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
+ "%s/service-instances/service-instance/%s" % \
+ (global_customer_id, service_type, service_instance_id)
+ ret = call_aai(resource, "PUT", data)
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NSLCMException("Ns instance creation exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
+def delete_ns_aai(global_customer_id, service_type, service_instance_id, data):
+ resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
+ "%s/service-instances/service-instance/%s" % \
+ (global_customer_id, service_type, service_instance_id)
+ ret = call_aai(resource, "DELETE", data)
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NSLCMException("Ns instance delete exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
+def query_ns_aai(global_customer_id, service_type, service_instance_id, data):
+ resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
+ "%s/service-instances/service-instance/%s" % \
+ (global_customer_id, service_type, service_instance_id)
+ ret = call_aai(resource, "GET", data)
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NSLCMException("Ns instance query exception in AAI")
+ return json.JSONDecoder().decode(ret[1])