From: ying.yunlong Date: Thu, 31 Aug 2017 09:29:22 +0000 (+0800) Subject: Add lcm ns instance operate X-Git-Tag: v1.0.0~117 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F39%2F9639%2F1;p=vfc%2Fnfvo%2Flcm.git Add lcm ns instance operate 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 --- 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])