'Fails over replications for a group.'

@wsgi.Controller.api_version(GROUP_REPLICATION_API_VERSION)
@wsgi.action('failover_replication')
def failover_replication(self, req, id, body):

    context = req.environ['cinder.context']
    if body:
        if (not self.is_valid_body(body, 'failover_replication')):
            msg = _("Missing    required    element    'failover_replication'    in    request    body.")
            raise exc.HTTPBadRequest(explanation=msg)
        grp_body = body['failover_replication']
        try:
            allow_attached = strutils.bool_from_string(grp_body.get('allow_attached_volume', False), strict=True)
        except ValueError:
            msg = (_("Invalid    value    '%s'    for    allow_attached_volume    flag.") % grp_body)
            raise exc.HTTPBadRequest(explanation=msg)
        secondary_backend_id = grp_body.get('secondary_backend_id')
    LOG.info('Failover    replication    group    with    id:    %s.', id, context=context)
    try:
        group = self.group_api.get(context, id)
        self.group_api.failover_replication(context, group, allow_attached, secondary_backend_id)
    except (exception.InvalidGroup, exception.InvalidGroupType, exception.InvalidVolume, exception.InvalidVolumeType) as error:
        raise exc.HTTPBadRequest(explanation=error.msg)
    return webob.Response(status_int=202)
