"""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
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
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
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"
"""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)
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
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()
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()
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(
key_name="my_keypair",
userdata="userdata",
config_drive=True,
- block_device_mapping=None,
+ block_device_mapping={},
scheduler_hints={},
)
mock_time.assert_called_once()
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(
key_name="my_keypair",
userdata="userdata",
config_drive=True,
- block_device_mapping=None,
+ block_device_mapping={},
scheduler_hints={},
)
mock_time.assert_called_once()
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(
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()
existing_vim_volumes=[],
created_items={},
vm_av_zone="nova",
+ block_device_mapping={},
disk_list=disk_list2,
)
key_name="my_keypair",
userdata="userdata",
config_drive=True,
- block_device_mapping=None,
+ block_device_mapping={},
scheduler_hints={},
)
mock_time.assert_not_called()
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.
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
"""
boot_volume_id = None
elapsed_time = 0
- block_device_mapping = {}
for disk in disk_list:
if "image_id" in disk:
# Root persistent volume
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 = {}
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,
)
--- /dev/null
+#######################################################################################
+# 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.