summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-11-02 16:20:56 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-11-02 16:20:56 +0800
commit18123fa1a7b6ec0e96da7facd84d130cc8a47cc5 (patch)
treeb2f3604871947092a7a8721b86519bcc908ab6c0
parentb29cf3674cdd94b58c382c62d2c8c9b052d473ca (diff)
Fix vfc-lcm call aai bugs
Change-Id: Ifc0f5d915939a481c63da4057cd43e16996f16a2 Issue-ID: VFC-579 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--lcm/ns/ns_create.py5
-rw-r--r--lcm/ns/ns_delete.py6
-rw-r--r--lcm/ns/vls/create_vls.py5
-rw-r--r--lcm/ns/vls/delete_vls.py8
-rw-r--r--lcm/ns/vnfs/create_vnfs.py16
-rw-r--r--lcm/ns/vnfs/terminate_nfs.py17
-rw-r--r--lcm/pub/msapi/aai.py50
7 files changed, 39 insertions, 68 deletions
diff --git a/lcm/ns/ns_create.py b/lcm/ns/ns_create.py
index 216d6386..40d8d501 100644
--- a/lcm/ns/ns_create.py
+++ b/lcm/ns/ns_create.py
@@ -109,10 +109,7 @@ class CreateNSService(object):
"service-role": SERVICE_ROLE
}
resp_data, resp_status = create_ns_aai(self.global_customer_id, self.service_type, self.ns_inst_id, data)
- if resp_data:
- logger.debug("Fail to create ns[%s] to aai: [%s].", self.ns_inst_id, resp_status)
- else:
- logger.debug("Success to create ns[%s] to aai: [%s].", self.ns_inst_id, resp_status)
+ logger.debug("Success to create ns[%s] to aai:[%s],[%s].", self.ns_inst_id, resp_data, resp_status)
except NSLCMException as e:
logger.debug("Fail to createns[%s] to aai, detail message: %s" % (self.ns_inst_id, e.message))
except:
diff --git a/lcm/ns/ns_delete.py b/lcm/ns/ns_delete.py
index 131cb76a..2e99f07d 100644
--- a/lcm/ns/ns_delete.py
+++ b/lcm/ns/ns_delete.py
@@ -73,11 +73,7 @@ class DeleteNsService(object):
logger.debug("ns instance resource_version=[%s]" % resource_version)
resp_data, resp_status = delete_ns_aai(self.global_customer_id, self.service_type,
self.ns_inst_id, resource_version)
- if resp_data:
- logger.debug("Fail to delete ns[%s] from aai, resp_status: [%s]." % (self.ns_inst_id, resp_status))
- else:
- logger.debug("Success to delete ns[%s] from aai, resp_status: [%s]."
- % (self.ns_inst_id, resp_status))
+ logger.debug("Success to delete ns[%s] from aai, resp_status: [%s]." % (self.ns_inst_id, resp_status))
except NSLCMException as e:
logger.debug("Fail to delete ns[%s] from aai, detail message: %s" % (self.ns_inst_id, e.message))
except:
diff --git a/lcm/ns/vls/create_vls.py b/lcm/ns/vls/create_vls.py
index f17027ef..18abfa26 100644
--- a/lcm/ns/vls/create_vls.py
+++ b/lcm/ns/vls/create_vls.py
@@ -227,10 +227,7 @@ class CreateVls(object):
}
}
resp_data, resp_status = create_network_aai(self.vl_inst_id, data)
- if resp_data:
- logger.debug("Fail to create network[%s] to aai: [%s].", self.vl_inst_id, resp_status)
- else:
- logger.debug("Success to create network[%s] to aai: [%s].", self.vl_inst_id, resp_status)
+ logger.debug("Success to create network[%s] to aai: [%s].", self.vl_inst_id, resp_status)
except NSLCMException as e:
logger.debug("Fail to create network[%s] to aai, detail message: %s" % (self.vl_inst_id, e.message))
except:
diff --git a/lcm/ns/vls/delete_vls.py b/lcm/ns/vls/delete_vls.py
index 3402016f..1ae5e66c 100644
--- a/lcm/ns/vls/delete_vls.py
+++ b/lcm/ns/vls/delete_vls.py
@@ -92,12 +92,8 @@ class DeleteVls(object):
# delete network from aai
resp_data, resp_status = delete_network_aai(self.vl_inst_id, resource_version)
- if resp_data:
- logger.debug("Fail to delete network[%s] from aai, resp_status: [%s]."
- % (self.vl_inst_id, resp_status))
- else:
- logger.debug("Success to delete network[%s] from aai, resp_status: [%s]."
- % (self.vl_inst_id, resp_status))
+ logger.debug("Success to delete network[%s] from aai, resp_status: [%s]."
+ % (self.vl_inst_id, resp_status))
except NSLCMException as e:
logger.debug("Fail to delete network[%s] to aai, detail message: %s" % (self.vl_inst_id, e.message))
except:
diff --git a/lcm/ns/vnfs/create_vnfs.py b/lcm/ns/vnfs/create_vnfs.py
index 0f3e57db..9356ed72 100644
--- a/lcm/ns/vnfs/create_vnfs.py
+++ b/lcm/ns/vnfs/create_vnfs.py
@@ -312,12 +312,8 @@ class CreateVnfs(Thread):
}
}
resp_data, resp_status = create_vnf_aai(self.nf_inst_id, data)
- if resp_data:
- logger.debug("Fail to create vnf[%s] to aai, ns instance=[%s], resp_status: [%s]."
- % (self.nf_inst_id, self.ns_inst_id, resp_status))
- else:
- logger.debug("Success to create vnf[%s] to aai, ns instance=[%s], resp_status: [%s]."
- % (self.nf_inst_id, self.ns_inst_id, resp_status))
+ logger.debug("Success to create vnf[%s] to aai, ns instance=[%s], resp_status: [%s]."
+ % (self.nf_inst_id, self.ns_inst_id, resp_status))
except NSLCMException as e:
logger.debug("Fail to create vnf[%s] to aai, ns instance=[%s], detail message: %s"
% (self.nf_inst_id, self.ns_inst_id, e.message))
@@ -359,12 +355,8 @@ class CreateVnfs(Thread):
# create vserver instance in aai
resp_data, resp_status = create_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, data)
- if resp_data:
- logger.debug("Fail to create vserver[%s] to aai, vnf instance=[%s], resp_status: [%s]."
- % (vserver_id, self.nf_inst_id, resp_status))
- else:
- logger.debug("Success to create vserver[%s] to aai, vnf instance=[%s], resp_status: [%s]."
- % (vserver_id, self.nf_inst_id, resp_status))
+ logger.debug("Success to create vserver[%s] to aai, vnf instance=[%s], resp_status: [%s]."
+ % (vserver_id, self.nf_inst_id, resp_status))
logger.debug("Success to create all vserver to aai.")
except NSLCMException as e:
logger.debug("Fail to create vserver to aai, vnf instance=[%s], detail message: %s"
diff --git a/lcm/ns/vnfs/terminate_nfs.py b/lcm/ns/vnfs/terminate_nfs.py
index 595470e6..2574dcb4 100644
--- a/lcm/ns/vnfs/terminate_nfs.py
+++ b/lcm/ns/vnfs/terminate_nfs.py
@@ -142,11 +142,8 @@ class TerminateVnfs(threading.Thread):
# delete vnf instance from aai
resp_data, resp_status = delete_vnf_aai(self.vnf_inst_id, resource_version)
- if resp_data:
- logger.debug("Fail to delete vnf[%s] from aai, resp_status: [%s]." % (self.vnf_inst_id, resp_status))
- else:
- logger.debug(
- "Success to delete vnf[%s] from aai, resp_status: [%s]." % (self.vnf_inst_id, resp_status))
+ logger.debug(
+ "Success to delete vnf[%s] from aai, resp_status: [%s]." % (self.vnf_inst_id, resp_status))
except NSLCMException as e:
logger.debug("Fail to delete vnf from aai[%s], detail message: %s" % (self.vnf_inst_id, e.message))
except:
@@ -171,13 +168,9 @@ class TerminateVnfs(threading.Thread):
# delete vserver instance from aai
resp_data, resp_status = delete_vserver_aai(cloud_owner, cloud_region_id,
tenant_id, vserver_id, resource_version)
- if resp_data:
- logger.debug("Fail to delete vserver instance[%s] from aai, resp_status: [%s]." %
- (vserver_id, resp_status))
- else:
- logger.debug(
- "Success to delete vserver instance[%s] from aai, resp_status: [%s]." %
- (vserver_id, resp_status))
+ logger.debug(
+ "Success to delete vserver instance[%s] from aai, resp_status: [%s]." %
+ (vserver_id, resp_status))
logger.debug("delete_vserver_in_aai end!")
except NSLCMException as e:
logger.debug("Fail to delete vserver from aai, detail message: %s" % e.message)
diff --git a/lcm/pub/msapi/aai.py b/lcm/pub/msapi/aai.py
index 9dc2719b..73f124b8 100644
--- a/lcm/pub/msapi/aai.py
+++ b/lcm/pub/msapi/aai.py
@@ -47,7 +47,7 @@ def create_customer_aai(global_customer_id, data):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Customer creation exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def query_customer_aai(global_customer_id):
@@ -56,7 +56,7 @@ def query_customer_aai(global_customer_id):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Get customer info exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def delete_customer_aai(global_customer_id, resource_version=""):
@@ -67,7 +67,7 @@ def delete_customer_aai(global_customer_id, resource_version=""):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Customer delete exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def put_customer_relationship(global_customer_id, data):
@@ -77,7 +77,7 @@ def put_customer_relationship(global_customer_id, data):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Put or update customer relationship exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def delete_customer_relationship(global_customer_id):
@@ -86,7 +86,7 @@ def delete_customer_relationship(global_customer_id):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Delete customer relationship exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def create_ns_aai(global_customer_id, service_type, service_instance_id, data):
@@ -98,7 +98,7 @@ def create_ns_aai(global_customer_id, service_type, service_instance_id, 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]), ret[2]
+ return json.loads(ret[1]) if ret[1] else ret[1], ret[2]
def query_ns_aai(global_customer_id, service_type, service_instance_id):
@@ -122,7 +122,7 @@ def delete_ns_aai(global_customer_id, service_type, service_instance_id, resourc
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]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def put_ns_relationship(global_customer_id, service_type, service_instance_id, data):
@@ -134,7 +134,7 @@ def put_ns_relationship(global_customer_id, service_type, service_instance_id, d
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]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def delete_ns_relationship(global_customer_id, service_type, service_instance_id):
@@ -145,7 +145,7 @@ def delete_ns_relationship(global_customer_id, service_type, service_instance_id
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]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def create_vnf_aai(vnf_id, data):
@@ -155,7 +155,7 @@ def create_vnf_aai(vnf_id, data):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Vnf instance creation exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def query_vnf_aai(vnf_id):
@@ -175,7 +175,7 @@ def delete_vnf_aai(vnf_id, resource_version=""):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Vnf instance delete exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def put_vnf_relationship(vnf_id, data):
@@ -185,7 +185,7 @@ def put_vnf_relationship(vnf_id, 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]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def delete_vnf_relationship(vnf_id):
@@ -194,7 +194,7 @@ def delete_vnf_relationship(vnf_id):
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]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def create_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, data):
@@ -206,7 +206,7 @@ def create_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, data
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Vserver creation exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def query_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id):
@@ -230,7 +230,7 @@ def delete_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, reso
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Vserver delete exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def put_vserver_relationship(cloud_owner, cloud_region_id, tenant_id, vserver_id, data):
@@ -242,7 +242,7 @@ def put_vserver_relationship(cloud_owner, cloud_region_id, tenant_id, vserver_id
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]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def delete_vserver_relationship(cloud_owner, cloud_region_id, tenant_id, vserver_id):
@@ -253,7 +253,7 @@ def delete_vserver_relationship(cloud_owner, cloud_region_id, tenant_id, vserver
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]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def create_network_aai(network_id, data):
@@ -263,7 +263,7 @@ def create_network_aai(network_id, data):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Network creation exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def query_network_aai(network_id):
@@ -283,7 +283,7 @@ def delete_network_aai(network_id, resource_version=""):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Network delete exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def put_network_relationship(network_id, data):
@@ -293,7 +293,7 @@ def put_network_relationship(network_id, data):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Put or update network relationship exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def delete_network_relationship(network_id):
@@ -302,7 +302,7 @@ def delete_network_relationship(network_id):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Delete network relationship exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def create_subnet_aai(network_id, subnet_id, data):
@@ -312,7 +312,7 @@ def create_subnet_aai(network_id, subnet_id, data):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Subnetwork creation exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def query_subnet_aai(network_id, subnet_id):
@@ -332,7 +332,7 @@ def delete_subnet_aai(network_id, subnet_id, resource_version=""):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Subnetwork delete exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def put_subnet_relationship(network_id, subnet_id, data):
@@ -343,7 +343,7 @@ def put_subnet_relationship(network_id, subnet_id, data):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Put or update subnetwork relationship exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]
def delete_subnet_relationship(network_id, subnet_id):
@@ -353,4 +353,4 @@ def delete_subnet_relationship(network_id, subnet_id):
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Delete subnetwork relationship exception in AAI")
- return json.JSONDecoder().decode(ret[1]), ret[2]
+ return json.JSONDecoder().decode(ret[1]) if ret[1] else ret[1], ret[2]