+ @patch.object(vimconnector, "update_block_device_mapping")
+ def test__prepare_shared_volumes_vim_using_volume_id(
+ self, mock_update_block_device_mapping
+ ):
+ """Existing persistent non root volume with vim_volume_id.
+ class Volume:
+ def __init__(self, s, type="__DEFAULT__", name="", id=""):
+ self.status = s
+ self.volume_type = type
+ self.name = name
+ self.id = id
+ volumes = {"shared-volume": volume_id4}
+
+ The device mappeing BEFORE is: {}
+ The device mappeing AFTER is: {'vdb': '8ca50cc6-a779-4513-a1f3-900b8b3987d2'}
+ """
+ base_disk_index = ord("b")
+ disk = {"name": "shared-volume"}
+ block_device_mapping = {}
+ existing_vim_volumes = []
+ created_items = {}
+ expected_block_device_mapping = {}
+ self.vimconn.cinder.volumes.list.return_value = [
+ Volume("avaible", "multiattach", "shared-volume", volume_id4)
+ ]
+ self.vimconn.cinder.volumes.get.return_value.id = volume_id4
+ self.vimconn._prepare_shared_volumes(
+ name,
+ disk,
+ base_disk_index,
+ block_device_mapping,
+ existing_vim_volumes,
+ created_items,
+ )
+ self.vimconn.cinder.volumes.get.assert_called_with(volume_id4)
+ self.assertDictEqual(block_device_mapping, expected_block_device_mapping)
+