From 9f2900c60cc75a7de14486b66cac5247c1ad8ecd Mon Sep 17 00:00:00 2001 From: tierno Date: Fri, 13 Jul 2018 15:25:24 +0200 Subject: [PATCH] Enhance SDN assist error reporting Change-Id: I1160b17eb053af427e6aede9f4f95013afc9e633 Signed-off-by: tierno --- openmanod | 2 +- osm_ro/openmano_schemas.py | 3 --- osm_ro/vim_thread.py | 22 +++++++++++----------- osm_ro/vimconn_openvim.py | 2 ++ 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/openmanod b/openmanod index 05747d79..f3b28006 100755 --- a/openmanod +++ b/openmanod @@ -48,7 +48,7 @@ import osm_ro __author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes" __date__ = "$26-aug-2014 11:09:29$" -__version__ = "0.5.72-r582" +__version__ = "0.5.73-r583" version_date = "Jul 2018" database_version = 32 # expected database schema version diff --git a/osm_ro/openmano_schemas.py b/osm_ro/openmano_schemas.py index fe595720..6c0dbdc5 100644 --- a/osm_ro/openmano_schemas.py +++ b/osm_ro/openmano_schemas.py @@ -1077,9 +1077,6 @@ instance_scenario_create_schema_v01 = { } } }, - - - } } }, diff --git a/osm_ro/vim_thread.py b/osm_ro/vim_thread.py index 0f8dec76..e82e37e8 100644 --- a/osm_ro/vim_thread.py +++ b/osm_ro/vim_thread.py @@ -277,7 +277,7 @@ class vim_thread(threading.Thread): if task_interface.get("sdn_port_id"): try: with self.db_lock: - self.ovim.delete_port(task_interface["sdn_port_id"]) + self.ovim.delete_port(task_interface["sdn_port_id"], idempotent=True) task_interface["sdn_port_id"] = None task_need_update = True except ovimException as e: @@ -394,18 +394,18 @@ class vim_thread(threading.Thread): except (ovimException, Exception) as e: text_error = "ovimException getting network snd_net_id={}: {}".format(task_sdn_net_id, e) self.logger.error("task={} get-net: {}".format(task_id, text_error), exc_info=True) - sdn_net = {"status": "ERROR", "error_msg": text_error} + sdn_net = {"status": "ERROR", "last_error": text_error} if sdn_net["status"] == "ERROR": if not vim_info_error_msg: - vim_info_error_msg = sdn_net["error_msg"] + vim_info_error_msg = str(sdn_net.get("last_error")) else: vim_info_error_msg = "VIM_ERROR: {} && SDN_ERROR: {}".format( self._format_vim_error_msg(vim_info_error_msg, 1024//2-14), - self._format_vim_error_msg(sdn_net["error_msg"], 1024//2-14)) - if vim_info_status == "VIM_ERROR": - vim_info_status = "VIM_SDN_ERROR" - else: - vim_info_status = "SDN_ERROR" + self._format_vim_error_msg(sdn_net["last_error"], 1024//2-14)) + vim_info_status = "ERROR" + elif sdn_net["status"] == "BUILD": + if vim_info_status == "ACTIVE": + vim_info_status = "BUILD" # update database if vim_info_error_msg: @@ -859,7 +859,7 @@ class vim_thread(threading.Thread): if iface.get("sdn_port_id"): try: with self.db_lock: - self.ovim.delete_port(iface["sdn_port_id"]) + self.ovim.delete_port(iface["sdn_port_id"], idempotent=True) except ovimException as e: self.logger.error("task={} del-VM: ovimException when deleting external_port={}: {} ".format( task_id, iface["sdn_port_id"], e), exc_info=True) @@ -996,8 +996,8 @@ class vim_thread(threading.Thread): port_list = self.ovim.get_ports(columns={'uuid'}, filter={'name': 'external_port', 'net_id': sdn_net_id}) for port in port_list: - self.ovim.delete_port(port['uuid']) - self.ovim.delete_network(sdn_net_id) + self.ovim.delete_port(port['uuid'], idempotent=True) + self.ovim.delete_network(sdn_net_id, idempotent=True) if net_vim_id: self.vim.delete_network(net_vim_id) task["status"] = "DONE" diff --git a/osm_ro/vimconn_openvim.py b/osm_ro/vimconn_openvim.py index 417092f1..5e5349d3 100644 --- a/osm_ro/vimconn_openvim.py +++ b/osm_ro/vimconn_openvim.py @@ -600,6 +600,8 @@ class vimconnector(vimconn.vimconnector): for device in new_flavor_dict.get('extended', {}).get('devices', ()): if 'image name' in device: del device['image name'] + if 'name' in device: + del device['name'] numas = new_flavor_dict.get('extended', {}).get('numas') if numas: numa = numas[0] -- 2.25.1