def notify(_context, message): """Notifies the recipient of the desired event given the model. Log notifications using openstack's default logging system""" priority = message.get("priority", CONF.default_notification_level) priority = priority.lower() logger = logging.getLogger("glance.openstack.common.notification.%s" % message["event_type"]) getattr(logger, priority)(jsonutils.dumps(message))
def start(self, application, default_port): """ Run a WSGI server with the given application. :param application: The application to be run in the WSGI server :param default_port: Port to bind to if none is specified in conf """ pgid = os.getpid() try: # NOTE(flaper87): Make sure this process # runs in its own process group. os.setpgid(pgid, pgid) except OSError: # NOTE(flaper87): When running glance-control, # (glance's functional tests, for example) # setpgid fails with EPERM as glance-control # creates a fresh session, of which the newly # launched service becomes the leader (session # leaders may not change process groups) # # Running glance-(api|registry) is safe and # shouldn't raise any error here. pgid = 0 def kill_children(*args): """Kills the entire process group.""" signal.signal(signal.SIGTERM, signal.SIG_IGN) signal.signal(signal.SIGINT, signal.SIG_IGN) self.running = False os.killpg(pgid, signal.SIGTERM) def hup(*args): """ Shuts down the server, but allows running requests to complete """ signal.signal(signal.SIGHUP, signal.SIG_IGN) self.running = False self.application = application self.sock = get_socket(default_port) os.umask(0o27) # ensure files are created with the correct privileges self._logger = logging.getLogger("eventlet.wsgi.server") self._wsgi_logger = logging.WritableLogger(self._logger) if CONF.workers == 0: # Useful for profiling, test, debug etc. self.pool = self.create_pool() self.pool.spawn_n(self._single_run, self.application, self.sock) return else: LOG.info(_LI("Starting %d workers") % CONF.workers) signal.signal(signal.SIGTERM, kill_children) signal.signal(signal.SIGINT, kill_children) signal.signal(signal.SIGHUP, hup) while len(self.children) < CONF.workers: self.run_child()
def start(self, application, default_port): """ Run a WSGI server with the given application. :param application: A function that can be called with no arguments that will return the application to run in the WSGI server :param default_port: Port to bind to if none is specified in conf """ def kill_children(*args): """Kills the entire process group.""" self.logger.info(_("SIGTERM or SIGINT received")) signal.signal(signal.SIGTERM, signal.SIG_IGN) signal.signal(signal.SIGINT, signal.SIG_IGN) self.running = False os.killpg(0, signal.SIGTERM) def hup(*args): """ Shuts down the server, but allows running requests to complete """ self.logger.info(_("SIGHUP received")) signal.signal(signal.SIGHUP, signal.SIG_IGN) self.running = False self.app_func = application self.sock = get_socket(default_port) os.umask(027) # ensure files are created with the correct privileges self.logger = os_logging.getLogger("eventlet.wsgi.server") if CONF.workers == 0: # Useful for profiling, test, debug etc. self.pool = self.create_pool() self.pool.spawn_n(self._single_run, self.app_func(), self.sock) return else: self.logger.info(_("Starting %d workers") % CONF.workers) signal.signal(signal.SIGTERM, kill_children) signal.signal(signal.SIGINT, kill_children) signal.signal(signal.SIGHUP, hup) while len(self.children) < CONF.workers: self.run_child()
def start(self, application, default_port): """ Run a WSGI server with the given application. :param application: The application to run in the WSGI server :param default_port: Port to bind to if none is specified in conf """ def kill_children(*args): """Kills the entire process group.""" self.logger.error(_('SIGTERM or SIGINT received')) signal.signal(signal.SIGTERM, signal.SIG_IGN) signal.signal(signal.SIGINT, signal.SIG_IGN) self.running = False os.killpg(0, signal.SIGTERM) def hup(*args): """ Shuts down the server, but allows running requests to complete """ self.logger.error(_('SIGHUP received')) signal.signal(signal.SIGHUP, signal.SIG_IGN) self.running = False self.application = application self.sock = get_socket(default_port) self.logger = os_logging.getLogger('eventlet.wsgi.server') if CONF.workers == 0: # Useful for profiling, test, debug etc. self.pool = eventlet.GreenPool(size=self.threads) self.pool.spawn_n(self._single_run, application, self.sock) return self.logger.info(_("Starting %d workers") % CONF.workers) signal.signal(signal.SIGTERM, kill_children) signal.signal(signal.SIGINT, kill_children) signal.signal(signal.SIGHUP, hup) while len(self.children) < CONF.workers: self.run_child()
import stevedore import glance.openstack.common.log as logging location_strategy_opts = [ cfg.StrOpt('location_strategy', default='location_order', help=_("This value sets what strategy will be used to " "determine the image location order. Currently " "two strategies are packaged with Glance " "'location_order' and 'store_type'.")) ] CONF = cfg.CONF CONF.register_opts(location_strategy_opts) LOG = logging.getLogger(__name__) def _load_strategies(): """Load all strategy modules.""" modules = {} namespace = "glance.common.image_location_strategy.modules" ex = stevedore.extension.ExtensionManager(namespace) for module_name in ex.names(): try: mgr = stevedore.driver.DriverManager( namespace=namespace, name=module_name, invoke_on_load=False) # Obtain module name
import six from six.moves import xrange import sqlalchemy import sqlalchemy.orm as sa_orm import sqlalchemy.sql as sa_sql from glance.common import exception from glance.db.sqlalchemy import models from glance import i18n import glance.openstack.common.log as os_logging from glance.openstack.common import timeutils BASE = models.BASE sa_logger = None LOG = os_logging.getLogger(__name__) _LI = i18n._LI _LW = i18n._LW STATUSES = ['active', 'saving', 'queued', 'killed', 'pending_delete', 'deleted'] CONF = cfg.CONF CONF.import_opt('debug', 'glance.openstack.common.log') CONF.import_group("profiler", "glance.common.wsgi") _FACADE = None _LOCK = threading.Lock()
# under the License. """ Registry's Client V2 """ import os from oslo.config import cfg from glance.common import exception from glance import i18n import glance.openstack.common.log as logging from glance.registry.client.v2 import client LOG = logging.getLogger(__name__) _ = i18n._ CONF = cfg.CONF _registry_client = 'glance.registry.client' CONF.import_opt('registry_client_protocol', _registry_client) CONF.import_opt('registry_client_key_file', _registry_client) CONF.import_opt('registry_client_cert_file', _registry_client) CONF.import_opt('registry_client_ca_file', _registry_client) CONF.import_opt('registry_client_insecure', _registry_client) CONF.import_opt('registry_client_timeout', _registry_client) CONF.import_opt('use_user_token', _registry_client) CONF.import_opt('admin_user', _registry_client) CONF.import_opt('admin_password', _registry_client) CONF.import_opt('admin_tenant_name', _registry_client) CONF.import_opt('auth_url', _registry_client)
import sqlalchemy.sql as sa_sql from glance.common import exception from glance.db.sqlalchemy import migration from glance.db.sqlalchemy import models from glance.openstack.common import cfg import glance.openstack.common.log as os_logging from glance.openstack.common import timeutils _ENGINE = None _MAKER = None _MAX_RETRIES = None _RETRY_INTERVAL = None BASE = models.BASE sa_logger = None LOG = os_logging.getLogger(__name__) STATUSES = [ 'active', 'saving', 'queued', 'killed', 'pending_delete', 'deleted' ] db_opts = [ cfg.IntOpt('sql_idle_timeout', default=3600), cfg.IntOpt('sql_max_retries', default=10), cfg.IntOpt('sql_retry_interval', default=1), cfg.BoolOpt('db_auto_create', default=False), ] CONF = cfg.CONF CONF.register_opts(db_opts)
def setUp(self): super(TestLoggingNotifier, self).setUp() self.config(notifier_strategy="logging") self.called = False self.logger = logging.getLogger("glance.notifier.notify_log") self.notifier = notifier.Notifier()
def __init__(self): self.logger = logging.getLogger(__name__)