From 529a2def1860f51f63c708150fc068fc4353d55e Mon Sep 17 00:00:00 2001 From: tierno Date: Mon, 20 Jul 2020 15:39:45 +0000 Subject: [PATCH] fix 1150 limit error length of a failing SDN connector It is not updating database entry vim_wim_actions when error lenght is longer than 1024 Change-Id: I2cb529e7a82784bd7a2274e617ad58ab275feefc Signed-off-by: tierno --- RO-plugin/osm_ro_plugin/sdn_failing.py | 22 ++++++++-------------- RO/osm_ro/vim_thread.py | 7 ++++--- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/RO-plugin/osm_ro_plugin/sdn_failing.py b/RO-plugin/osm_ro_plugin/sdn_failing.py index b8ea42f1..fac28aa9 100644 --- a/RO-plugin/osm_ro_plugin/sdn_failing.py +++ b/RO-plugin/osm_ro_plugin/sdn_failing.py @@ -36,7 +36,6 @@ we need a replacement for it, that will throw an error every time we try to execute any action """ -import json from osm_ro_plugin.sdnconn import SdnConnectorError @@ -61,28 +60,23 @@ class SdnFailingConnector(object): raise SdnConnectorError('Impossible to use WIM:\n' + self.error_msg) def get_connectivity_service_status(self, service_uuid, _conn_info=None): - raise SdnConnectorError('Impossible to retrieve status for {}\n\n{}' + raise SdnConnectorError('Impossible to retrieve status for {}: {}' .format(service_uuid, self.error_msg)) def create_connectivity_service(self, service_uuid, *args, **kwargs): - raise SdnConnectorError('Impossible to connect {}.\n{}\n{}\n{}' - .format(service_uuid, self.error_msg, - json.dumps(args, indent=4), - json.dumps(kwargs, indent=4))) + raise SdnConnectorError('Impossible to create connectivity: {}' + .format(self.error_msg)) def delete_connectivity_service(self, service_uuid, _conn_info=None): - raise SdnConnectorError('Impossible to disconnect {}\n\n{}' + raise SdnConnectorError('Impossible to delete {}: {}' .format(service_uuid, self.error_msg)) def edit_connectivity_service(self, service_uuid, *args, **kwargs): - raise SdnConnectorError('Impossible to change connection {}.\n{}\n' - '{}\n{}' - .format(service_uuid, self.error_msg, - json.dumps(args, indent=4), - json.dumps(kwargs, indent=4))) + raise SdnConnectorError('Impossible to change connection {}: {}' + .format(service_uuid, self.error_msg)) def clear_all_connectivity_services(self): - raise SdnConnectorError('Impossible to use WIM:\n' + self.error_msg) + raise SdnConnectorError('Impossible to use WIM: {}'.format(self.error_msg)) def get_all_active_connectivity_services(self): - raise SdnConnectorError('Impossible to use WIM:\n' + self.error_msg) + raise SdnConnectorError('Impossible to use WIM: {}'.format(self.error_msg)) diff --git a/RO/osm_ro/vim_thread.py b/RO/osm_ro/vim_thread.py index e7bf8914..b8f6a376 100644 --- a/RO/osm_ro/vim_thread.py +++ b/RO/osm_ro/vim_thread.py @@ -224,9 +224,9 @@ class vim_thread(threading.Thread): self.wim_account_id, self.plugin_name)) except Exception as e: self.logger.error("Cannot load sdn connector for wim_account={}, plugin={}: {}".format( - self.wim_account_id, self.plugin_name, e)) + self.wim_account_id, self.plugin_name, e), exc_info=True) self.sdnconnector = None - self.error_status = "Error loading sdn connector: {}".format(e) + self.error_status = self._format_vim_error_msg("Error loading sdn connector: {}".format(e)) def _get_db_task(self): """ @@ -723,7 +723,8 @@ class vim_thread(threading.Thread): self.logger.error("Error executing task={}: {}".format(task_id, e), exc_info=True) task["error_msg"] = str(e) task["status"] = "FAILED" - database_update = {"status": "VIM_ERROR", "error_msg": task["error_msg"]} + database_update = {"status": "VIM_ERROR" if task["item"] != "instance_wim_nets" else "WIM_ERROR", + "error_msg": task["error_msg"]} # if task["item"] == 'instance_vms': # database_update["vim_vm_id"] = None # elif task["item"] == 'instance_nets': -- 2.25.1