'Process failover for a volume.
There are 3 different cases that will return different update values
for the volume:
- Volume has replication enabled and failover succeeded: Set
replication status to failed-over.
- Volume has replication enabled and failover fails: Set status to
error, replication status to failover-error, and store previous
status in previous_status field.
- Volume replication is disabled: Set status to error, and store
status in previous_status field.'

def _failover_volume(self, volume, remote, is_demoted, replication_status):

    if self._is_replicated_type(volume.volume_type):
        vol_name = utils.convert_str(volume.name)
        try:
            self._exec_on_volume(vol_name, remote, 'mirror_image_promote', (not is_demoted))
            return {'volume_id': volume.id, 'updates': {'replication_status': replication_status}}
        except Exception as e:
            replication_status = fields.ReplicationStatus.FAILOVER_ERROR
            LOG.error('Failed    to    failover    volume    %(volume)s    with    error:    %(error)s.', {'volume': volume.name, 'error': e})
    else:
        replication_status = fields.ReplicationStatus.NOT_CAPABLE
        LOG.debug('Skipping    failover    for    non    replicated    volume    %(volume)s    with    status:    %(status)s', {'volume': volume.name, 'status': volume.status})
    error_result = {'volume_id': volume.id, 'updates': {'status': 'error', 'previous_status': volume.status, 'replication_status': replication_status}}
    return error_result
