From: ying.yunlong Date: Wed, 23 Aug 2017 01:09:45 +0000 (+0800) Subject: Implement vnf-instance operation function X-Git-Tag: v1.0.0~57 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=vfc%2Fgvnfm%2Fvnflcm.git;a=commitdiff_plain;h=31e588f135366e0dc0b93f602cec92bbbce35d0c 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 --- 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):