Merge "Check volume_backend in retype"
This commit is contained in:
commit
90412abbde
@ -674,3 +674,14 @@ class VolumeUtilsTestCase(test.TestCase):
|
||||
expected = None
|
||||
self.assertEqual(expected,
|
||||
volume_utils.append_host(host, pool))
|
||||
|
||||
def test_compare_hosts(self):
|
||||
host_1 = 'fake_host@backend1'
|
||||
host_2 = 'fake_host@backend1#pool1'
|
||||
self.assertTrue(volume_utils.hosts_are_equivalent(host_1, host_2))
|
||||
|
||||
host_2 = 'fake_host@backend1'
|
||||
self.assertTrue(volume_utils.hosts_are_equivalent(host_1, host_2))
|
||||
|
||||
host_2 = 'fake_host2@backend1'
|
||||
self.assertFalse(volume_utils.hosts_are_equivalent(host_1, host_2))
|
||||
|
@ -1665,7 +1665,17 @@ class VolumeManager(manager.SchedulerDependentManager):
|
||||
|
||||
# Call driver to try and change the type
|
||||
retype_model_update = None
|
||||
if not retyped:
|
||||
|
||||
# NOTE(jdg): Check to see if the destination host is the same
|
||||
# as the current. If it's not don't call the driver.retype
|
||||
# method, otherwise drivers that implement retype may report
|
||||
# success, but it's invalid in the case of a migrate.
|
||||
|
||||
# We assume that those that support pools do this internally
|
||||
# so we strip off the pools designation
|
||||
if (not retyped and
|
||||
vol_utils.hosts_are_equivalent(self.driver.host,
|
||||
host['host'])):
|
||||
try:
|
||||
new_type = volume_types.get_volume_type(context, new_type_id)
|
||||
ret = self.driver.retype(context,
|
||||
|
@ -507,3 +507,7 @@ def matching_backend_name(src_volume_type, volume_type):
|
||||
volume_type.get('volume_backend_name')
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def hosts_are_equivalent(host_1, host_2):
|
||||
return extract_host(host_1) == extract_host(host_2)
|
||||
|
Loading…
Reference in New Issue
Block a user