Adding missing variable 01/12701/3
authorGulsum Atici <gulsum.atici@canonical.com>
Thu, 17 Nov 2022 21:10:15 +0000 (00:10 +0300)
committerGulsum Atici <gulsum.atici@canonical.com>
Thu, 17 Nov 2022 21:34:21 +0000 (00:34 +0300)
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>
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 c48d184..f7a0f1d 100644 (file)
@@ -2631,6 +2631,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
@@ -2639,7 +2640,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
@@ -2682,6 +2688,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
@@ -2689,7 +2696,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"
@@ -2734,12 +2746,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)
@@ -2762,6 +2780,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
@@ -2769,7 +2788,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()
@@ -2800,13 +2824,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()
@@ -4011,6 +4041,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(
@@ -4023,7 +4054,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()
@@ -4177,6 +4208,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(
@@ -4189,7 +4221,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()
@@ -4271,6 +4303,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(
@@ -4283,7 +4316,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()
@@ -4364,6 +4397,7 @@ class TestNewVmInstance(unittest.TestCase):
             existing_vim_volumes=[],
             created_items={},
             vm_av_zone="nova",
+            block_device_mapping={},
             disk_list=disk_list2,
         )
 
@@ -4377,7 +4411,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 f3b89dc..993dccd 100644 (file)
@@ -2062,6 +2062,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.
@@ -2071,6 +2072,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
 
         """
@@ -2079,7 +2081,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
@@ -2493,7 +2494,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 = {}
@@ -2526,6 +2527,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.