From: limon Date: Mon, 24 Jul 2023 13:53:41 +0000 (+0200) Subject: Fix bug 2275 X-Git-Tag: v12.0.7~1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F38%2F13738%2F2;p=osm%2FRO.git Fix bug 2275 Change-Id: I2de80100a8b2efcd9d9beca67224ab46714e0afc Signed-off-by: limon --- 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 037fb095..81a42747 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 @@ -4869,51 +4869,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 f8b1c5a0..65ddb044 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -2822,11 +2822,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.