

def _set_enabled_status(self, context, host_name, enabled):
    "Sets the specified host's ability to accept new instances.\n        :param enabled: a boolean - if False no new VMs will be able to start\n                        on the host.\n        "
    if enabled:
        LOG.info(_LI('Enabling host %s.'), host_name)
    else:
        LOG.info(_LI('Disabling host %s.'), host_name)
    try:
        result = self.api.set_host_enabled(context, host_name=host_name, enabled=enabled)
    except NotImplementedError:
        common.raise_feature_not_supported()
    except exception.HostNotFound as e:
        raise webob.exc.HTTPNotFound(explanation=e.format_message())
    except exception.ComputeServiceUnavailable as e:
        raise webob.exc.HTTPBadRequest(explanation=e.format_message())
    if (result not in ('enabled', 'disabled')):
        raise webob.exc.HTTPBadRequest(explanation=result)
    return result

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/hosts.py HostController._set_enabled_status/original