def _set_enabled_status(self, context, host_name, enabled):
        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
Sets the specified host's ability to accept new instances.
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/hosts.py/HostController._set_enabled_status