def init_host(self, host): LOG.debug('Host check') try: if not self.lxd.host_ping(): msg = _('Unable to connect to LXD daemon') raise exception.HostNotFound(msg) return True except lxd_exceptions.APIError as ex: msg = _('Unable to connect to LXD daemon: %s') % ex raise exception.HostNotFound(msg)
def init_host(self, host): LOG.debug('Host check') try: if not self.lxd.host_ping(): msg = _('Unable to connect to LXD daemon') raise exception.HostNotFound(msg) if CONF.lxd.default_profile not in self.lxd.profile_list(): profile = {'name': CONF.lxd.default_profile} self.lxd.profile_create(profile) return True except lxd_exceptions.APIError as ex: msg = _('Unable to connect to LXD daemon: %s') % ex raise exception.HostNotFound(msg)
def wrapped(self, req, id, service=None, *args, **kwargs): listed_hosts = _list_hosts(req, service) hosts = [h["host_name"] for h in listed_hosts] if id in hosts: return fn(self, req, id, *args, **kwargs) else: raise exception.HostNotFound(host=id)
def host_power_action(self, context, host_name, action): try: result = super(HostAPI, self).host_power_action(context, host_name, action) except exception.CellRoutingInconsistency: raise exception.HostNotFound(host=host_name) return result
def set_host_enabled(self, context, host_name, enabled): try: result = super(HostAPI, self).set_host_enabled(context, host_name, enabled) except exception.CellRoutingInconsistency: raise exception.HostNotFound(host=host_name) return result
def init_host(self, host): """Initialize the driver on the host. The pylxd Client is initialized. This initialization may raise an exception if the LXD instance cannot be found. The `host` argument is ignored here, as the LXD instance is assumed to be on the same system as the compute worker running this code. This is by (current) design. See `nova.virt.driver.ComputeDriver.init_host` for more information. """ try: self.client = pylxd.Client() except lxd_exceptions.ClientConnectionFailed as e: msg = _('Unable to connect to LXD daemon: %s') % e raise exception.HostNotFound(msg) self._after_reboot()