def load_image_driver(image_driver=None): """Load an image driver module. Load the container image driver module specified by the image_driver configuration option or, if supplied, the driver name supplied as an argument. :param image_driver: container image driver name to override config opt :returns: a ContainerImageDriver instance """ if not image_driver: LOG.error( _LE("Container image driver option required, " "but not specified")) sys.exit(1) LOG.info(_LI("Loading container image driver '%s'"), image_driver) try: driver = importutils.import_object('zun.image.%s' % image_driver) if not isinstance(driver, ContainerImageDriver): raise Exception( _('Expected driver of type: %s') % str(ContainerImageDriver)) return driver except ImportError: LOG.exception(_LE("Unable to load the container image driver")) sys.exit(1)
def load_container_driver(container_driver=None): """Load a container driver module. Load the container driver module specified by the container_driver configuration option or, if supplied, the driver name supplied as an argument. :param container_driver: a container driver name to override the config opt :returns: a ContainerDriver instance """ if not container_driver: container_driver = CONF.container_driver if not container_driver: LOG.error( _LE("Container driver option required, " "but not specified")) sys.exit(1) LOG.info(_LI("Loading container driver '%s'"), container_driver) try: if not container_driver.startswith('zun.'): container_driver = 'zun.container.%s' % container_driver driver = importutils.import_object(container_driver) if not isinstance(driver, ContainerDriver): raise Exception( _('Expected driver of type: %s') % str(ContainerDriver)) return driver except ImportError: LOG.exception(_LE("Unable to load the container driver")) sys.exit(1)
def load_app(): cfg_file = None cfg_path = CONF.api.api_paste_config if not os.path.isabs(cfg_path): cfg_file = CONF.find_file(cfg_path) elif os.path.exists(cfg_path): cfg_file = cfg_path if not cfg_file: raise cfg.ConfigFilesNotFoundError([CONF.api.api_paste_config]) LOG.info(_LI("Full WSGI config used: %s"), cfg_file) return deploy.loadapp("config:" + cfg_file)
def _ensure_deleted(self, novaclient, server_id, timeout=300): '''Wait until the Nova instance to be deleted.''' def _check_delete_complete(): return novaclient.check_delete_server_complete(server_id) success_msg = _LI("Delete server %s successfully.") % server_id timeout_msg = _LE("Failed to create server %s. Timeout waiting for " "server to be deleted.") % server_id utils.poll_until(_check_delete_complete, sleep_time=CONF.default_sleep_time, time_out=timeout or CONF.default_timeout, success_msg=success_msg, timeout_msg=timeout_msg)
def _ensure_active(self, novaclient, server, timeout=300): '''Wait until the Nova instance to become active.''' def _check_active(): return novaclient.check_active(server) success_msg = _LI("Created server %s successfully.") % server.id timeout_msg = _LE("Failed to create server %s. Timeout waiting for " "server to become active.") % server.id utils.poll_until(_check_active, sleep_time=CONF.default_sleep_time, time_out=timeout or CONF.default_timeout, success_msg=success_msg, timeout_msg=timeout_msg)
def main(): zun_service.prepare_service(sys.argv) LOG.info(_LI('Starting server in PID %s'), os.getpid()) CONF.log_opt_values(LOG, logging.DEBUG) CONF.import_opt('topic', 'zun.conf.compute', group='compute') endpoints = [ compute_manager.Manager(), ] server = rpc_service.Service.create(CONF.compute.topic, CONF.host, endpoints, binary='zun-compute') launcher = service.launch(CONF, server) launcher.wait()