Example #1
0
 def test_wsgi_middleware_disable_via_python(self, mock_profiler_init):
     request = mock.MagicMock()
     request.get_response.return_value = "yeah!"
     web.disable()
     middleware = web.WsgiMiddleware("app", "hmac_key", enabled=True)
     self.assertEqual("yeah!", middleware(request))
     self.assertEqual(mock_profiler_init.call_count, 0)
Example #2
0
 def test_wsgi_middleware_disable_via_python(self, mock_profiler_init):
     request = mock.MagicMock()
     request.get_response.return_value = "yeah!"
     web.disable()
     middleware = web.WsgiMiddleware("app", "hmac_key", enabled=True)
     self.assertEqual("yeah!", middleware(request))
     self.assertEqual(mock_profiler_init.call_count, 0)
Example #3
0
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()
Example #4
0
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()
Example #5
0
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()
Example #6
0
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()
Example #7
0
 def test_enabled(self):
     web.disable()
     web.enable()
     self.assertTrue(web._ENABLED)
Example #8
0
 def test_disable(self):
     web.disable()
     self.assertFalse(web._ENABLED)
Example #9
0
def disable_web_trace(conf=None):
    if conf is None:
        conf = cfg.CONF
    if conf.profiler.enabled:
        web.disable()
Example #10
0
def disable_web_trace(conf=None):
    if conf is None:
        conf = cfg.CONF
    if conf.profiler.enabled:
        web.disable()
Example #11
0
 def test_enabled(self):
     web.disable()
     web.enable()
     self.assertTrue(web._ENABLED)
Example #12
0
 def test_disable(self):
     web.disable()
     self.assertFalse(web._ENABLED)
Example #13
0
 def test_enabled(self):
     web.disable()
     web.enable()
     self.assertFalse(web._DISABLED)
Example #14
0
 def test_disable(self):
     web.disable()
     self.assertTrue(web._DISABLED)