]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
VMware: Add support for VVOL datastores
authorVipin Balachandran <vbala@vmware.com>
Thu, 17 Dec 2015 07:57:47 +0000 (23:57 -0800)
committerVipin Balachandran <vbala@vmware.com>
Thu, 17 Dec 2015 11:33:53 +0000 (03:33 -0800)
vCenter 6.0 added support for a new type of datastore called VVOL
datastore. A VVOL datastore represents a storage container which
is a logical grouping of virtual volumes in an array that supports
VVOL. A virtual disk in a VVOL datastore corresponds to a virtual
volume in the array. Since VVOL datastores are treated like VMFS
or NFS datastores by vCenter APIs, the changes in the VMDK driver
to support VVOL datastores are minimal.

This patch adds the following changes in the VMDK driver to support
VVOL datastores:

* Add VVOL datastore type to the list of allowed datastore types

* Skip VVOL datastore while creating a volume from a preallocated
glance image because it involves replacing the data file of a
temporary virtual disk with the downloaded preallocated image
which VVOL cannot support.

Implements: blueprint vmdk-vvol-support
Change-Id: I528e4caed616dfd9bd85c7de113024bea6709fc1

cinder/tests/unit/test_vmware_vmdk.py
cinder/volume/drivers/vmware/datastore.py
cinder/volume/drivers/vmware/vmdk.py

index e867fdb61f710771d6540c814822b8056a53786b..cb1006975c61242994e7625806e508a88cfb43d6 100644 (file)
@@ -687,6 +687,32 @@ class VMwareVcVmdkDriverTestCase(test.TestCase):
             dc_ref, src_path, dc_ref, dest_path)
         self.assertEqual(dest_path, ret)
 
+    @mock.patch.object(VMDK_DRIVER, '_select_datastore')
+    @mock.patch.object(VMDK_DRIVER, 'volumeops')
+    def test_get_temp_image_folder(self, vops, select_datastore):
+        host = mock.sentinel.host
+        resource_pool = mock.sentinel.rp
+        summary = mock.Mock()
+        ds_name = mock.sentinel.ds_name
+        summary.name = ds_name
+        select_datastore.return_value = (host, resource_pool, summary)
+
+        dc = mock.sentinel.dc
+        vops.get_dc.return_value = dc
+
+        image_size = 2 * units.Gi
+        ret = self._driver._get_temp_image_folder(image_size)
+
+        self.assertEqual((dc, ds_name, vmdk.TMP_IMAGES_DATASTORE_FOLDER_PATH),
+                         ret)
+        exp_req = {
+            hub.DatastoreSelector.SIZE_BYTES: image_size,
+            hub.DatastoreSelector.HARD_AFFINITY_DS_TYPE:
+                {hub.DatastoreType.VMFS, hub.DatastoreType.NFS}}
+        select_datastore.assert_called_once_with(exp_req)
+        vops.create_datastore_folder.assert_called_once_with(
+            ds_name, vmdk.TMP_IMAGES_DATASTORE_FOLDER_PATH, dc)
+
     @mock.patch.object(VMDK_DRIVER, '_select_ds_for_volume')
     @mock.patch.object(VMDK_DRIVER, '_get_storage_profile_id')
     @mock.patch('cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver.'
index e2a46a5a50fc6725a1da59961995e1eb10c754ed..ec7b8b17ed857be0b5d4b9ca0ad921fe6229a960 100644 (file)
@@ -35,8 +35,9 @@ class DatastoreType(object):
     NFS = "nfs"
     VMFS = "vmfs"
     VSAN = "vsan"
+    VVOL = "vvol"
 
-    _ALL_TYPES = {NFS, VMFS, VSAN}
+    _ALL_TYPES = {NFS, VMFS, VSAN, VVOL}
 
     @staticmethod
     def get_all_types():
index d01b87ebcc4490415240d069d751f52d73a0252f..6903e03223cdb120f27891ce5366938c035ad7cf 100644 (file)
@@ -731,10 +731,11 @@ class VMwareVcVmdkDriver(driver.VolumeDriver):
         # Form requirements for datastore selection.
         req = {}
         req[hub.DatastoreSelector.SIZE_BYTES] = image_size_in_bytes
-        # vSAN datastores don't support virtual disk with
+        # vSAN/VVOL datastores don't support virtual disk with
         # flat extent; skip such datastores.
         req[hub.DatastoreSelector.HARD_AFFINITY_DS_TYPE] = (
-            hub.DatastoreType.get_all_types() - {hub.DatastoreType.VSAN})
+            hub.DatastoreType.get_all_types() -
+            {hub.DatastoreType.VSAN, hub.DatastoreType.VVOL})
 
         # Select datastore satisfying the requirements.
         (host_ref, _resource_pool, summary) = self._select_datastore(req)