From: Gulsum Atici Date: Mon, 12 Dec 2022 16:21:25 +0000 (+0300) Subject: Fixing the signature of method X-Git-Tag: v12.0.6~10 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F72%2F12972%2F2;p=osm%2FRO.git Fixing the signature of method Correcting the signature of method _get_free_floating_ip in vimconn_openstack.py Change-Id: I0351b1c9af9543c02985601a30fe1e684db71e8a Signed-off-by: Gulsum Atici --- 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 c48d1843..1fa0af72 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 @@ -3124,7 +3124,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", @@ -3145,13 +3144,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") @@ -3161,15 +3158,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() @@ -3182,7 +3176,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", @@ -3206,14 +3199,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") @@ -3255,7 +3246,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" @@ -3309,7 +3299,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() @@ -3365,7 +3354,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() @@ -3420,7 +3408,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() @@ -3476,7 +3463,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3484,7 +3470,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3492,7 +3477,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual(self.vimconn.neutron.show_floatingip.call_count, 3) @@ -3555,7 +3539,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3563,7 +3546,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3571,7 +3553,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3579,7 +3560,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) @@ -3633,7 +3613,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3641,7 +3620,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3649,7 +3627,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3657,7 +3634,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) @@ -3714,7 +3690,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3722,7 +3697,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3730,7 +3704,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) @@ -3796,7 +3769,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3804,7 +3776,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) self.assertEqual( @@ -3812,7 +3783,6 @@ class TestNewVmInstance(unittest.TestCase): ( self.server, floating_network, - created_items, ), ) diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py index f509db66..67b31ae6 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -2258,14 +2258,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 @@ -2277,9 +2276,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, @@ -2308,7 +2305,7 @@ class vimconnector(vimconn.VimConnector): # several times 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 index 00000000..69896ab5 --- /dev/null +++ b/releasenotes/notes/fixing_method_signature-d09f0b0320474a79.yaml @@ -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. +