From ddf0ce104f2b8103a683b6207ad5f1cfd451da36 Mon Sep 17 00:00:00 2001 From: "ying.yunlong" Date: Wed, 23 Aug 2017 09:17:09 +0800 Subject: [PATCH] Implement ns-instance operation function MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add new create_ns、delete_ns、 query_ns function to operate resource to aai. Change-Id: I911be43118b5ea6b7c146702da738b3dc6b5fcfb Issue-ID: VFC-105 Signed-off-by: ying.yunlong --- lcm/lcm/pub/aaiapi/aai.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lcm/lcm/pub/aaiapi/aai.py b/lcm/lcm/pub/aaiapi/aai.py index 817068d0..c42ead1b 100644 --- a/lcm/lcm/pub/aaiapi/aai.py +++ b/lcm/lcm/pub/aaiapi/aai.py @@ -21,8 +21,35 @@ from lcm.pub.utils.restcall import call_req_aai, rest_no_auth logger = logging.getLogger(__name__) -def create_ns(ns_id, data): - pass +def create_ns(global_customer_id, service_type, service_instance_id, data): + resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \ + "%s/service-instances/service-instance/%s" % \ + (global_customer_id, service_type, service_instance_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("Ns instance creation exception in AAI") + return json.JSONDecoder().decode(ret[1]) + +def delete_ns(global_customer_id, service_type, service_instance_id, data): + resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \ + "%s/service-instances/service-instance/%s" % \ + (global_customer_id, service_type, service_instance_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("Ns instance delete exception in AAI") + return json.JSONDecoder().decode(ret[1]) + +def query_ns(global_customer_id, service_type, service_instance_id, data): + resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \ + "%s/service-instances/service-instance/%s" % \ + (global_customer_id, service_type, service_instance_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("Ns instance query exception in AAI") + return json.JSONDecoder().decode(ret[1]) def create_vnf(vnf_id, data): -- 2.16.6