VMware: Fix retype when storage policy is enabled
If storage policy is enabled, retype checks if the volume is compliant (using is_datastore_compliant method) with the policy mentioned in the new volume type. This check is failing because is_datastore_compliant calls _filter_by_profile passing a list, and this call fails since _filter_by_profile expects a dictionary after change I0c505cbe1c82b9cbd2918a223a53a800a9bc7931. Closes-bug: #1599167 Change-Id: Ia62f5f268c124a3665a7a9e0e2d3c84cb6f2e632
This commit is contained in:
parent
c523afa0fd
commit
50276fd5c5
@ -341,19 +341,21 @@ class DatastoreTest(test.TestCase):
|
||||
get_profile_id_by_name.reset_mock()
|
||||
profile_id = mock.sentinel.profile_id
|
||||
get_profile_id_by_name.return_value = profile_id
|
||||
filter_by_profile.return_value = []
|
||||
filter_by_profile.return_value = {}
|
||||
self.assertFalse(self._ds_sel.is_datastore_compliant(datastore,
|
||||
profile_name))
|
||||
get_profile_id_by_name.assert_called_once_with(self._session,
|
||||
profile_name)
|
||||
filter_by_profile.assert_called_once_with([datastore], profile_id)
|
||||
filter_by_profile.assert_called_once_with({datastore: None},
|
||||
profile_id)
|
||||
|
||||
# Test with valid profile and compliant datastore.
|
||||
get_profile_id_by_name.reset_mock()
|
||||
filter_by_profile.reset_mock()
|
||||
filter_by_profile.return_value = [datastore]
|
||||
filter_by_profile.return_value = {datastore: None}
|
||||
self.assertTrue(self._ds_sel.is_datastore_compliant(datastore,
|
||||
profile_name))
|
||||
get_profile_id_by_name.assert_called_once_with(self._session,
|
||||
profile_name)
|
||||
filter_by_profile.assert_called_once_with([datastore], profile_id)
|
||||
filter_by_profile.assert_called_once_with({datastore: None},
|
||||
profile_id)
|
||||
|
@ -294,7 +294,12 @@ class DatastoreSelector(object):
|
||||
return True
|
||||
|
||||
profile_id = self.get_profile_id(profile_name)
|
||||
is_compliant = bool(self._filter_by_profile([datastore], profile_id))
|
||||
# _filter_by_profile expects a map of datastore references to its
|
||||
# properties. It only uses the properties to construct a map of
|
||||
# filtered datastores to its properties. Here we don't care about
|
||||
# the datastore property, so pass it as None.
|
||||
is_compliant = bool(self._filter_by_profile({datastore: None},
|
||||
profile_id))
|
||||
LOG.debug("Compliance is %(is_compliant)s for datastore: "
|
||||
"%(datastore)s against profile: %(profile)s.",
|
||||
{'is_compliant': is_compliant,
|
||||
|
Loading…
x
Reference in New Issue
Block a user