Add lcm vnf instance operate 87/9787/1
authorying.yunlong <ying.yunlong@zte.com.cn>
Fri, 1 Sep 2017 00:57:57 +0000 (08:57 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Fri, 1 Sep 2017 00:57:57 +0000 (08:57 +0800)
After operate ns instance,need
update ns instance in aai, so
add create、delete、query function.

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

index 4483836..4cfc8e6 100644 (file)
@@ -67,3 +67,26 @@ def query_ns_aai(global_customer_id, service_type, service_instance_id, data):
         raise NSLCMException("Ns instance query exception in AAI")
     return json.JSONDecoder().decode(ret[1])
 
+def create_vnf_aai(vnf_id, data):
+    resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_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("Vnf instance creation exception in AAI")
+    return json.JSONDecoder().decode(ret[1])
+
+def delete_vnf_aai(vnf_id, data=''):
+    resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_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("Vnf instance delete exception in AAI")
+    return json.JSONDecoder().decode(ret[1])
+
+def query_vnf_aai(vnf_id, data):
+    resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_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("Vnf instance query exception in AAI")
+    return json.JSONDecoder().decode(ret[1])