From 31e588f135366e0dc0b93f602cec92bbbce35d0c Mon Sep 17 00:00:00 2001 From: "ying.yunlong" Date: Wed, 23 Aug 2017 09:09:45 +0800 Subject: [PATCH] Implement vnf-instance operation function MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- lcm/lcm/pub/aaiapi/aai.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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): -- 2.16.6