From fdd49d09a6c85b4b07be18d56ac29c5af2ac224f Mon Sep 17 00:00:00 2001 From: Vipin Balachandran Date: Tue, 16 May 2017 14:03:35 -0700 Subject: [PATCH] VMware: Config option for default adapter type Currently vmdk volumes are created with lsiLogic adapter. The volume may not be recognized if the guest OS does not support lsiLogic. Adding config option 'vmware_adapter_type' to specify the default adapter type for new volumes. DocImpact Added new driver config option 'vmware_adapter_type' to specify the default adapter type for new volumes created by the VMware VMDK driver. Partial-bug: #1691285 Change-Id: I2b923af59d51a8b0c94ef4e111d20958d44182b0 --- .../volume/drivers/vmware/test_vmware_vmdk.py | 7 +++++-- cinder/volume/drivers/vmware/vmdk.py | 16 ++++++++++++---- ...dk_default_adapter_type-8e247bce5b229c7a.yaml | 5 +++++ 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/vmware_vmdk_default_adapter_type-8e247bce5b229c7a.yaml diff --git a/cinder/tests/unit/volume/drivers/vmware/test_vmware_vmdk.py b/cinder/tests/unit/volume/drivers/vmware/test_vmware_vmdk.py index 0f1f0bb0f8a..8a87fd7cf03 100644 --- a/cinder/tests/unit/volume/drivers/vmware/test_vmware_vmdk.py +++ b/cinder/tests/unit/volume/drivers/vmware/test_vmware_vmdk.py @@ -71,6 +71,7 @@ class VMwareVcVmdkDriverTestCase(test.TestCase): SNAPSHOT_DESCRIPTION = 'test snapshot' IMAGE_ID = 'eb87f4b0-d625-47f8-bb45-71c43b486d3a' IMAGE_NAME = 'image-1' + ADAPTER_TYPE = volumeops.VirtualDiskAdapterType.BUS_LOGIC def setUp(self): super(VMwareVcVmdkDriverTestCase, self).setUp() @@ -92,6 +93,7 @@ class VMwareVcVmdkDriverTestCase(test.TestCase): self._config.vmware_cluster_name = self.CLUSTERS self._config.vmware_host_version = self.DEFAULT_VC_VERSION self._config.vmware_connection_pool_size = self.POOL_SIZE + self._config.vmware_adapter_type = self.ADAPTER_TYPE self._db = mock.Mock() self._driver = vmdk.VMwareVcVmdkDriver(configuration=self._config, @@ -2024,7 +2026,7 @@ class VMwareVcVmdkDriverTestCase(test.TestCase): volume['name']) exp_adapter_type = ( create_params.get(vmdk.CREATE_PARAM_ADAPTER_TYPE) or - 'lsiLogic') + self._driver.configuration.vmware_adapter_type) vops.create_backing.assert_called_once_with( exp_backing_name, volume['size'] * units.Mi, @@ -2393,7 +2395,8 @@ class VMwareVcVmdkDriverTestCase(test.TestCase): src_dc, src_path, dest_path, dest_dc_ref=dest_dc) get_storage_profile_id.assert_called_once_with(volume) vops.attach_disk_to_backing.assert_called_once_with( - backing, disk_device.capacityInKB, disk_type, 'lsiLogic', + backing, disk_device.capacityInKB, disk_type, + self._driver.configuration.vmware_adapter_type, profile_id, dest_path) vops.update_backing_disk_uuid.assert_called_once_with(backing, volume['id']) diff --git a/cinder/volume/drivers/vmware/vmdk.py b/cinder/volume/drivers/vmware/vmdk.py index d248a1877ac..4942ded9d95 100644 --- a/cinder/volume/drivers/vmware/vmdk.py +++ b/cinder/volume/drivers/vmware/vmdk.py @@ -128,6 +128,14 @@ vmdk_opts = [ cfg.IntOpt('vmware_connection_pool_size', default=10, help='Maximum number of connections in http connection pool.'), + cfg.StrOpt('vmware_adapter_type', + choices=[volumeops.VirtualDiskAdapterType.LSI_LOGIC, + volumeops.VirtualDiskAdapterType.BUS_LOGIC, + volumeops.VirtualDiskAdapterType.LSI_LOGIC_SAS, + volumeops.VirtualDiskAdapterType.PARA_VIRTUAL, + volumeops.VirtualDiskAdapterType.IDE], + default=volumeops.VirtualDiskAdapterType.LSI_LOGIC, + help='Default adapter type to be used for attaching volumes.'), ] CONF = cfg.CONF @@ -438,8 +446,8 @@ class VMwareVcVmdkDriver(driver.VolumeDriver): # create a backing with single disk disk_type = VMwareVcVmdkDriver._get_disk_type(volume) size_kb = volume['size'] * units.Mi - adapter_type = create_params.get(CREATE_PARAM_ADAPTER_TYPE, - 'lsiLogic') + adapter_type = create_params.get( + CREATE_PARAM_ADAPTER_TYPE, self.configuration.vmware_adapter_type) backing = self.volumeops.create_backing(backing_name, size_kb, disk_type, @@ -1151,7 +1159,7 @@ class VMwareVcVmdkDriver(driver.VolumeDriver): # Get the disk type, adapter type and size of vmdk image image_disk_type = ImageDiskType.PREALLOCATED - image_adapter_type = volumeops.VirtualDiskAdapterType.LSI_LOGIC + image_adapter_type = self.configuration.vmware_adapter_type image_size_in_bytes = metadata['size'] properties = metadata['properties'] if properties: @@ -1560,7 +1568,7 @@ class VMwareVcVmdkDriver(driver.VolumeDriver): backing, disk.capacityInKB, VMwareVcVmdkDriver._get_disk_type(volume), - 'lsiLogic', + self.configuration.vmware_adapter_type, profile_id, dest_path.get_descriptor_ds_file_path()) self.volumeops.update_backing_disk_uuid(backing, volume['id']) diff --git a/releasenotes/notes/vmware_vmdk_default_adapter_type-8e247bce5b229c7a.yaml b/releasenotes/notes/vmware_vmdk_default_adapter_type-8e247bce5b229c7a.yaml new file mode 100644 index 00000000000..ca11da09f39 --- /dev/null +++ b/releasenotes/notes/vmware_vmdk_default_adapter_type-8e247bce5b229c7a.yaml @@ -0,0 +1,5 @@ +--- +features: + - Added config option ``vmware_adapter_type`` for the VMware VMDK + driver to specify the default adapter type for volumes in vCenter + server.