Fix bug 2275 36/13736/6
authorlimon <alimonj@indra.es>
Mon, 24 Jul 2023 13:53:41 +0000 (15:53 +0200)
committeraticig <gulsum.atici@canonical.com>
Tue, 25 Jul 2023 19:08:04 +0000 (21:08 +0200)
Change-Id: I2de80100a8b2efcd9d9beca67224ab46714e0afc
Signed-off-by: limon <alimonj@indra.es>
RO-VIM-openstack/osm_rovim_openstack/tests/test_vimconn_openstack.py
RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
releasenotes/notes/fix_bug_2275-9344b6edce5bfade.yaml [new file with mode: 0644]

index 08f73bc..a3da330 100644 (file)
@@ -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.)"
index 70b3f21..f225be4 100644 (file)
@@ -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 (file)
index 0000000..62bb370
--- /dev/null
@@ -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.