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() 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 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 main(): try: config.parse_cache_args() logging.setup(CONF, 'glance') glance_store.register_opts(config.CONF) glance_store.create_stores(config.CONF) glance_store.verify_default_store() app = prefetcher.Prefetcher() app.run() except RuntimeError as e: sys.exit("ERROR: %s" % e)
def init_app(): config_files = _get_config_files() CONF([], project='glance', default_config_files=config_files) logging.setup(CONF, "glance") if CONF.enabled_backends: glance_store.register_store_opts(CONF) glance_store.create_multi_stores(CONF) glance_store.verify_store() else: glance_store.register_opts(CONF) glance_store.create_stores(CONF) glance_store.verify_default_store() _setup_os_profiler() return config.load_paste_app('glance-api')
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(): 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.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: import eventlet pool = eventlet.greenpool.GreenPool(1000) app.run(pool) except RuntimeError as e: sys.exit("ERROR: %s" % e)
def initialize_glance_store(): """Initialize glance store.""" glance_store.register_opts(CONF) glance_store.create_stores(CONF) glance_store.verify_default_store()
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') CONF.import_opt('enabled_backends', 'glance.common.wsgi') if CONF.enabled_backends: glance_store.register_store_opts(CONF) glance_store.create_multi_stores(CONF) glance_store.verify_store() else: glance_store.register_opts(CONF) glance_store.create_stores(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()