aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-09-06 15:14:47 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-09-06 15:14:47 +0800
commit34d1eeacf2c6c01c3f523aaacdd04558c7e72433 (patch)
tree2f3a334af42bab9e84a4fc816e61ee31313ba96c
parent9043ea7dd60a598e5797f8008695852d3b7e9a5d (diff)
Add methods to operate resource relationship
Add methods to operate resource relationship in vfc lcm. Change-Id: Ibd88d91c80740db4777c15b47e6f9861195b549c Issue-ID: VFC-293 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--lcm/pub/msapi/aai.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/lcm/pub/msapi/aai.py b/lcm/pub/msapi/aai.py
index 4ed8528d..d6e10ee7 100644
--- a/lcm/pub/msapi/aai.py
+++ b/lcm/pub/msapi/aai.py
@@ -120,3 +120,64 @@ def query_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, data)
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Vserver query exception in AAI")
return json.JSONDecoder().decode(ret[1])
+
+def put_vserver_relationship(cloud_owner, cloud_region_id, tenant_id, vserver_id, data):
+ resource = "/cloud-infrastructure/cloud-regions/cloud-region/%s/" \
+ "%s/tenants/tenant/%s/vservers/vserver/%s/relationship-list/relationship" % \
+ (cloud_owner, cloud_region_id, tenant_id, vserver_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("Put or update vserver relationship exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
+
+def delete_vserver_relationship(cloud_owner, cloud_region_id, tenant_id, vserver_id):
+ resource = "/cloud-infrastructure/cloud-regions/cloud-region/%s/" \
+ "%s/tenants/tenant/%s/vservers/vserver/%s/relationship-list/relationship" % \
+ (cloud_owner, cloud_region_id, tenant_id, vserver_id)
+ ret = call_aai(resource, "DELETE")
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NSLCMException("Delete vserver relationship exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
+
+def put_vnf_relationship(vnf_id, data):
+ resource = "/network/generic-vnfs/generic-vnf/%s/relationship-list/relationship" % vnf_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("Put or update vnf instance relationship exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
+
+def delete_vnf_relationship(vnf_id):
+ resource = "/network/generic-vnfs/generic-vnf/%s/relationship-list/relationship" % vnf_id
+ ret = call_aai(resource, "DELETE")
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NSLCMException("Delete vnf instance relationship exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
+
+def put_ns_relationship(global_customer_id, service_type, service_instance_id, data):
+ resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
+ "%s/service-instances/service-instance/%s/relationship-list/relationship" % \
+ (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("Put or update ns instance relationship exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
+
+def delete_ns_relationship(global_customer_id, service_type, service_instance_id):
+ resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
+ "%s/service-instances/service-instance/%s/relationship-list/relationship" % \
+ (global_customer_id, service_type, service_instance_id)
+ ret = call_aai(resource, "DELETE")
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NSLCMException("Delete ns instance relationship exception in AAI")
+ return json.JSONDecoder().decode(ret[1])