Add lcm ns instance operate 39/9639/1
authorying.yunlong <ying.yunlong@zte.com.cn>
Thu, 31 Aug 2017 09:29:22 +0000 (17:29 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Thu, 31 Aug 2017 09:29:22 +0000 (17:29 +0800)
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>
lcm/pub/msapi/aai.py

index 2f8cf93..4483836 100644 (file)
@@ -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])