Merge "3PAR: fix volume migration for "in-use" volume."

This commit is contained in:
Zuul 2018-01-19 10:26:25 +00:00 committed by Gerrit Code Review
commit 9cd77136c5
2 changed files with 40 additions and 5 deletions

View File

@ -7720,6 +7720,36 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
self.assertEqual(self.FAKE_HOST, host['name'])
self.assertEqual(3, len(host['FCPaths']))
@mock.patch.object(volume_types, 'get_volume_type')
def test_migrate_fc_volume_attached_to_iscsi_protocol(self,
_mock_volume_types):
_mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_1
mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF)
protocol = "iSCSI"
volume = {'name': HPE3PARBaseDriver.VOLUME_NAME,
'volume_type_id': None,
'id': HPE3PARBaseDriver.CLONE_ID,
'display_name': 'Foo Volume',
'size': 2,
'status': 'in-use',
'host': HPE3PARBaseDriver.FAKE_HOST,
'source_volid': HPE3PARBaseDriver.VOLUME_ID}
loc_info = 'HPE3PARDriver:1234567:CPG-FC1'
host = {'host': 'stack@3parfc1',
'capabilities': {'location_info': loc_info,
'storage_protocol': protocol}}
result = self.driver.migrate_volume(context.get_admin_context(),
volume, host)
self.assertIsNotNone(result)
self.assertEqual((False, None), result)
expected = []
mock_client.assert_has_calls(expected)
def test_migrate_volume_attached(self):
self.migrate_volume_attached()

View File

@ -56,10 +56,11 @@ class HPE3PARDriverBase(driver.ManageableVD,
1.0.1 - Adds consistency group capability in generic volume groups.
1.0.2 - Adds capability.
1.0.3 - Added Tiramisu feature on 3PAR.
1.0.4 - Fixed Volume migration for "in-use" volume. bug #1744021
"""
VERSION = "1.0.3"
VERSION = "1.0.4"
def __init__(self, *args, **kwargs):
super(HPE3PARDriverBase, self).__init__(*args, **kwargs)
@ -303,10 +304,14 @@ class HPE3PARDriverBase(driver.ManageableVD,
@utils.trace
def migrate_volume(self, context, volume, host):
if volume['status'] == 'in-use':
LOG.debug("3PAR %(protocol)s driver cannot migrate in-use volume "
"to a host with storage_protocol=%(protocol)s",
{'protocol': self.protocol})
return False, None
protocol = host['capabilities']['storage_protocol']
if protocol != self.protocol:
LOG.debug("3PAR %(protocol)s driver cannot migrate in-use "
"volume to a host with "
"storage_protocol=%(storage_protocol)s",
{'protocol': self.protocol,
'storage_protocol': protocol})
return False, None
common = self._login()
try: