'Sets the compute host\'s ability to accept new instances.'

def set_host_enabled(self, enabled):

    cntxt = context.get_admin_context()
    service = objects.Service.get_by_args(cntxt, CONF.host, 'nova-compute')
    service.disabled = (not enabled)
    service.disabled_reason = 'set    by    xenapi    host_state'
    service.save()
    response = _call_host_management(self._session, host_management.set_host_enabled, jsonutils.dumps(enabled))
    return response.get('status', response)
