'Failover backend to a secondary array
This action will not affect the original volumes in any
way and it will stay as is. If a subsequent failover is performed we
will simply overwrite the original (now unmanaged) volumes.'

@pure_driver_debug_trace
def failover_host(self, context, volumes, secondary_id=None, groups=None):

    if (secondary_id == 'default'):
        if self._failed_over_primary_array:
            self._set_current_array(self._failed_over_primary_array)
            return (secondary_id, [], [])
        else:
            msg = _('Unable    to    failback    to    "default",    this    can    only    be    done    after    a    failover    has    completed.')
            raise exception.InvalidReplicationTarget(message=msg)
    current_array = self._get_current_array()
    LOG.debug('Failover    replication    for    array    %(primary)s    to    %(secondary)s.', {'primary': current_array._backend_id, 'secondary': secondary_id})
    if (secondary_id == current_array._backend_id):
        raise exception.InvalidReplicationTarget(reason=(_('Secondary    id    can    not    be    the    same    as    primary    array,    backend_id    =    %(secondary)s.') % {'secondary': secondary_id}))
    (secondary_array, pg_snap) = self._find_failover_target(secondary_id)
    LOG.debug('Starting    failover    from    %(primary)s    to    %(secondary)s', {'primary': current_array.array_name, 'secondary': secondary_array.array_name})
    api_version = secondary_array.get_rest_version()
    LOG.debug('Current    REST    API    for    array    id    %(id)s    is    %(api_version)s', {'id': secondary_array.array_id, 'api_version': api_version})
    if (api_version != '1.3'):
        target_array = self._get_flasharray(secondary_array._target, api_token=secondary_array._api_token, rest_version='1.3', verify_https=secondary_array._verify_https, ssl_cert_path=secondary_array._ssl_cert)
    else:
        target_array = secondary_array
    volume_snaps = target_array.get_volume(pg_snap['name'], snap=True, pgroup=True)
    vol_names = set()
    for vol in volumes:
        vol_names.add(self._get_vol_name(vol))
    for snap in volume_snaps:
        vol_name = snap['name'].split('.')[(-1)]
        if (vol_name in vol_names):
            vol_names.remove(vol_name)
            LOG.debug('Creating    volume    %(vol)s    from    replicated    snapshot    %(snap)s', {'vol': vol_name, 'snap': snap['name']})
            secondary_array.copy_volume(snap['name'], vol_name, overwrite=True)
        else:
            LOG.debug('Ignoring    unmanaged    volume    %(vol)s    from    replicated    snapshot    %(snap)s.', {'vol': vol_name, 'snap': snap['name']})
    model_updates = []
    for vol in volumes:
        if (self._get_vol_name(vol) in vol_names):
            model_updates.append({'volume_id': vol['id'], 'updates': {'status': 'error'}})
    self._failed_over_primary_array = self._get_current_array()
    self._set_current_array(secondary_array)
    return (secondary_array._backend_id, model_updates, [])
