Adding missing variable 83/12983/1
authorGulsum Atici <gulsum.atici@canonical.com>
Thu, 17 Nov 2022 21:10:15 +0000 (00:10 +0300)
committeraticig <gulsum.atici@canonical.com>
Thu, 16 Feb 2023 14:26:24 +0000 (15:26 +0100)
Missing variable block_device_mapping is added to prepare_disk_for_vminstance method

Change-Id: Ic759df4d53b6d0f454b2a851215aa40402b3053a
Signed-off-by: Gulsum Atici <gulsum.atici@canonical.com>
(cherry picked from commit 13d0232214b1f8db522ee8861741b938ea37bd45)

RO-VIM-openstack/osm_rovim_openstack/tests/test_vimconn_openstack.py
RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
releasenotes/notes/fixing_block_device_mapping_variable-0512331f482fe8bc.yaml [new file with mode: 0644]

index 4799449..1c6a40b 100644 (file)
@@ -2671,6 +2671,7 @@ class TestNewVmInstance(unittest.TestCase):
         """Prepare disks for VM instance successfully."""
         existing_vim_volumes = []
         created_items = {}
+        block_device_mapping = {}
         vm_av_zone = ["nova"]
 
         mock_root_volumes.return_value = root_vol_id
@@ -2679,7 +2680,12 @@ class TestNewVmInstance(unittest.TestCase):
         self.vimconn.cinder = CopyingMock()
 
         self.vimconn._prepare_disk_for_vminstance(
-            name, existing_vim_volumes, created_items, vm_av_zone, disk_list2
+            name,
+            existing_vim_volumes,
+            created_items,
+            vm_av_zone,
+            block_device_mapping,
+            disk_list2,
         )
         self.vimconn.cinder.volumes.set_bootable.assert_called_once_with(
             root_vol_id, True
@@ -2722,6 +2728,7 @@ class TestNewVmInstance(unittest.TestCase):
         existing_vim_volumes = []
         created_items = {}
         vm_av_zone = ["nova"]
+        block_device_mapping = {}
 
         mock_root_volumes.return_value = root_vol_id
         mock_created_vol_availability.return_value = 1700
@@ -2729,7 +2736,12 @@ class TestNewVmInstance(unittest.TestCase):
 
         with self.assertRaises(VimConnException) as err:
             self.vimconn._prepare_disk_for_vminstance(
-                name, existing_vim_volumes, created_items, vm_av_zone, disk_list2
+                name,
+                existing_vim_volumes,
+                created_items,
+                vm_av_zone,
+                block_device_mapping,
+                disk_list2,
             )
         self.assertEqual(
             str(err.exception), "Timeout creating volumes for instance basicvm"
@@ -2774,12 +2786,18 @@ class TestNewVmInstance(unittest.TestCase):
         """Disk list is empty."""
         existing_vim_volumes = []
         created_items = {}
+        block_device_mapping = {}
         vm_av_zone = ["nova"]
         mock_created_vol_availability.return_value = 2
         mock_existing_vol_availability.return_value = 3
 
         self.vimconn._prepare_disk_for_vminstance(
-            name, existing_vim_volumes, created_items, vm_av_zone, disk_list
+            name,
+            existing_vim_volumes,
+            created_items,
+            vm_av_zone,
+            block_device_mapping,
+            disk_list,
         )
         self.vimconn.cinder.volumes.set_bootable.assert_not_called()
         mock_created_vol_availability.assert_called_once_with(0, created_items)
@@ -2802,6 +2820,7 @@ class TestNewVmInstance(unittest.TestCase):
         existing_vim_volumes = []
         created_items = {}
         vm_av_zone = ["nova"]
+        block_device_mapping = {}
 
         mock_root_volumes.side_effect = Exception()
         mock_created_vol_availability.return_value = 10
@@ -2809,7 +2828,12 @@ class TestNewVmInstance(unittest.TestCase):
 
         with self.assertRaises(Exception):
             self.vimconn._prepare_disk_for_vminstance(
-                name, existing_vim_volumes, created_items, vm_av_zone, disk_list2
+                name,
+                existing_vim_volumes,
+                created_items,
+                vm_av_zone,
+                block_device_mapping,
+                disk_list2,
             )
         self.vimconn.cinder.volumes.set_bootable.assert_not_called()
         mock_created_vol_availability.assert_not_called()
@@ -2840,13 +2864,19 @@ class TestNewVmInstance(unittest.TestCase):
         existing_vim_volumes = []
         created_items = {}
         vm_av_zone = ["nova"]
+        block_device_mapping = {}
 
         mock_root_volumes.return_value = root_vol_id
         mock_non_root_volumes.side_effect = Exception
 
         with self.assertRaises(Exception):
             self.vimconn._prepare_disk_for_vminstance(
-                name, existing_vim_volumes, created_items, vm_av_zone, disk_list2
+                name,
+                existing_vim_volumes,
+                created_items,
+                vm_av_zone,
+                block_device_mapping,
+                disk_list2,
             )
         self.vimconn.cinder.volumes.set_bootable.assert_not_called()
         mock_created_vol_availability.assert_not_called()
@@ -4021,6 +4051,7 @@ class TestNewVmInstance(unittest.TestCase):
             existing_vim_volumes=[],
             created_items={},
             vm_av_zone="nova",
+            block_device_mapping={},
             disk_list=disk_list2,
         )
         self.vimconn.nova.servers.create.assert_called_once_with(
@@ -4033,7 +4064,7 @@ class TestNewVmInstance(unittest.TestCase):
             key_name="my_keypair",
             userdata="userdata",
             config_drive=True,
-            block_device_mapping=None,
+            block_device_mapping={},
             scheduler_hints={},
         )
         mock_time.assert_called_once()
@@ -4187,6 +4218,7 @@ class TestNewVmInstance(unittest.TestCase):
             existing_vim_volumes=[],
             created_items={},
             vm_av_zone="nova",
+            block_device_mapping={},
             disk_list=disk_list2,
         )
         self.vimconn.nova.servers.create.assert_called_once_with(
@@ -4199,7 +4231,7 @@ class TestNewVmInstance(unittest.TestCase):
             key_name="my_keypair",
             userdata="userdata",
             config_drive=True,
-            block_device_mapping=None,
+            block_device_mapping={},
             scheduler_hints={},
         )
         mock_time.assert_called_once()
