summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-08-23 09:09:45 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-08-23 09:09:45 +0800
commit31e588f135366e0dc0b93f602cec92bbbce35d0c (patch)
tree312c0667be426f92e07fd9ad2387390f3c7e309e
parentcdb2b13b1330aca1b85d19cbd0e95c7adfa38073 (diff)
Implement vnf-instance operation function
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>
-rw-r--r--lcm/lcm/pub/aaiapi/aai.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/lcm/lcm/pub/aaiapi/aai.py b/lcm/lcm/pub/aaiapi/aai.py
index f92ca2d4..817068d0 100644
--- a/lcm/lcm/pub/aaiapi/aai.py
+++ b/lcm/lcm/pub/aaiapi/aai.py
@@ -26,7 +26,28 @@ def create_ns(ns_id, data):
def create_vnf(vnf_id, data):
- pass
+ resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_id
+ ret = call_req_aai(AAI_BASE_URL, AAI_USER, AAI_PASSWORD, rest_no_auth, resource, "PUT", data)
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NFLCMException("Vnf instance creation exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
+def delete_vnf(vnf_id, data):
+ resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_id
+ ret = call_req_aai(AAI_BASE_URL, AAI_USER, AAI_PASSWORD, rest_no_auth, resource, "DELETE", data)
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NFLCMException("Vnf instance delete exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
+def query_vnf(vnf_id, data):
+ resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_id
+ ret = call_req_aai(AAI_BASE_URL, AAI_USER, AAI_PASSWORD, rest_no_auth, resource, "GET", data)
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NFLCMException("Vnf instance query exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
def create_vserver(cloud_owner, cloud_region_id, tenant_id, vserver_id, data):