Implement ns-instance operation function 61/8361/1
authorying.yunlong <ying.yunlong@zte.com.cn>
Wed, 23 Aug 2017 01:17:09 +0000 (09:17 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Wed, 23 Aug 2017 01:17:09 +0000 (09:17 +0800)
Add new create_ns、delete_ns、
query_ns function to operate resource
to aai.

Change-Id: I911be43118b5ea6b7c146702da738b3dc6b5fcfb
Issue-ID: VFC-105
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
lcm/lcm/pub/aaiapi/aai.py

index 817068d..c42ead1 100644 (file)
@@ -21,8 +21,35 @@ from lcm.pub.utils.restcall import call_req_aai, rest_no_auth
 logger = logging.getLogger(__name__)\r
 \r
 \r
-def create_ns(ns_id, data):\r
-    pass\r
+def create_ns(global_customer_id, service_type, service_instance_id, data):\r
+    resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \\r
+               "%s/service-instances/service-instance/%s" % \\r
+               (global_customer_id, service_type, service_instance_id)\r
+    ret = call_req_aai(AAI_BASE_URL, AAI_USER, AAI_PASSWORD, rest_no_auth, resource, "PUT", data)\r
+    if ret[0] != 0:\r
+        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])\r
+        raise NFLCMException("Ns instance creation exception in AAI")\r
+    return json.JSONDecoder().decode(ret[1])\r
+\r
+def delete_ns(global_customer_id, service_type, service_instance_id, data):\r
+    resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \\r
+               "%s/service-instances/service-instance/%s" % \\r
+               (global_customer_id, service_type, service_instance_id)\r
+    ret = call_req_aai(AAI_BASE_URL, AAI_USER, AAI_PASSWORD, rest_no_auth, resource, "DELETE", data)\r
+    if ret[0] != 0:\r
+        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])\r
+        raise NFLCMException("Ns instance delete exception in AAI")\r
+    return json.JSONDecoder().decode(ret[1])\r
+\r
+def query_ns(global_customer_id, service_type, service_instance_id, data):\r
+    resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \\r
+               "%s/service-instances/service-instance/%s" % \\r
+               (global_customer_id, service_type, service_instance_id)\r
+    ret = call_req_aai(AAI_BASE_URL, AAI_USER, AAI_PASSWORD, rest_no_auth, resource, "GET", data)\r
+    if ret[0] != 0:\r
+        logger.error("Status code is %s, detail is %s.", ret[2], ret[1])\r
+        raise NFLCMException("Ns instance query exception in AAI")\r
+    return json.JSONDecoder().decode(ret[1])\r
 \r
 \r
 def create_vnf(vnf_id, data):\r