Fix driver.failover_host call in manager.py

We have things set on the driver to take a named arg here,
but were just passing in a positional value.

Fix that.

While we're at it, the HP and EMC drivers went their own way and used their own
parameters for failover.  We fix those up to match the other drivers including
the reference in driver.py.

Change-Id: I58e3d28e3185c2448556f75a21deecea5326a26f
Closes-Bug: #1564200
This commit is contained in:
John Griffith 2016-03-30 20:44:20 -06:00
parent f0a81d5abc
commit e01af62ecd
9 changed files with 22 additions and 21 deletions

View File

@ -6372,7 +6372,7 @@ class EMCVNXCLIDriverReplicationV2TestCase(DriverTestCaseBase):
fake_remote.return_value = self.driver.cli._client
invalid = 'invalid_backend_id'
self.assertRaisesRegex(exception.VolumeBackendAPIException,
"Invalid secondary_backend_id specified",
"Invalid secondary_id specified",
self.driver.failover_host,
None,
[rep_volume],

View File

@ -302,6 +302,6 @@ class EMCCLIFCDriver(driver.FibreChannelDriver):
def backup_use_temp_snapshot(self):
return True
def failover_host(self, context, volumes, secondary_backend_id):
def failover_host(self, context, volumes, secondary_id=None):
"""Failovers volume from primary device to secondary."""
return self.cli.failover_host(context, volumes, secondary_backend_id)
return self.cli.failover_host(context, volumes, secondary_id)

View File

@ -281,6 +281,6 @@ class EMCCLIISCSIDriver(driver.ISCSIDriver):
def backup_use_temp_snapshot(self):
return True
def failover_host(self, context, volumes, secondary_backend_id):
def failover_host(self, context, volumes, secondary_id=None):
"""Failovers volume from primary device to secondary."""
return self.cli.failover_host(context, volumes, secondary_backend_id)
return self.cli.failover_host(context, volumes, secondary_id)

View File

@ -4020,7 +4020,7 @@ class EMCVnxCliBase(object):
return specs
def failover_host(self, context, volumes, secondary_backend_id):
def failover_host(self, context, volumes, secondary_id=None):
"""Fails over the volume back and forth.
Driver needs to update following info for this volume:
@ -4028,12 +4028,12 @@ class EMCVnxCliBase(object):
"""
volume_update_list = []
if secondary_backend_id != 'default':
if secondary_id and secondary_id != 'default':
rep_status = 'failed-over'
backend_id = (
self.configuration.replication_device[0]['backend_id'])
if secondary_backend_id != backend_id:
msg = (_('Invalid secondary_backend_id specified. '
if secondary_id != backend_id:
msg = (_('Invalid secondary_id specified. '
'Valid backend id is %s.') % backend_id)
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
@ -4055,12 +4055,12 @@ class EMCVnxCliBase(object):
'Failed to failover volume %(volume_id)s '
'to %(target)s: %(error)s.')
LOG.error(msg, {'volume_id': volume.id,
'target': secondary_backend_id,
'target': secondary_id,
'error': ex},)
new_status = 'error'
else:
rep_data.update({'is_primary': not is_primary})
# Transfer ownership to secondary_backend_id and
# Transfer ownership to secondary_id and
# update provider_location field
provider_location = self._update_provider_location(
provider_location,
@ -4085,7 +4085,7 @@ class EMCVnxCliBase(object):
volume_update_list.append({
'volume_id': volume.id,
'updates': {'status': 'error'}})
return secondary_backend_id, volume_update_list
return secondary_id, volume_update_list
def _is_replication_enabled(self, volume):
"""Return True if replication extra specs is specified.

View File

@ -2920,7 +2920,8 @@ class HPE3PARCommon(object):
raise exception.VolumeBackendAPIException(data=msg)
# Check to see if the user requested to failback.
if secondary_backend_id == self.FAILBACK_VALUE:
if (secondary_backend_id and
secondary_backend_id == self.FAILBACK_VALUE):
volume_update_list = self._replication_failback(volumes)
target_id = None
else:

View File

@ -611,13 +611,13 @@ class HPE3PARFCDriver(driver.TransferVD,
finally:
self._logout(common)
def failover_host(self, context, volumes, secondary_backend_id):
def failover_host(self, context, volumes, secondary_id=None):
"""Force failover to a secondary replication target."""
common = self._login(timeout=30)
try:
# Update the active_backend_id in the driver and return it.
active_backend_id, volume_updates = common.failover_host(
context, volumes, secondary_backend_id)
context, volumes, secondary_id)
self._active_backend_id = active_backend_id
return active_backend_id, volume_updates
finally:

View File

@ -929,13 +929,13 @@ class HPE3PARISCSIDriver(driver.TransferVD,
finally:
self._logout(common)
def failover_host(self, context, volumes, secondary_backend_id):
def failover_host(self, context, volumes, secondary_id=None):
"""Force failover to a secondary replication target."""
common = self._login(timeout=30)
try:
# Update the active_backend_id in the driver and return it.
active_backend_id, volume_updates = common.failover_host(
context, volumes, secondary_backend_id)
context, volumes, secondary_id)
self._active_backend_id = active_backend_id
return active_backend_id, volume_updates
finally:

View File

@ -1403,15 +1403,15 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver):
return volume_types.get_volume_type(ctxt, type_id)
# v2 replication methods
def failover_host(self, context, volumes, secondary_backend_id):
def failover_host(self, context, volumes, secondary_id=None):
"""Force failover to a secondary replication target."""
if secondary_backend_id == self.FAILBACK_VALUE:
if secondary_id and secondary_id == self.FAILBACK_VALUE:
volume_update_list = self._replication_failback(volumes)
target_id = None
else:
failover_target = None
for target in self._replication_targets:
if target['backend_id'] == secondary_backend_id:
if target['backend_id'] == secondary_id:
failover_target = target
break
if not failover_target:

View File

@ -3297,7 +3297,7 @@ class VolumeManager(manager.SchedulerDependentManager):
self.driver.failover_host(
context,
volumes,
secondary_backend_id))
secondary_id=secondary_backend_id))
except exception.UnableToFailOver:
LOG.exception(_LE("Failed to perform replication failover"))
service.replication_status = (