def _set_host_enabled(self, enabled, disable_reason=DISABLE_REASON_UNDEFINED):
    "Enables / Disables the compute service on this host.\n\n           This doesn't override non-automatic disablement with an automatic\n           setting; thereby permitting operators to keep otherwise\n           healthy hosts out of rotation.\n        "
    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 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.warn(_LW('Cannot update service status on host: %s,since it is not registered.'), CONF.host)
    except Exception:
        LOG.warn(_LW('Cannot update service status on host: %s,due to an unexpected exception.'), CONF.host, exc_info=True)
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):
    "Enables / Disables the compute service on this host.\n\n           This doesn't override non-automatic disablement with an automatic\n           setting; thereby permitting operators to keep otherwise\n           healthy hosts out of rotation.\n        "
    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 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.warn(_LW('Cannot update service status on host: %s,since it is not registered.'), CONF.host)
    except Exception:
        LOG.warn(_LW('Cannot update service status on host: %s,due to an unexpected exception.'), CONF.host, exc_info=True)