'Enable/Disable scheduling for a service.
Includes Freeze/Thaw which sends call down to drivers
and allows volume.manager for the specified host to
disable the service rather than accessing the service
directly in this API layer.'

def update(self, req, id, body):

    context = req.environ['cinder.context']
    authorize(context, action='update')
    support_dynamic_log = req.api_version_request.matches('3.32')
    ext_loaded = self.ext_mgr.is_loaded('os-extended-services')
    ret_val = {}
    if (id == 'enable'):
        disabled = False
        status = 'enabled'
        if ext_loaded:
            ret_val['disabled_reason'] = None
    elif ((id == 'disable') or ((id == 'disable-log-reason') and ext_loaded)):
        disabled = True
        status = 'disabled'
    elif (id == 'freeze'):
        return self._freeze(context, req, body)
    elif (id == 'thaw'):
        return self._thaw(context, req, body)
    elif (id == 'failover_host'):
        return self._failover(context, req, body, False)
    elif (req.api_version_request.matches('3.26') and (id == 'failover')):
        return self._failover(context, req, body, True)
    elif (support_dynamic_log and (id == 'set-log')):
        return self._set_log(context, body)
    elif (support_dynamic_log and (id == 'get-log')):
        return self._get_log(context, body)
    else:
        raise exception.InvalidInput(reason=_('Unknown    action'))
    host = common.get_cluster_host(req, body, False)[1]
    ret_val['disabled'] = disabled
    if ((id == 'disable-log-reason') and ext_loaded):
        reason = body.get('disabled_reason')
        if (not self._is_valid_as_reason(reason)):
            msg = _('Disabled    reason    contains    invalid    characters    or    is    too    long')
            raise webob.exc.HTTPBadRequest(explanation=msg)
        ret_val['disabled_reason'] = reason
    service = body.get('service', '')
    binary = body.get('binary', '')
    binary_key = (binary or service)
    if (not binary_key):
        raise webob.exc.HTTPBadRequest()
    svc = objects.Service.get_by_args(context, host, binary_key)
    svc.disabled = ret_val['disabled']
    if ('disabled_reason' in ret_val):
        svc.disabled_reason = ret_val['disabled_reason']
    svc.save()
    ret_val.update({'host': host, 'service': service, 'binary': binary, 'status': status})
    return ret_val
