diff options
author | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-10-13 14:25:35 +0800 |
---|---|---|
committer | ying.yunlong <ying.yunlong@zte.com.cn> | 2017-10-13 14:25:35 +0800 |
commit | ee7095efd0c5837768fff17453e945d316951e20 (patch) | |
tree | d0a2aaf18ea15b53bcd783c874bd32bd20e8decb | |
parent | fd098a6f75baa3da31f91f94a2200bc88aa32d5e (diff) |
Add exception protection in vfc-nfvo-lcm
Change-Id: I65b9886981487d1204def9fe5bad3e5e082bbadb
Issue-ID: VFC-525
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | lcm/ns/vls/create_vls.py | 71 | ||||
-rw-r--r-- | lcm/ns/vls/delete_vls.py | 26 |
2 files changed, 54 insertions, 43 deletions
diff --git a/lcm/ns/vls/create_vls.py b/lcm/ns/vls/create_vls.py index dc721018..f17027ef 100644 --- a/lcm/ns/vls/create_vls.py +++ b/lcm/ns/vls/create_vls.py @@ -196,37 +196,42 @@ class CreateVls(object): def create_network_and_subnet_in_aai(self): logger.debug("CreateVls::create_network_in_aai::report network[%s] to aai." % self.vl_inst_id) - data = { - "network-id": self.vl_inst_id, - "network-name": self.vl_inst_name, - "is-bound-to-vpn": False, - "is-provider-network": True, - "is-shared-network": True, - "is-external-network": True, - "subnets": { - "subnet": [ - { - "subnet-id": self.related_subnetwork_id, - "dhcp-enabled": False - } - ] - }, - "relationship-list": { - "relationship": [ - { - "related-to": "generic-vnf", - "relationship-data": [ - { - "relationship-key": "generic-vnf.vnf-id", - "relationship-value": self.owner_id - } - ] - } - ] + try: + data = { + "network-id": self.vl_inst_id, + "network-name": self.vl_inst_name, + "is-bound-to-vpn": False, + "is-provider-network": True, + "is-shared-network": True, + "is-external-network": True, + "subnets": { + "subnet": [ + { + "subnet-id": self.related_subnetwork_id, + "dhcp-enabled": False + } + ] + }, + "relationship-list": { + "relationship": [ + { + "related-to": "generic-vnf", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": self.owner_id + } + ] + } + ] + } } - } - 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) + 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) + except NSLCMException as e: + logger.debug("Fail to create network[%s] to aai, detail message: %s" % (self.vl_inst_id, e.message)) + except: + logger.error(traceback.format_exc()) diff --git a/lcm/ns/vls/delete_vls.py b/lcm/ns/vls/delete_vls.py index 8c089b1c..3402016f 100644 --- a/lcm/ns/vls/delete_vls.py +++ b/lcm/ns/vls/delete_vls.py @@ -85,17 +85,23 @@ class DeleteVls(object): def delete_network_and_subnet_in_aai(self): logger.debug("DeleteVls::delete_network_in_aai::delete network[%s] in aai." % self.vl_inst_id) + try: + # query network in aai, get resource_version + customer_info = query_network_aai(self.vl_inst_id) + resource_version = customer_info["resource-version"] - # query network in aai, get resource_version - customer_info = query_network_aai(self.vl_inst_id) - resource_version = customer_info["resource-version"] - - # 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)) + # 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)) + except NSLCMException as e: + logger.debug("Fail to delete network[%s] to aai, detail message: %s" % (self.vl_inst_id, e.message)) + except: + logger.error(traceback.format_exc()) def delete_vl_from_db(self, vl_inst_info): # do_biz_with_share_lock("delete-vllist-in-vnffg-%s" % self.ns_inst_id, self.delete_vl_inst_id_in_vnffg) |