'Enables / Disables the compute service on this host.
This doesn\'t override non-automatic disablement with an automatic
setting; thereby permitting operators to keep otherwise
healthy hosts out of rotation.'

def _set_host_enabled(self, enabled, disable_reason=DISABLE_REASON_UNDEFINED):

    status_name = {True: 'disabled', False: 'enabled'}
    disable_service = (not enabled)
    ctx = nova_context.get_admin_context()
    try:
        service = objects.Service.get_by_compute_host(ctx, CONF.host)
        if (service.disabled != disable_service):
            if ((not service.disabled) or (service.disabled_reason and service.disabled_reason.startswith(DISABLE_PREFIX))):
                service.disabled = disable_service
                service.disabled_reason = ((DISABLE_PREFIX + disable_reason) if (disable_service and disable_reason) else DISABLE_REASON_UNDEFINED)
                service.save()
                LOG.debug('Updating    compute    service    status    to    %s', status_name[disable_service])
            else:
                LOG.debug('Not    overriding    manual    compute    service    status    with:    %s', status_name[disable_service])
    except exception.ComputeHostNotFound:
        LOG.warning('Cannot    update    service    status    on    host    "%s"    since    it    is    not    registered.', CONF.host)
    except Exception:
        LOG.warning('Cannot    update    service    status    on    host    "%s"    due    to    an    unexpected    exception.', CONF.host, exc_info=True)
    if enabled:
        mount.get_manager().host_up(self._host)
    else:
        mount.get_manager().host_down()
