Merge "VMware: Fix re-attach volume error for VC 5.1"
This commit is contained in:
commit
bcc7ce05cb
@ -2760,6 +2760,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase):
|
|||||||
@mock.patch.object(VMDK_DRIVER, 'volumeops')
|
@mock.patch.object(VMDK_DRIVER, 'volumeops')
|
||||||
@mock.patch.object(VMDK_DRIVER, 'ds_sel')
|
@mock.patch.object(VMDK_DRIVER, 'ds_sel')
|
||||||
def test_relocate_backing_nop(self, ds_sel, vops):
|
def test_relocate_backing_nop(self, ds_sel, vops):
|
||||||
|
self._driver._storage_policy_enabled = True
|
||||||
volume = {'name': 'vol-1', 'size': 1}
|
volume = {'name': 'vol-1', 'size': 1}
|
||||||
|
|
||||||
datastore = mock.sentinel.datastore
|
datastore = mock.sentinel.datastore
|
||||||
@ -2784,6 +2785,7 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase):
|
|||||||
@mock.patch.object(VMDK_DRIVER, 'ds_sel')
|
@mock.patch.object(VMDK_DRIVER, 'ds_sel')
|
||||||
def test_relocate_backing_with_no_datastore(
|
def test_relocate_backing_with_no_datastore(
|
||||||
self, ds_sel, vops):
|
self, ds_sel, vops):
|
||||||
|
self._driver._storage_policy_enabled = True
|
||||||
volume = {'name': 'vol-1', 'size': 1}
|
volume = {'name': 'vol-1', 'size': 1}
|
||||||
|
|
||||||
profile = mock.sentinel.profile
|
profile = mock.sentinel.profile
|
||||||
@ -2838,6 +2840,40 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase):
|
|||||||
vops.move_backing_to_folder.assert_called_once_with(backing,
|
vops.move_backing_to_folder.assert_called_once_with(backing,
|
||||||
folder)
|
folder)
|
||||||
|
|
||||||
|
@mock.patch.object(VMDK_DRIVER, 'volumeops')
|
||||||
|
@mock.patch.object(VMDK_DRIVER, '_get_volume_group_folder')
|
||||||
|
@mock.patch.object(VMDK_DRIVER, 'ds_sel')
|
||||||
|
def test_relocate_backing_with_pbm_disabled(
|
||||||
|
self, ds_sel, get_volume_group_folder, vops):
|
||||||
|
self._driver._storage_policy_enabled = False
|
||||||
|
volume = {'name': 'vol-1', 'size': 1, 'project_id': 'abc'}
|
||||||
|
|
||||||
|
vops.is_datastore_accessible.return_value = False
|
||||||
|
|
||||||
|
backing = mock.sentinel.backing
|
||||||
|
host = mock.sentinel.host
|
||||||
|
|
||||||
|
rp = mock.sentinel.rp
|
||||||
|
datastore = mock.sentinel.datastore
|
||||||
|
summary = mock.Mock(datastore=datastore)
|
||||||
|
ds_sel.select_datastore.return_value = (host, rp, summary)
|
||||||
|
|
||||||
|
folder = mock.sentinel.folder
|
||||||
|
get_volume_group_folder.return_value = folder
|
||||||
|
|
||||||
|
self._driver._relocate_backing(volume, backing, host)
|
||||||
|
|
||||||
|
self.assertFalse(vops.get_profile.called)
|
||||||
|
vops.relocate_backing.assert_called_once_with(backing,
|
||||||
|
datastore,
|
||||||
|
rp,
|
||||||
|
host)
|
||||||
|
vops.move_backing_to_folder.assert_called_once_with(backing,
|
||||||
|
folder)
|
||||||
|
ds_sel.select_datastore.assert_called_once_with(
|
||||||
|
{hub.DatastoreSelector.SIZE_BYTES: volume['size'] * units.Gi,
|
||||||
|
hub.DatastoreSelector.PROFILE_NAME: None}, hosts=[host])
|
||||||
|
|
||||||
@mock.patch('oslo_vmware.api.VMwareAPISession')
|
@mock.patch('oslo_vmware.api.VMwareAPISession')
|
||||||
def test_session(self, apiSession):
|
def test_session(self, apiSession):
|
||||||
self._session = None
|
self._session = None
|
||||||
|
@ -1948,17 +1948,22 @@ class VMwareVcVmdkDriver(VMwareEsxVmdkDriver):
|
|||||||
# Check if the current datastore is visible to the host managing
|
# Check if the current datastore is visible to the host managing
|
||||||
# the instance and compliant with the storage profile.
|
# the instance and compliant with the storage profile.
|
||||||
datastore = self.volumeops.get_datastore(backing)
|
datastore = self.volumeops.get_datastore(backing)
|
||||||
backing_profile = self.volumeops.get_profile(backing)
|
backing_profile = None
|
||||||
|
if self._storage_policy_enabled:
|
||||||
|
backing_profile = self.volumeops.get_profile(backing)
|
||||||
if (self.volumeops.is_datastore_accessible(datastore, host) and
|
if (self.volumeops.is_datastore_accessible(datastore, host) and
|
||||||
self.ds_sel.is_datastore_compliant(datastore,
|
self.ds_sel.is_datastore_compliant(datastore,
|
||||||
backing_profile)):
|
backing_profile)):
|
||||||
LOG.debug("Datastore: %(datastore)s of backing: %(backing)s is "
|
LOG.debug("Datastore: %(datastore)s of backing: %(backing)s is "
|
||||||
"already accessible to instance's host: %(host)s and "
|
"already accessible to instance's host: %(host)s.",
|
||||||
"compliant with storage profile: %(profile)s.",
|
|
||||||
{'backing': backing,
|
{'backing': backing,
|
||||||
'datastore': datastore,
|
'datastore': datastore,
|
||||||
'host': host,
|
'host': host})
|
||||||
'profile': backing_profile})
|
if backing_profile:
|
||||||
|
LOG.debug("Backing: %(backing)s is compliant with "
|
||||||
|
"storage profile: %(profile)s.",
|
||||||
|
{'backing': backing,
|
||||||
|
'profile': backing_profile})
|
||||||
return
|
return
|
||||||
|
|
||||||
# We need to relocate the backing to an accessible and profile
|
# We need to relocate the backing to an accessible and profile
|
||||||
|
Loading…
Reference in New Issue
Block a user