Fixing the signature of method 86/12786/1
authorGulsum Atici <gulsum.atici@canonical.com>
Mon, 12 Dec 2022 16:21:25 +0000 (19:21 +0300)
committeraticig <gulsum.atici@canonical.com>
Mon, 12 Dec 2022 16:29:03 +0000 (17:29 +0100)
Correcting the signature of method _get_free_floating_ip in vimconn_openstack.py

Change-Id: I0351b1c9af9543c02985601a30fe1e684db71e8a
Signed-off-by: Gulsum Atici <gulsum.atici@canonical.com>
RO-VIM-openstack/osm_rovim_openstack/tests/test_vimconn_openstack.py
RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
releasenotes/notes/fixing_method_signature-d09f0b0320474a79.yaml [new file with mode: 0644]

index c0e1c6e..f4382ad 100644 (file)
@@ -3304,7 +3304,6 @@ class TestNewVmInstance(unittest.TestCase):
     def test_get_free_floating_ip(self, mock_find_floating_ip, mock_shuffle):
         """Get free floating ip successfully."""
         floating_network = {"floating_ip": "308b73-t9cc-1a6a-a270-12cc4811bd4a"}
-        created_items = {}
         floating_ips = [
             {
                 "port_id": "608b73-r9cc-5a6a-a270-82cc4811bd4a",
@@ -3325,13 +3324,11 @@ class TestNewVmInstance(unittest.TestCase):
         mock_find_floating_ip.return_value = "508b73-o9cc-5a6a-a270-72cc4811bd8"
         expected_result = "508b73-o9cc-5a6a-a270-72cc4811bd8"
 
-        result = self.vimconn._get_free_floating_ip(
-            self.server, floating_network, created_items
-        )
+        result = self.vimconn._get_free_floating_ip(self.server, floating_network)
         self.assertEqual(result, expected_result)
         mock_shuffle.assert_called_once_with(floating_ips)
         mock_find_floating_ip.assert_called_once_with(
-            self.server, floating_ips, floating_network, created_items
+            self.server, floating_ips, floating_network
         )
 
     @patch("random.shuffle")
@@ -3341,15 +3338,12 @@ class TestNewVmInstance(unittest.TestCase):
     ):
         """Neutron list floating IPs raises exception."""
         floating_network = {"floating_ip": "308b73-t9cc-1a6a-a270-12cc4811bd4a"}
-        created_items = {}
         self.vimconn.neutron = CopyingMock()
         self.vimconn.neutron.list_floatingips.side_effect = Exception(
             "Floating ips could not be listed."
         )
         with self.assertRaises(Exception) as err:
-            result = self.vimconn._get_free_floating_ip(
-                self.server, floating_network, created_items
-            )
+            result = self.vimconn._get_free_floating_ip(self.server, floating_network)
             self.assertEqual(result, None)
             self.assertEqual(str(err.exception), "Floating ips could not be listed.")
         mock_shuffle.assert_not_called()
@@ -3362,7 +3356,6 @@ class TestNewVmInstance(unittest.TestCase):
     ):
         """_find_floating_ip method raises exception."""
         floating_network = {"floating_ip": "308b73-t9cc-1a6a-a270-12cc4811bd4a"}
-        created_items = {}
         floating_ips = [
             {
                 "port_id": "608b73-r9cc-5a6a-a270-82cc4811bd4a",
@@ -3386,14 +3379,12 @@ class TestNewVmInstance(unittest.TestCase):
         )
 
         with self.assertRaises(Exception) as err:
-            result = self.vimconn._get_free_floating_ip(
-                self.server, floating_network, created_items
-            )
+            result = self.vimconn._get_free_floating_ip(self.server, floating_network)
             self.assertEqual(result, None)
             self.assertEqual(str(err.exception), "Free floating ip could not be found.")
         mock_shuffle.assert_called_once_with(floating_ips)
         mock_find_floating_ip.assert_called_once_with(
-            self.server, floating_ips, floating_network, created_items
+            self.server, floating_ips, floating_network
         )
 
     @patch.object(vimconnector, "_create_floating_ip")
@@ -3435,7 +3426,6 @@ class TestNewVmInstance(unittest.TestCase):
                 "floating_ip": "y08b73-o9cc-1a6a-a270-12cc4811bd4u",
                 "vim_id": "608b73-r9cc-5a6a-a270-82cc4811bd4a",
             },
