From 417fa7dd1361f6e685499b81740893559f01e590 Mon Sep 17 00:00:00 2001 From: "ying.yunlong" Date: Thu, 31 Aug 2017 17:29:22 +0800 Subject: [PATCH] Add lcm ns instance operate MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit After operate ns instance,need update ns instance in aai, so add create、delete、query function. Change-Id: Ie4b9bb7c811adbc7953beabb17aac01b61d9711b Issue-ID: VFC-202 Signed-off-by: ying.yunlong --- lcm/pub/msapi/aai.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lcm/pub/msapi/aai.py b/lcm/pub/msapi/aai.py index 2f8cf935..4483836d 100644 --- a/lcm/pub/msapi/aai.py +++ b/lcm/pub/msapi/aai.py @@ -37,4 +37,33 @@ def call_aai(resource, method, content=''): content=content, additional_headers=additional_headers) +def create_ns_aai(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_aai(resource, "PUT", data) + if ret[0] != 0: + logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) + raise NSLCMException("Ns instance creation exception in AAI") + return json.JSONDecoder().decode(ret[1]) + +def delete_ns_aai(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_aai(resource, "DELETE", data) + if ret[0] != 0: + logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) + raise NSLCMException("Ns instance delete exception in AAI") + return json.JSONDecoder().decode(ret[1]) + +def query_ns_aai(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_aai(resource, "GET", data) + if ret[0] != 0: + logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) + raise NSLCMException("Ns instance query exception in AAI") + return json.JSONDecoder().decode(ret[1]) -- 2.16.6