Implement vnf-instance operation function 59/8359/1
authorying.yunlong <ying.yunlong@zte.com.cn>
Wed, 23 Aug 2017 01:09:45 +0000 (09:09 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Wed, 23 Aug 2017 01:09:45 +0000 (09:09 +0800)
Add new create_vnf、delete_vnf、
query_vnf function to operate resource
to aai.

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

index f92ca2d..817068d 100644 (file)
@@ -26,7 +26,28 @@ def create_ns(ns_id, data):
 \r
 \r
 def create_vnf(vnf_id, data):\r
-    pass\r
+    resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_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("Vnf instance creation exception in AAI")\r
+    return json.JSONDecoder().decode(ret[1])\r
+\r
+def delete_vnf(vnf_id, data):\r
+    resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_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("Vnf instance delete exception in AAI")\r
+    return json.JSONDecoder().decode(ret[1])\r
+\r
+def query_vnf(vnf_id, data):\r
+    resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_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("Vnf instance query exception in AAI")\r
+    return json.JSONDecoder().decode(ret[1])\r
 \r
 \r
 def create_vserver(cloud_owner, cloud_region_id, tenant_id, vserver_id, data):\r