@@ -4281,6 +4313,7 @@ class TestNewVmInstance(unittest.TestCase):
             existing_vim_volumes=[],
             created_items={},
             vm_av_zone="nova",
+            block_device_mapping={},
             disk_list=disk_list2,
         )
         self.vimconn.nova.servers.create.assert_called_once_with(
@@ -4293,7 +4326,7 @@ class TestNewVmInstance(unittest.TestCase):
             key_name="my_keypair",
             userdata="userdata",
             config_drive=True,
-            block_device_mapping=None,
+            block_device_mapping={},
             scheduler_hints={"group": "38b73-e9cc-5a6a-t270-82cc4811bd4a"},
         )
         mock_time.assert_called_once()
@@ -4374,6 +4407,7 @@ class TestNewVmInstance(unittest.TestCase):
             existing_vim_volumes=[],
             created_items={},
             vm_av_zone="nova",
+            block_device_mapping={},
             disk_list=disk_list2,
         )
 
@@ -4387,7 +4421,7 @@ class TestNewVmInstance(unittest.TestCase):
             key_name="my_keypair",
             userdata="userdata",
             config_drive=True,
-            block_device_mapping=None,
+            block_device_mapping={},
             scheduler_hints={},
         )
         mock_time.assert_not_called()
index 0a237d9..9e6f7aa 100644 (file)
@@ -2194,6 +2194,7 @@ class vimconnector(vimconn.VimConnector):
         existing_vim_volumes: list,
         created_items: dict,
         vm_av_zone: list,
+        block_device_mapping: dict,
         disk_list: list = None,
     ) -> None:
         """Prepare all volumes for new VM instance.
@@ -2203,6 +2204,7 @@ class vimconnector(vimconn.VimConnector):
             existing_vim_volumes    (list):     List of existing volumes
             created_items   (dict):             All created items belongs to VM
             vm_av_zone  (list):                 VM availability zone
+            block_device_mapping (dict):        Block devices to be attached to VM
             disk_list   (list):                 List of disks
 
         """
@@ -2211,7 +2213,6 @@ class vimconnector(vimconn.VimConnector):
         boot_volume_id = None
         elapsed_time = 0
 
-        block_device_mapping = {}
         for disk in disk_list:
             if "image_id" in disk:
                 # Root persistent volume
@@ -2620,7 +2621,7 @@ class vimconnector(vimconn.VimConnector):
             external_network = []
             # List of ports with port-security disabled
             no_secured_ports = []
-            block_device_mapping = None
+            block_device_mapping = {}
             existing_vim_volumes = []
             server_group_id = None
             scheduller_hints = {}
@@ -2653,6 +2654,7 @@ class vimconnector(vimconn.VimConnector):
                     existing_vim_volumes=existing_vim_volumes,
                     created_items=created_items,
                     vm_av_zone=vm_av_zone,
+                    block_device_mapping=block_device_mapping,
                     disk_list=disk_list,
                 )
 
diff --git a/releasenotes/notes/fixing_block_device_mapping_variable-0512331f482fe8bc.yaml b/releasenotes/notes/fixing_block_device_mapping_variable-0512331f482fe8bc.yaml
new file mode 100644 (file)
index 0000000..d26c59e
--- /dev/null
@@ -0,0 +1,20 @@
+#######################################################################################
+# 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.
+#######################################################################################
+---
+other:
+  - |
+    Adding missing variable "block_device_mapping" to prepare_disk_for_vminstance method.