Merge "VMAX driver - failover error fix"
This commit is contained in:
@@ -9235,6 +9235,7 @@ class VMAXCommonTest(test.TestCase):
|
|||||||
self.assertEqual(verify_update_fo, volume_update)
|
self.assertEqual(verify_update_fo, volume_update)
|
||||||
# Path 2: Failback non replicated volume
|
# Path 2: Failback non replicated volume
|
||||||
# Path 2a: Volume still available on primary
|
# Path 2a: Volume still available on primary
|
||||||
|
common.failover = True
|
||||||
verify_update_fb1 = [{'volume_id': volumes[0]['id'],
|
verify_update_fb1 = [{'volume_id': volumes[0]['id'],
|
||||||
'updates': {'status': 'available'}}]
|
'updates': {'status': 'available'}}]
|
||||||
secondary_id, volume_update_1 = (
|
secondary_id, volume_update_1 = (
|
||||||
@@ -9243,6 +9244,7 @@ class VMAXCommonTest(test.TestCase):
|
|||||||
# Path 2a: Volume not still available on primary
|
# Path 2a: Volume not still available on primary
|
||||||
with mock.patch.object(common, '_find_lun',
|
with mock.patch.object(common, '_find_lun',
|
||||||
return_value=None):
|
return_value=None):
|
||||||
|
common.failover = True
|
||||||
secondary_id, volume_update_2 = (
|
secondary_id, volume_update_2 = (
|
||||||
common.failover_host('context', volumes, 'default'))
|
common.failover_host('context', volumes, 'default'))
|
||||||
self.assertEqual(verify_update_fo, volume_update_2)
|
self.assertEqual(verify_update_fo, volume_update_2)
|
||||||
@@ -9632,6 +9634,7 @@ class EMCV3ReplicationTest(test.TestCase):
|
|||||||
{'replication_status': fields.ReplicationStatus.ENABLED,
|
{'replication_status': fields.ReplicationStatus.ENABLED,
|
||||||
'provider_location': loc,
|
'provider_location': loc,
|
||||||
'replication_driver_data': rep_data}}])
|
'replication_driver_data': rep_data}}])
|
||||||
|
self.driver.common.failover = True
|
||||||
secondary_id, volume_update_list = (
|
secondary_id, volume_update_list = (
|
||||||
self.driver.failover_host('context', volumes, 'default'))
|
self.driver.failover_host('context', volumes, 'default'))
|
||||||
self.assertEqual(check_update_list, volume_update_list)
|
self.assertEqual(check_update_list, volume_update_list)
|
||||||
@@ -9677,6 +9680,7 @@ class EMCV3ReplicationTest(test.TestCase):
|
|||||||
{'replication_status': fields.ReplicationStatus.ENABLED,
|
{'replication_status': fields.ReplicationStatus.ENABLED,
|
||||||
'replication_driver_data': rep_data,
|
'replication_driver_data': rep_data,
|
||||||
'provider_location': loc}}])
|
'provider_location': loc}}])
|
||||||
|
self.driver.common.failover = True
|
||||||
secondary_id, volume_update_list = (
|
secondary_id, volume_update_list = (
|
||||||
self.driver.failover_host('context', volumes, 'default'))
|
self.driver.failover_host('context', volumes, 'default'))
|
||||||
self.assertEqual(check_update_list, volume_update_list)
|
self.assertEqual(check_update_list, volume_update_list)
|
||||||
@@ -9698,6 +9702,7 @@ class EMCV3ReplicationTest(test.TestCase):
|
|||||||
fields.ReplicationStatus.FAILOVER_ERROR),
|
fields.ReplicationStatus.FAILOVER_ERROR),
|
||||||
'provider_location': fake_location,
|
'provider_location': fake_location,
|
||||||
'replication_driver_data': 'fake_data'}}])
|
'replication_driver_data': 'fake_data'}}])
|
||||||
|
self.driver.common.failover = True
|
||||||
secondary_id, volume_update_list = (
|
secondary_id, volume_update_list = (
|
||||||
self.driver.failover_host('context', fake_volumes, 'default'))
|
self.driver.failover_host('context', fake_volumes, 'default'))
|
||||||
self.assertEqual(check_update_list, volume_update_list)
|
self.assertEqual(check_update_list, volume_update_list)
|
||||||
@@ -10016,3 +10021,17 @@ class EMCV3ReplicationTest(test.TestCase):
|
|||||||
self.driver.delete_volume(volume)
|
self.driver.delete_volume(volume)
|
||||||
common.cleanup_lun_replication.assert_called_once_with(
|
common.cleanup_lun_replication.assert_called_once_with(
|
||||||
common.conn, volume, volumeName, volumeInstance, extraSpecs)
|
common.conn, volume, volumeName, volumeInstance, extraSpecs)
|
||||||
|
|
||||||
|
def test_failback_failover_wrong_state(self):
|
||||||
|
common = self.driver.common
|
||||||
|
volumes = [self.data.test_volume_re]
|
||||||
|
# failover command, backend already failed over
|
||||||
|
common.failover = True
|
||||||
|
self.assertRaises(exception.VolumeBackendAPIException,
|
||||||
|
self.driver.failover_host,
|
||||||
|
'context', volumes, None)
|
||||||
|
# failback command, backend not failed over
|
||||||
|
common.failover = False
|
||||||
|
self.assertRaises(exception.VolumeBackendAPIException,
|
||||||
|
self.driver.failover_host,
|
||||||
|
'context', volumes, 'default')
|
||||||
|
|||||||
@@ -5319,12 +5319,34 @@ class VMAXCommon(object):
|
|||||||
if not self.conn:
|
if not self.conn:
|
||||||
self.conn = self._get_ecom_connection()
|
self.conn = self._get_ecom_connection()
|
||||||
if secondary_id != 'default':
|
if secondary_id != 'default':
|
||||||
|
if not self.failover:
|
||||||
self.failover = True
|
self.failover = True
|
||||||
if self.rep_config:
|
if self.rep_config:
|
||||||
secondary_id = self.rep_config['array']
|
secondary_id = self.rep_config['array']
|
||||||
else:
|
else:
|
||||||
|
exception_message = (_(
|
||||||
|
"Backend %(backend)s is already failed over. "
|
||||||
|
"If you wish to failback, please append "
|
||||||
|
"'--backend_id default' to your command.")
|
||||||
|
% {'backend': self.configuration.safe_get(
|
||||||
|
'volume_backend_name')})
|
||||||
|
LOG.error(exception_message)
|
||||||
|
raise exception.VolumeBackendAPIException(
|
||||||
|
data=exception_message)
|
||||||
|
else:
|
||||||
|
if self.failover:
|
||||||
self.failover = False
|
self.failover = False
|
||||||
secondary_id = None
|
secondary_id = None
|
||||||
|
else:
|
||||||
|
exception_message = (_(
|
||||||
|
"Cannot failback backend %(backend)s- backend not "
|
||||||
|
"in failed over state. If you meant to failover, please "
|
||||||
|
"omit the '--backend_id default' from the command")
|
||||||
|
% {'backend': self.configuration.safe_get(
|
||||||
|
'volume_backend_name')})
|
||||||
|
LOG.error(exception_message)
|
||||||
|
raise exception.VolumeBackendAPIException(
|
||||||
|
data=exception_message)
|
||||||
|
|
||||||
def failover_volume(vol, failover):
|
def failover_volume(vol, failover):
|
||||||
loc = vol['provider_location']
|
loc = vol['provider_location']
|
||||||
|
|||||||
Reference in New Issue
Block a user