def main(): try: config.parse_args() wsgi.set_eventlet_hub() log.setup('glance') glance_store.register_opts(config.CONF) glance_store.create_stores(config.CONF) glance_store.verify_default_store() if cfg.CONF.profiler.enabled: _notifier = osprofiler.notifier.create("Messaging", notifier.messaging, {}, notifier.get_transport(), "glance", "api", cfg.CONF.bind_host) osprofiler.notifier.set(_notifier) else: osprofiler.web.disable() server = wsgi.Server() server.start(config.load_paste_app('glance-api'), default_port=9292) server.wait() except exception.WorkerCreationFailure as e: fail(2, e) except RuntimeError as e: fail(1, e)
def setUp(self): super(BaseTestCase, self).setUp() #NOTE(bcwaldon): parse_args has to be called to register certain # command-line options - specifically we need config_dir for # the following policy tests config.parse_args(args=[])
def main(): CONF.register_cli_opts([ cfg.Opt('os-username'), cfg.Opt('os-password'), cfg.Opt('os-auth-url'), cfg.Opt('os-tenant-name'), ]) try: logging.register_options(CONF) cfg_files = cfg.find_config_files(project='glance', prog='glance-api') cfg_files.extend( cfg.find_config_files(project='glance', prog='glance-search')) config.parse_args(default_config_files=cfg_files) logging.setup(CONF, 'glance') namespace = 'glance.search.index_backend' ext_manager = stevedore.extension.ExtensionManager(namespace, invoke_on_load=True) for ext in ext_manager.extensions: try: ext.obj.setup() except Exception as e: LOG.error( _LE("Failed to setup index extension " "%(ext)s: %(e)s") % { 'ext': ext.name, 'e': e }) except RuntimeError as e: sys.exit("ERROR: %s" % e)
def main(): CONF.register_cli_opt( cfg.BoolOpt('daemon', short='D', default=False, help='Run as a long-running process. When not ' 'specified (the default) run the scrub operation ' 'once and then exits. When specified do not exit ' 'and run scrub on wakeup_time interval as ' 'specified in the config.')) CONF.register_opt(cfg.IntOpt('wakeup_time', default=300)) try: config.parse_args() log.setup('glance') glance.store.create_stores() glance.store.verify_default_store() app = glance.store.scrubber.Scrubber() if CONF.daemon: server = glance.store.scrubber.Daemon(CONF.wakeup_time) server.start(app) server.wait() else: import eventlet pool = eventlet.greenpool.GreenPool(1000) scrubber = app.run(pool) except RuntimeError as e: sys.exit("ERROR: %s" % e)
def main(): CONF.register_cli_opt(command_opt) try: logging.register_options(CONF) cfg_files = cfg.find_config_files(project='glance', prog='glance-registry') cfg_files.extend(cfg.find_config_files(project='glance', prog='glance-api')) cfg_files.extend(cfg.find_config_files(project='glance', prog='glance-manage')) config.parse_args(default_config_files=cfg_files, usage="%(prog)s [options] <cmd>") logging.setup(CONF, 'glance') except RuntimeError as e: sys.exit("ERROR: %s" % e) try: if CONF.command.action.startswith('db'): return CONF.command.action_fn() else: func_kwargs = {} for k in CONF.command.action_kwargs: v = getattr(CONF.command, 'action_kwarg_' + k) if v is None: continue if isinstance(v, six.string_types): v = encodeutils.safe_decode(v) func_kwargs[k] = v func_args = [encodeutils.safe_decode(arg) for arg in CONF.command.action_args] return CONF.command.action_fn(*func_args, **func_kwargs) except exception.GlanceException as e: sys.exit("ERROR: %s" % utils.exception_to_str(e))
def main(): try: config.parse_args() config.set_config_defaults() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') notifier.set_defaults() if cfg.CONF.profiler.enabled: _notifier = osprofiler.notifier.create("Messaging", oslo_messaging, {}, notifier.get_transport(), "glance", "registry", cfg.CONF.bind_host) osprofiler.notifier.set(_notifier) osprofiler.web.enable(cfg.CONF.profiler.hmac_keys) else: osprofiler.web.disable() server = wsgi.Server() server.start(config.load_paste_app('glance-registry'), default_port=9191) server.wait() except RuntimeError as e: sys.exit("ERROR: %s" % encodeutils.exception_to_unicode(e))
def main(): CONF.register_cli_opt(command_opt) try: cfg_files = cfg.find_config_files( project='glance', prog='glance-registry') cfg_files.extend( cfg.find_config_files(project='glance', prog='glance-api')) config.parse_args( default_config_files=cfg_files, usage="%(prog)s [options] <cmd>") log.setup('glance') except RuntimeError as e: sys.exit("ERROR: %s" % e) try: if CONF.command.action.startswith('db'): return CONF.command.action_fn() else: func_kwargs = {} for k in CONF.command.action_kwargs: v = getattr(CONF.command, 'action_kwarg_' + k) if v is None: continue func_kwargs[k] = strutils.safe_decode(v) func_args = [ strutils.safe_decode(arg) for arg in CONF.command.action_args ] return CONF.command.action_fn(*func_args, **func_kwargs) except exception.GlanceException as e: sys.exit("ERROR: %s" % utils.exception_to_str(e))
def main(): try: config.parse_args() wsgi.set_eventlet_hub() log.setup('glance') glance_store.register_opts(config.CONF) glance_store.create_stores(config.CONF) glance_store.verify_default_store() if cfg.CONF.profiler.enabled: _notifier = osprofiler.notifier.create("Messaging", notifier.messaging, {}, notifier.get_transport(), "glance", "api", cfg.CONF.bind_host) osprofiler.notifier.set(_notifier) else: osprofiler.web.disable() server = wsgi.Server() server.start(config.load_paste_app('glance-api'), default_port=9292) systemd.notify_once() server.wait() except exception.WorkerCreationFailure as e: fail(2, e) except RuntimeError as e: fail(1, e)
def main(): """The main function.""" try: config.parse_args() except RuntimeError as e: sys.exit("ERROR: %s" % encodeutils.exception_to_unicode(e)) except SystemExit as e: sys.exit("Please specify one command") # Setup logging logging.setup(CONF, 'glance') if CONF.token: CONF.slavetoken = CONF.token CONF.mastertoken = CONF.token command = lookup_command(CONF.command) try: command(CONF, CONF.args) except TypeError as e: LOG.error(_LE(command.__doc__) % {'prog': command.__name__}) # noqa sys.exit("ERROR: %s" % encodeutils.exception_to_unicode(e)) except ValueError as e: LOG.error(_LE(command.__doc__) % {'prog': command.__name__}) # noqa sys.exit("ERROR: %s" % encodeutils.exception_to_unicode(e))
def main(): CONF.register_cli_opt( cfg.BoolOpt('daemon', short='D', default=False, help='Run as a long-running process. When not ' 'specified (the default) run the scrub operation ' 'once and then exits. When specified do not exit ' 'and run scrub on wakeup_time interval as ' 'specified in the config.')) CONF.register_opt(cfg.IntOpt('wakeup_time', default=300)) try: config.parse_args() log.setup('glance') glance.store.create_stores() glance.store.verify_default_store() app = scrubber.Scrubber(glance.store) if CONF.daemon: server = scrubber.Daemon(CONF.wakeup_time) server.start(app) server.wait() else: import eventlet pool = eventlet.greenpool.GreenPool(1000) app.run(pool) except RuntimeError as e: sys.exit("ERROR: %s" % e)
def main(): CONF.register_cli_opts(scrubber.scrubber_cmd_cli_opts) CONF.register_opts(scrubber.scrubber_cmd_opts) try: config.parse_args() log.setup('glance') glance_store.register_opts(config.CONF) glance_store.create_stores(config.CONF) glance_store.verify_default_store() app = scrubber.Scrubber(glance_store) if CONF.daemon: server = scrubber.Daemon(CONF.wakeup_time) server.start(app) systemd.notify_once() server.wait() else: import eventlet pool = eventlet.greenpool.GreenPool(1000) app.run(pool) except RuntimeError as e: sys.exit("ERROR: %s" % e)
def main(): try: config.parse_args() config.set_config_defaults() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') gmr.TextGuruMeditation.setup_autorun(version) notifier.set_defaults() if CONF.profiler.enabled: osprofiler.initializer.init_from_conf( conf=CONF, context={}, project="glance", service="api", host=CONF.bind_host ) # NOTE(danms): Configure system-wide threading model to use eventlet glance.async_.set_threadpool_model('eventlet') # NOTE(abhishekk): Added initialize_prefetcher KW argument to Server # object so that prefetcher object should only be initialized in case # of API service and ignored in case of registry. Once registry is # removed this parameter should be removed as well. initialize_prefetcher = False if CONF.paste_deploy.flavor == 'keystone+cachemanagement': initialize_prefetcher = True server = wsgi.Server(initialize_glance_store=True, initialize_prefetcher=initialize_prefetcher) server.start(config.load_paste_app('glance-api'), default_port=9292) server.wait() except Exception as e: fail(e)
def main(): CONF.register_cli_opts([ cfg.Opt('os-username'), cfg.Opt('os-password'), cfg.Opt('os-auth-url'), cfg.Opt('os-tenant-name'), ]) try: logging.register_options(CONF) cfg_files = cfg.find_config_files(project='glance', prog='glance-api') cfg_files.extend(cfg.find_config_files(project='glance', prog='glance-search')) config.parse_args(default_config_files=cfg_files) logging.setup(CONF, 'glance') namespace = 'glance.search.index_backend' ext_manager = stevedore.extension.ExtensionManager( namespace, invoke_on_load=True) for ext in ext_manager.extensions: try: ext.obj.setup() except Exception as e: LOG.error(_LE("Failed to setup index extension " "%(ext)s: %(e)s") % {'ext': ext.name, 'e': e}) except RuntimeError as e: sys.exit("ERROR: %s" % e)
def _do_test_load_paste_app( self, expected_app_type, make_paste_file=True, paste_flavor=None, paste_config_file=None, paste_append=None ): def _writeto(path, str): with open(path, "wb") as f: f.write(str or "") f.flush() def _appendto(orig, copy, str): shutil.copy(orig, copy) with open(copy, "ab") as f: f.write(str or "") f.flush() self.config(flavor=paste_flavor, config_file=paste_config_file, group="paste_deploy") temp_dir = self.useFixture(fixtures.TempDir()).path temp_file = os.path.join(temp_dir, "testcfg.conf") _writeto(temp_file, "[DEFAULT]\n") config.parse_args(["--config-file", temp_file]) paste_to = temp_file.replace(".conf", "-paste.ini") if not paste_config_file and make_paste_file: paste_from = os.path.join(os.getcwd(), "etc/glance-registry-paste.ini") _appendto(paste_from, paste_to, paste_append) app = config.load_paste_app("glance-registry") self.assertIsInstance(app, expected_app_type)
def main(): try: config.parse_args() config.set_config_defaults() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') notifier.set_defaults() # Shared data need to be initialized prior to fork() # so we need this before WSGI initialization in case it is # configured to use it cache_raw.initialize() if CONF.profiler.enabled: osprofiler.initializer.init_from_conf(conf=CONF, context={}, project="glance", service="api", host=CONF.bind_host) server = wsgi.Server(initialize_glance_store=True) server.start(config.load_paste_app('glance-api'), default_port=9292) # Start RAW caching p = cache_raw.start_raw_caching(server) server.wait(p) except KNOWN_EXCEPTIONS as e: fail(e)
def main(): try: config.parse_args(default_config_files='glance-sync.conf') log.setup('glance') server = wsgi.Server() server.start(config.load_paste_app('glance-sync'), default_port=9595) server.wait() except RuntimeError as e: sys.exit("ERROR: %s" % e)
def setUp(self): """Run before each test method to initialize test environment.""" super(TestMetadefDriver, self).setUp() config.parse_args(args=[]) context_cls = context.RequestContext self.adm_context = context_cls(is_admin=True, auth_tok='user:user:admin') self.context = context_cls(is_admin=False, auth_tok='user:user:user') self.db_api = db_tests.get_db(self.config) db_tests.reset_db(self.db_api)
def main(): try: config.parse_args() log.setup('glance') server = wsgi.Server() server.start(config.load_paste_app(), default_port=9191) server.wait() except RuntimeError as e: sys.exit("ERROR: %s" % e)
def setUp(self): super(BaseTestCase, self).setUp() #NOTE(bcwaldon): parse_args has to be called to register certain # command-line options - specifically we need config_dir for # the following policy tests config.parse_args(args=[]) self.addCleanup(CONF.reset) self.stubs = stubout.StubOutForTesting() self.stubs.Set(exception, '_FATAL_EXCEPTION_FORMAT_ERRORS', True)
def main(): # Used on Window, ensuring that a single scrubber can run at a time. mutex = None mutex_acquired = False try: if os.name == 'nt': # We can't rely on process names on Windows as there may be # wrappers with the same name. mutex = os_win_utilsfactory.get_mutex( name='Global\\glance-scrubber') mutex_acquired = mutex.acquire(timeout_ms=0) CONF.register_cli_opts(scrubber.scrubber_cmd_cli_opts) CONF.register_opts(scrubber.scrubber_cmd_opts) config.parse_args() logging.setup(CONF, 'glance') glance_store.register_opts(config.CONF) glance_store.create_stores(config.CONF) glance_store.verify_default_store() if CONF.restore and CONF.daemon: sys.exit("ERROR: The restore and daemon options should not be set " "together. Please use either of them in one request.") app = scrubber.Scrubber(glance_store) if CONF.restore: if os.name == 'nt': scrubber_already_running = not mutex_acquired else: scrubber_already_running = scrubber_already_running_posix() if scrubber_already_running: already_running_msg = ( "ERROR: glance-scrubber is already running. " "Please ensure that the daemon is stopped.") sys.exit(already_running_msg) app.revert_image_status(CONF.restore) elif CONF.daemon: server = scrubber.Daemon(CONF.wakeup_time) server.start(app) server.wait() else: app.run() except (exception.ImageNotFound, exception.Conflict) as e: sys.exit("ERROR: %s" % e) except RuntimeError as e: sys.exit("ERROR: %s" % e) finally: if mutex and mutex_acquired: mutex.release()
def setUp(self): """Run before each test method to initialize test environment.""" super(TestMetadefDriver, self).setUp() config.parse_args(args=[]) context_cls = context.RequestContext self.adm_context = context_cls(is_admin=True, auth_token='user:user:admin') self.context = context_cls(is_admin=False, auth_token='user:user:user') self.db_api = db_tests.get_db(self.config) db_tests.reset_db(self.db_api)
def main(): try: config.parse_args() log.setup('glance') server = wsgi.Server() server.start(config.load_paste_app('glance-registry'), default_port=9191) server.wait() except RuntimeError as e: sys.exit("ERROR: %s" % e)
def main(): try: config.parse_args(default_config_files='glance-sync.conf') log.setup('glance') server = wsgi.Server() server.start(config.load_paste_app('glance-sync'), default_port=9595) server.wait() except exception.WorkerCreationFailure as e: fail(2, e) except RuntimeError as e: fail(1, e)
def setUp(self): super(BaseTestCase, self).setUp() # NOTE(bcwaldon): parse_args has to be called to register certain # command-line options - specifically we need config_dir for # the following policy tests config.parse_args(args=[]) self.addCleanup(CONF.reset) self.stubs = stubout.StubOutForTesting() self.stubs.Set(exception, '_FATAL_EXCEPTION_FORMAT_ERRORS', True) self.test_dir = self.useFixture(fixtures.TempDir()).path self.conf_dir = os.path.join(self.test_dir, 'etc') utils.safe_mkdirs(self.conf_dir) self.set_policy()
def main(): try: config.parse_args() log.setup('glance') glance.store.create_stores() glance.store.verify_default_store() server = wsgi.Server() server.start(config.load_paste_app('glance-api'), default_port=9292) server.wait() except exception.WorkerCreationFailure as e: fail(2, e) except RuntimeError as e: fail(1, e)
def main(): try: config.parse_args() config.set_config_defaults() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') notifier.set_defaults() osprofiler.web.disable() server = wsgi.Server(initialize_glance_store=True) server.start(config.load_paste_app('glance-api'), default_port=9292) server.wait() except KNOWN_EXCEPTIONS as e: fail(e)
def main(): try: config.parse_args() log.setup('glance') glance.store.create_stores() glance.store.verify_default_store() server = wsgi.Server() server.start(config.load_paste_app(), default_port=9292) server.wait() except exception.WorkerCreationFailure as e: fail(2, e) except RuntimeError as e: fail(1, e)
def main(): CONF.register_cli_opt(command_opt) try: cfg_files = cfg.find_config_files(project='glance', prog='glance-registry') cfg_files.extend(cfg.find_config_files(project='glance', prog='glance-api')) config.parse_args(default_config_files=cfg_files, usage="%(prog)s [options] <cmd>") log.setup('glance') except RuntimeError as e: sys.exit("ERROR: %s" % e) try: CONF.command.action_fn() except exception.GlanceException as e: sys.exit("ERROR: %s" % e)
def main(): CONF.register_cli_opt(command_opt) if len(sys.argv) < 2: script_name = sys.argv[0] print("%s category action [<args>]" % script_name) print(_("Available categories:")) for category in CATEGORIES: print(_("\t%s") % category) sys.exit(2) try: logging.register_options(CONF) CONF.set_default(name='use_stderr', default=True, enforce_type=True) cfg_files = cfg.find_config_files(project='glance', prog='glance-registry') cfg_files.extend( cfg.find_config_files(project='glance', prog='glance-api')) cfg_files.extend( cfg.find_config_files(project='glance', prog='glance-manage')) config.parse_args(default_config_files=cfg_files) config.set_config_defaults() logging.setup(CONF, 'glance') except RuntimeError as e: sys.exit("ERROR: %s" % e) try: if CONF.command.action.startswith('db'): return CONF.command.action_fn() else: func_kwargs = {} for k in CONF.command.action_kwargs: v = getattr(CONF.command, 'action_kwarg_' + k) if v is None: continue if isinstance(v, six.string_types): v = encodeutils.safe_decode(v) func_kwargs[k] = v func_args = [ encodeutils.safe_decode(arg) for arg in CONF.command.action_args ] return CONF.command.action_fn(*func_args, **func_kwargs) except exception.GlanceException as e: sys.exit("ERROR: %s" % encodeutils.exception_to_unicode(e))
def main(): CONF.register_cli_opt(command_opt) if len(sys.argv) < 2: script_name = sys.argv[0] print("%s category action [<args>]" % script_name) print(_("Available categories:")) for category in CATEGORIES: print(_("\t%s") % category) sys.exit(2) try: logging.register_options(CONF) CONF.set_default(name='use_stderr', default=True, enforce_type=True) cfg_files = cfg.find_config_files(project='glance', prog='glance-registry') cfg_files.extend(cfg.find_config_files(project='glance', prog='glance-api')) cfg_files.extend(cfg.find_config_files(project='glance', prog='glance-manage')) config.parse_args(default_config_files=cfg_files) config.set_config_defaults() logging.setup(CONF, 'glance') except RuntimeError as e: sys.exit("ERROR: %s" % e) try: if CONF.command.action.startswith('db'): return CONF.command.action_fn() else: func_kwargs = {} for k in CONF.command.action_kwargs: v = getattr(CONF.command, 'action_kwarg_' + k) if v is None: continue if isinstance(v, six.string_types): v = encodeutils.safe_decode(v) func_kwargs[k] = v func_args = [encodeutils.safe_decode(arg) for arg in CONF.command.action_args] return CONF.command.action_fn(*func_args, **func_kwargs) except exception.GlanceException as e: sys.exit("ERROR: %s" % encodeutils.exception_to_unicode(e))
def main(): try: config.parse_args() config.set_config_defaults() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') gmr.TextGuruMeditation.setup_autorun(version) notifier.set_defaults() if CONF.profiler.enabled: osprofiler.initializer.init_from_conf( conf=CONF, context={}, project="glance", service="api", host=CONF.bind_host ) if CONF.enforce_secure_rbac != CONF.oslo_policy.enforce_new_defaults: fail_message = ( "[DEFAULT] enforce_secure_rbac does not match " "[oslo_policy] enforce_new_defaults. Please set both to " "True to enable secure RBAC personas. Otherwise, make sure " "both are False.") raise exception.ServerError(fail_message) # NOTE(danms): Configure system-wide threading model to use eventlet glance.async_.set_threadpool_model('eventlet') # NOTE(abhishekk): Added initialize_prefetcher KW argument to Server # object so that prefetcher object should only be initialized in case # of API service and ignored in case of registry. Once registry is # removed this parameter should be removed as well. initialize_prefetcher = False if CONF.paste_deploy.flavor == 'keystone+cachemanagement': initialize_prefetcher = True server = wsgi.Server(initialize_glance_store=True, initialize_prefetcher=initialize_prefetcher) server.start(config.load_paste_app('glance-api'), default_port=9292) server.wait() except Exception as e: fail(e)
def main(): try: config.parse_args() wsgi.set_eventlet_hub() log.setup("glance") if cfg.CONF.profiler.enabled: _notifier = osprofiler.notifier.create( "Messaging", notifier.messaging, {}, notifier.get_transport(), "glance", "registry", cfg.CONF.bind_host ) osprofiler.notifier.set(_notifier) else: osprofiler.web.disable() server = wsgi.Server() server.start(config.load_paste_app("glance-registry"), default_port=9191) server.wait() except RuntimeError as e: sys.exit("ERROR: %s" % utils.exception_to_str(e))
def main(): try: config.parse_args() config.set_config_defaults() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') notifier.set_defaults() if CONF.profiler.enabled: osprofiler.initializer.init_from_conf(conf=CONF, context={}, project="glance", service="api", host=CONF.bind_host) server = wsgi.Server(initialize_glance_store=True) server.start(config.load_paste_app('glance-api'), default_port=9292) server.wait() except KNOWN_EXCEPTIONS as e: fail(e)
def setUp(self): super(BaseTestCase, self).setUp() self._config_fixture = self.useFixture(cfg_fixture.Config()) # NOTE(bcwaldon): parse_args has to be called to register certain # command-line options - specifically we need config_dir for # the following policy tests config.parse_args(args=[]) self.addCleanup(CONF.reset) mox_fixture = self.useFixture(moxstubout.MoxStubout()) self.stubs = mox_fixture.stubs self.stubs.Set(exception, '_FATAL_EXCEPTION_FORMAT_ERRORS', True) self.test_dir = self.useFixture(fixtures.TempDir()).path self.conf_dir = os.path.join(self.test_dir, 'etc') utils.safe_mkdirs(self.conf_dir) self.set_policy() # Limit the amount of DeprecationWarning messages in the unit test logs self.useFixture(glance_fixtures.WarningsFixture())
def main(): try: config.parse_args() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') if cfg.CONF.profiler.enabled: _notifier = osprofiler.notifier.create("Messaging", notifier.messaging, {}, notifier.get_transport(), "glance", "api", cfg.CONF.bind_host) osprofiler.notifier.set(_notifier) else: osprofiler.web.disable() server = wsgi.Server(initialize_glance_store=True) server.start(config.load_paste_app('glance-api'), default_port=9292) server.wait() except KNOWN_EXCEPTIONS as e: fail(e)
def main(): try: config.parse_args() wsgi.set_eventlet_hub() logging.setup(CONF, 'glare') if cfg.CONF.profiler.enabled: _notifier = osprofiler.notifier.create("Messaging", oslo_messaging, {}, notifier.get_transport(), "glance", "artifacts", cfg.CONF.bind_host) osprofiler.notifier.set(_notifier) else: osprofiler.web.disable() server = wsgi.Server(initialize_glance_store=True) server.start(config.load_paste_app('glare-api'), default_port=9494) server.wait() except KNOWN_EXCEPTIONS as e: fail(e)
def main(): CONF.register_cli_opt(command_opt) try: # We load the glance-registry config section because # sql_connection is only part of the glance registry. glance.db.sqlalchemy.api.add_cli_options() cfg_files = cfg.find_config_files(project='glance', prog='glance-registry') cfg_files.extend( cfg.find_config_files(project='glance', prog='glance-api')) config.parse_args(default_config_files=cfg_files, usage="%(prog)s [options] <cmd>") log.setup('glance') except RuntimeError as e: sys.exit("ERROR: %s" % e) try: CONF.command.func() except exception.GlanceException as e: sys.exit("ERROR: %s" % e)
def main(): try: config.parse_args() config.set_config_defaults() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') notifier.set_defaults() if CONF.profiler.enabled: osprofiler.initializer.init_from_conf(conf=CONF, context={}, project="glance", service="registry", host=CONF.bind_host) server = wsgi.Server() server.start(config.load_paste_app('glance-registry'), default_port=9191) server.wait() except RuntimeError as e: sys.exit("ERROR: %s" % encodeutils.exception_to_unicode(e))
def main(): try: config.parse_args() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') #if cfg.CONF.profiler.enabled: # _notifier = osprofiler.notifier.create("Messaging", # oslo_messaging, {}, # notifier.get_transport(), # "glance", "api", # cfg.CONF.bind_host) # osprofiler.notifier.set(_notifier) #else: # osprofiler.web.disable() server = wsgi.Server(initialize_glance_store=True) server.start(config.load_paste_app('pdl'), default_port=9292) server.wait() except KNOWN_EXCEPTIONS as e: fail(e)
def main(): CONF.register_cli_opt(command_opt) try: # We load the glance-registry config section because # sql_connection is only part of the glance registry. glance.db.sqlalchemy.api.add_cli_options() cfg_files = cfg.find_config_files(project='glance', prog='glance-registry') cfg_files.extend(cfg.find_config_files(project='glance', prog='glance-api')) config.parse_args(default_config_files=cfg_files, usage="%(prog)s [options] <cmd>") log.setup('glance') except RuntimeError as e: sys.exit("ERROR: %s" % e) try: CONF.command.func() except exception.GlanceException as e: sys.exit("ERROR: %s" % e)
def _do_test_load_paste_app(self, expected_app_type, make_paste_file=True, paste_flavor=None, paste_config_file=None, paste_append=None): def _writeto(path, str): with open(path, 'wb') as f: f.write(str or '') f.flush() def _appendto(orig, copy, str): shutil.copy(orig, copy) with open(copy, 'ab') as f: f.write(str or '') f.flush() self.config(flavor=paste_flavor, config_file=paste_config_file, group='paste_deploy') temp_file = os.path.join(tempfile.mkdtemp(), 'testcfg.conf') try: _writeto(temp_file, '[DEFAULT]\n') config.parse_args(['--config-file', temp_file]) paste_to = temp_file.replace('.conf', '-paste.ini') if not paste_config_file and make_paste_file: paste_from = os.path.join(os.getcwd(), 'etc/glance-registry-paste.ini') _appendto(paste_from, paste_to, paste_append) app = config.load_paste_app('glance-registry') self.assertEquals(expected_app_type, type(app)) finally: shutil.rmtree(os.path.dirname(temp_file))
def main(): try: config.parse_args() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') if cfg.CONF.profiler.enabled: _notifier = osprofiler.notifier.create("Messaging", notifier.messaging, {}, notifier.get_transport(), "glance", "search", cfg.CONF.bind_host) osprofiler.notifier.set(_notifier) else: osprofiler.web.disable() server = wsgi.Server() server.start(config.load_paste_app('glance-search'), default_port=9393) server.wait() except KNOWN_EXCEPTIONS as e: fail(e)
def main(): CONF.register_cli_opts(scrubber.scrubber_cmd_cli_opts) CONF.register_opts(scrubber.scrubber_cmd_opts) try: config.parse_args() logging.setup(CONF, 'glance') glance_store.register_opts(config.CONF) glance_store.create_stores(config.CONF) glance_store.verify_default_store() app = scrubber.Scrubber(glance_store) if CONF.daemon: server = scrubber.Daemon(CONF.wakeup_time) server.start(app) server.wait() else: app.run() except RuntimeError as e: sys.exit("ERROR: %s" % e)
def main(): try: config.parse_args() config.set_config_defaults() wsgi.set_eventlet_hub() logging.setup(CONF, 'glance') notifier.set_defaults() if CONF.profiler.enabled: osprofiler.initializer.init_from_conf( conf=CONF, context={}, project="glance", service="api", host=CONF.bind_host ) server = wsgi.Server(initialize_glance_store=True) server.start(config.load_paste_app('glance-api'), default_port=9292) server.wait() except Exception as e: fail(e)
def main(): CONF.register_cli_opts(scrubber.scrubber_cmd_cli_opts) CONF.register_opts(scrubber.scrubber_cmd_opts) try: config.parse_args() logging.setup(CONF, "glance") glance_store.register_opts(config.CONF) glance_store.create_stores(config.CONF) glance_store.verify_default_store() app = scrubber.Scrubber(glance_store) if CONF.daemon: server = scrubber.Daemon(CONF.wakeup_time) server.start(app) server.wait() else: app.run() except RuntimeError as e: sys.exit("ERROR: %s" % e)
def setUp(self): super(BaseTestCase, self).setUp() self._config_fixture = self.useFixture(cfg_fixture.Config()) # NOTE(bcwaldon): parse_args has to be called to register certain # command-line options - specifically we need config_dir for # the following policy tests config.parse_args(args=[]) self.addCleanup(CONF.reset) self.mock_object(exception, '_FATAL_EXCEPTION_FORMAT_ERRORS', True) self.test_dir = self.useFixture(fixtures.TempDir()).path self.conf_dir = os.path.join(self.test_dir, 'etc') utils.safe_mkdirs(self.conf_dir) self.set_policy() # Limit the amount of DeprecationWarning messages in the unit test logs self.useFixture(glance_fixtures.WarningsFixture()) # Make sure logging output is limited but still test debug formatting self.useFixture(log_fixture.get_logging_handle_error_fixture()) self.useFixture(glance_fixtures.StandardLogging())
def _do_test_load_paste_app(self, expected_app_type, make_paste_file=True, paste_flavor=None, paste_config_file=None, paste_append=None): def _writeto(path, str): with open(path, 'w') as f: f.write(str or '') f.flush() def _appendto(orig, copy, str): shutil.copy(orig, copy) with open(copy, 'a') as f: f.write(str or '') f.flush() self.config(flavor=paste_flavor, config_file=paste_config_file, group='paste_deploy') temp_dir = self.useFixture(fixtures.TempDir()).path temp_file = os.path.join(temp_dir, 'testcfg.conf') _writeto(temp_file, '[DEFAULT]\n') config.parse_args(['--config-file', temp_file]) paste_to = temp_file.replace('.conf', '-paste.ini') if not paste_config_file and make_paste_file: paste_from = os.path.join(os.getcwd(), 'etc/glance-registry-paste.ini') _appendto(paste_from, paste_to, paste_append) app = config.load_paste_app('glance-registry') self.assertIsInstance(app, expected_app_type)
def _do_test_load_paste_app(self, expected_app_type, make_paste_file=True, paste_flavor=None, paste_config_file=None, paste_append=None): def _writeto(path, str): with open(path, 'wb') as f: f.write(str or '') f.flush() def _appendto(orig, copy, str): shutil.copy(orig, copy) with open(copy, 'ab') as f: f.write(str or '') f.flush() self.config(flavor=paste_flavor, config_file=paste_config_file, group='paste_deploy') temp_dir = self.useFixture(fixtures.TempDir()).path temp_file = os.path.join(temp_dir, 'testcfg.conf') _writeto(temp_file, '[DEFAULT]\n') config.parse_args(['--config-file', temp_file]) paste_to = temp_file.replace('.conf', '-paste.ini') if not paste_config_file and make_paste_file: paste_from = os.path.join(os.getcwd(), 'etc/glance-registry-paste.ini') _appendto(paste_from, paste_to, paste_append) app = config.load_paste_app('glance-registry') self.assertIsInstance(app, expected_app_type)
def main(): try: config.parse_args() wsgi.set_eventlet_hub() log.setup('glance') if cfg.CONF.profiler.enabled: _notifier = osprofiler.notifier.create("Messaging", notifier.messaging, {}, notifier.get_transport(), "glance", "registry", cfg.CONF.bind_host) osprofiler.notifier.set(_notifier) else: osprofiler.web.disable() server = wsgi.Server() server.start(config.load_paste_app('glance-registry'), default_port=9191) server.wait() except RuntimeError as e: sys.exit("ERROR: %s" % e)
def _routes_of_glance_api(self): import routes from glance.common import config config.parse_args() from glance.api.v1.router import API as API_V1 from glance.api.v2.router import API as API_V2 from glance.registry.api.v1 import API as API_REG v1_mapper = routes.Mapper() v1 = API_V1(v1_mapper) router = self._extract_api_info(v1_mapper.matchlist) v2_mapper = routes.Mapper() v2 = API_V2(v2_mapper) router.extend(self._extract_api_info(v2_mapper.matchlist)) self.mappers['glance-api'] = [v1_mapper, v2_mapper] self.routes['glance-api'] = router registry = API_REG(None) router = self._extract_api_info(registry.map.matchlist) self.mappers['glance-registry'] = [registry.map] self.routes['glance-registry'] = router