-            created_items,
         )
         self.vimconn.neutron.show_floatingip.assert_called_once_with(
             "y08b73-o9cc-1a6a-a270-12cc4811bd4u"
@@ -3489,7 +3479,6 @@ class TestNewVmInstance(unittest.TestCase):
                 "floating_ip": "y08b73-o9cc-1a6a-a270-12cc4811bd4u",
                 "vim_id": "608b73-r9cc-5a6a-a270-82cc4811bd4a",
             },
-            created_items,
         )
         self.vimconn.neutron.show_floatingip.assert_called_with(None)
         mock_sleep.assert_not_called()
@@ -3545,7 +3534,6 @@ class TestNewVmInstance(unittest.TestCase):
                 "vim_id": "608b73-r9cc-5a6a-a270-82cc4811bd4a",
                 "exit_on_floating_ip_error": False,
             },
-            created_items,
         )
         self.vimconn.neutron.show_floatingip.assert_not_called()
         mock_sleep.assert_not_called()
@@ -3600,7 +3588,6 @@ class TestNewVmInstance(unittest.TestCase):
                 "vim_id": "608b73-r9cc-5a6a-a270-82cc4811bd4a",
                 "exit_on_floating_ip_error": True,
             },
-            created_items,
         )
         self.vimconn.neutron.show_floatingip.assert_not_called()
         mock_sleep.assert_not_called()
@@ -3656,7 +3643,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3664,7 +3650,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3672,7 +3657,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(self.vimconn.neutron.show_floatingip.call_count, 3)
@@ -3735,7 +3719,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3743,7 +3726,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3751,7 +3733,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3759,7 +3740,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
 
@@ -3813,7 +3793,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3821,7 +3800,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3829,7 +3807,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3837,7 +3814,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
 
@@ -3894,7 +3870,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3902,7 +3877,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3910,7 +3884,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
 
@@ -3976,7 +3949,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3984,7 +3956,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
         self.assertEqual(
@@ -3992,7 +3963,6 @@ class TestNewVmInstance(unittest.TestCase):
             (
                 self.server,
                 floating_network,
-                created_items,
             ),
         )
 
index 3d5eb77..2de443c 100644 (file)
@@ -2305,14 +2305,13 @@ class vimconnector(vimconn.VimConnector):
         return self.neutron.show_floatingip(free_floating_ip)
 
     def _get_free_floating_ip(
-        self, server: object, floating_network: dict, created_items: dict
+        self, server: object, floating_network: dict
     ) -> Optional[str]:
         """Get the free floating IP address.
 
         Args:
             server  (object):               Server Object
             floating_network    (dict):     Floating network details
-            created_items   (dict):         All created items belongs to new VM instance
 
         Returns:
             free_floating_ip    (str):      Free floating ip addr
@@ -2324,9 +2323,7 @@ class vimconnector(vimconn.VimConnector):
         # Randomize
         random.shuffle(floating_ips)
 
-        return self._find_floating_ip(
-            server, floating_ips, floating_network, created_items
-        )
+        return self._find_floating_ip(server, floating_ips, floating_network)
 
     def _prepare_external_network_for_vminstance(
         self,
@@ -2356,7 +2353,7 @@ class vimconnector(vimconn.VimConnector):
                 while not assigned:
 
                     free_floating_ip = self._get_free_floating_ip(
-                        server, floating_network, created_items
+                        server, floating_network
                     )
 
                     if not free_floating_ip:
diff --git a/releasenotes/notes/fixing_method_signature-d09f0b0320474a79.yaml b/releasenotes/notes/fixing_method_signature-d09f0b0320474a79.yaml
new file mode 100644 (file)
index 0000000..69896ab
--- /dev/null
@@ -0,0 +1,21 @@
+#######################################################################################
+# 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:
+  - |
+    Fixing the signature of method _get_free_floating_ip in vimconn_openstack.py.
+