summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-08-23 09:17:09 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-08-23 09:17:09 +0800
commitddf0ce104f2b8103a683b6207ad5f1cfd451da36 (patch)
tree84e588cfdecb7a3689e7199204258832e4ef8029
parent31e588f135366e0dc0b93f602cec92bbbce35d0c (diff)
Implement ns-instance operation function
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 <ying.yunlong@zte.com.cn>
-rw-r--r--lcm/lcm/pub/aaiapi/aai.py31
1 files 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):