From 878f869cb0e0f7b175f396959364781429fbea37 Mon Sep 17 00:00:00 2001 From: limon Date: Mon, 24 Jul 2023 15:53:41 +0200 Subject: [PATCH] Fix bug 2275 Change-Id: I2de80100a8b2efcd9d9beca67224ab46714e0afc Signed-off-by: limon --- .../tests/test_vimconn_openstack.py | 34 ------------------- .../osm_rovim_openstack/vimconn_openstack.py | 6 +--- .../notes/fix_bug_2275-9344b6edce5bfade.yaml | 24 +++++++++++++ 3 files changed, 25 insertions(+), 39 deletions(-) create mode 100644 releasenotes/notes/fix_bug_2275-9344b6edce5bfade.yaml diff --git a/RO-VIM-openstack/osm_rovim_openstack/tests/test_vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/tests/test_vimconn_openstack.py index 08f73bc9..a3da3305 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/tests/test_vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/tests/test_vimconn_openstack.py @@ -4141,51 +4141,17 @@ class TestNewVmInstance(unittest.TestCase): def test_delete_ports_by_id_by_neutron(self): """neutron delete ports.""" k_id = port_id - self.vimconn.neutron.list_ports.return_value = { - "ports": [{"id": port_id}, {"id": port2_id}] - } - self.vimconn._delete_ports_by_id_wth_neutron(k_id) - self.vimconn.neutron.list_ports.assert_called_once() self.vimconn.neutron.delete_port.assert_called_once_with(k_id) self.vimconn.logger.error.assert_not_called() - def test_delete_ports_by_id_by_neutron_id_not_in_port_list(self): - """port id not in the port list.""" - k_id = volume_id - self.vimconn.neutron.list_ports.return_value = { - "ports": [{"id": port_id}, {"id": port2_id}] - } - - self.vimconn._delete_ports_by_id_wth_neutron(k_id) - self.vimconn.neutron.list_ports.assert_called_once() - self.vimconn.neutron.delete_port.assert_not_called() - self.vimconn.logger.error.assert_not_called() - - def test_delete_ports_by_id_by_neutron_list_port_raise_exception(self): - """neutron list port raises exception.""" - k_id = port_id - self.vimconn.neutron.list_ports.side_effect = nvExceptions.ClientException( - "Connection aborted." - ) - self.vimconn._delete_ports_by_id_wth_neutron(k_id) - self.vimconn.neutron.list_ports.assert_called_once() - self.vimconn.neutron.delete_port.assert_not_called() - self.vimconn.logger.error.assert_called_once_with( - "Error deleting port: ClientException: Unknown Error (HTTP Connection aborted.)" - ) - def test_delete_ports_by_id_by_neutron_delete_port_raise_exception(self): """neutron delete port raises exception.""" k_id = port_id - self.vimconn.neutron.list_ports.return_value = { - "ports": [{"id": port_id}, {"id": port2_id}] - } self.vimconn.neutron.delete_port.side_effect = nvExceptions.ClientException( "Connection aborted." ) self.vimconn._delete_ports_by_id_wth_neutron(k_id) - self.vimconn.neutron.list_ports.assert_called_once() self.vimconn.neutron.delete_port.assert_called_once_with(k_id) self.vimconn.logger.error.assert_called_once_with( "Error deleting port: ClientException: Unknown Error (HTTP Connection aborted.)" diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py index 70b3f211..f225be45 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -2988,11 +2988,7 @@ class vimconnector(vimconn.VimConnector): k_id (str): Port id in the VIM """ try: - port_dict = self.neutron.list_ports() - existing_ports = [port["id"] for port in port_dict["ports"] if port_dict] - - if k_id in existing_ports: - self.neutron.delete_port(k_id) + self.neutron.delete_port(k_id) except Exception as e: self.logger.error("Error deleting port: {}: {}".format(type(e).__name__, e)) diff --git a/releasenotes/notes/fix_bug_2275-9344b6edce5bfade.yaml b/releasenotes/notes/fix_bug_2275-9344b6edce5bfade.yaml new file mode 100644 index 00000000..62bb370a --- /dev/null +++ b/releasenotes/notes/fix_bug_2275-9344b6edce5bfade.yaml @@ -0,0 +1,24 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +fixes: + - | + Fix Bug 2275 + + Remove the pre-check before deleting a Neutron Port. The existing request + has no filter and is retrieving all the ports in the Tenant. This requires + a big amount of execution time causing issues in the NS deletions. -- 2.17.1