def test_set(self): def test(info): pass notifier.set(test) self.assertEqual(notifier.get(), test)
def init_from_conf(conf, context, project, service, host): """Initialize notifier from service configuration :param conf: service configuration :param context: request context :param project: project name (keystone, cinder etc.) :param service: service name that will be profiled :param host: hostname or host IP address that the service will be running on. """ connection_str = conf.profiler.connection_string kwargs = {} if connection_str.startswith("messaging"): kwargs = { "messaging": oslo_messaging, "transport": oslo_messaging.get_transport(conf) } _notifier = notifier.create(connection_str, context=context, project=project, service=service, host=host, conf=conf, **kwargs) notifier.set(_notifier) web.enable(conf.profiler.hmac_keys)
def setup_profiler(binary, host): if CONF.profiler.enabled: _notifier = notifier.create( "Messaging", messaging, context.get_admin_context().to_dict(), rpc.TRANSPORT, "trove", binary, host) notifier.set(_notifier) LOG.warn(_LW("The OpenStack Profiler is enabled. Using one of the " "hmac_keys specified in the api-paste.ini file " "(typically in /etc/trove), a trace can be made of all " "requests. Only an admin user can retrieve the trace " "information, however.\n" "To disable the profiler, add the following to the " "configuration file:\n" "[profiler]\n" "enabled=false")) else: web.disable()
def setup_profiler(binary, host): if CONF.profiler.enabled: _notifier = notifier.create("Messaging", messaging, context.get_admin_context().to_dict(), rpc.TRANSPORT, "trove", binary, host) notifier.set(_notifier) LOG.warn( _LW("The OpenStack Profiler is enabled. Using one of the " "hmac_keys specified in the api-paste.ini file " "(typically in /etc/trove), a trace can be made of all " "requests. Only an admin user can retrieve the trace " "information, however.\n" "To disable the profiler, add the following to the " "configuration file:\n" "[profiler]\n" "enabled=false")) else: web.disable()
def init_from_conf(conf, context, project, service, host): """Initialize notifier from service configuration :param conf: service configuration :param context: request context :param project: project name (keystone, cinder etc.) :param service: service name that will be profiled :param host: hostname or host IP address that the service will be running on. """ connection_str = conf.profiler.connection_string _notifier = notifier.create(connection_str, context=context, project=project, service=service, host=host, conf=conf) notifier.set(_notifier) web.enable(conf.profiler.hmac_keys)
def setup(conf, binary, host): if conf.profiler.enabled: # Note(wangxiyuan): OSprofiler now support some kind of backends, such # as Ceilometer, ElasticSearch, Messaging and MongoDB. # 1. Ceilometer is only used for data collection, and Messaging is only # used for data transfer. So Ceilometer only works when Messaging is # enabled. # 2. ElasticSearch and MongoDB support both data collection and # transfer. So they can be used standalone. # 3. Choose which backend depends on the config option # "connection_string" , and the default value is "messaging://". backend_uri = conf.profiler.connection_string if "://" not in backend_uri: backend_uri += "://" parsed_connection = urlparse.urlparse(backend_uri) backend_type = parsed_connection.scheme if backend_type == "messaging": import oslo_messaging _notifier = notifier.create( backend_uri, oslo_messaging, {}, oslo_messaging.get_notification_transport(conf), "Zaqar", binary, host) else: _notifier = notifier.create(backend_uri, project="Zaqar", service=binary, host=host) notifier.set(_notifier) LOG.warning("OSProfiler is enabled.\nIt means that person who " "knows any of hmac_keys that are specified in " "/etc/zaqar/zaqar.conf can trace his requests. \n In " "real life only operator can read this file so there " "is no security issue. Note that even if person can " "trigger profiler, only admin user can retrieve trace " "information.\n" "To disable OSprofiler set in zaqar.conf:\n" "[profiler]\nenabled=false") web.enable(conf.profiler.hmac_keys) else: web.disable()
def init_from_conf(conf, context, project, service, host): """Initialize notifier from service configuration :param conf: service configuration :param context: request context :param project: project name (keystone, cinder etc.) :param service: service name that will be profiled :param host: hostname or host IP address that the service will be running on. """ connection_str = conf.profiler.connection_string _notifier = notifier.create( connection_str, messaging=oslo_messaging, context=context, transport=oslo_messaging.get_transport(conf), project=project, service=service, host=host) notifier.set(_notifier) web.enable(conf.profiler.hmac_keys)
def init_notifier(connection_str, host="localhost"): _notifier = notifier.create(connection_str, project='horizon', service='horizon', host=host) notifier.set(_notifier)
def init_notifier(connection_str, host="localhost"): _notifier = notifier.create( connection_str, project='horizon', service='horizon', host=host) notifier.set(_notifier)
def test_notify(self): m = mock.MagicMock() notifier.set(m) notifier.notify(10) m.assert_called_once_with(10)
def tearDown(self): notifier.set(notifier._noop_notifier) # restore defaults notifier.clear_notifier_cache() super(NotifierTestCase, self).tearDown()
def tearDown(self): notifier.set(notifier._noop_notifier) # restore defaults super(NotifierTestCase, self).tearDown()