Ejemplo n.º 1
0
 def _init_profiler(self, context):
     """Inits the profiler."""
     if not CONF.openstack.enable_profiler:
         return
     if context is not None:
         cred = None
         profiler_hmac_key = None
         profiler_conn_str = None
         if context.get("admin"):
             cred = context["admin"]["credential"]
             if cred.profiler_hmac_key is not None:
                 profiler_hmac_key = cred.profiler_hmac_key
                 profiler_conn_str = cred.profiler_conn_str
         if context.get("user"):
             cred = context["user"]["credential"]
             if cred.profiler_hmac_key is not None:
                 profiler_hmac_key = cred.profiler_hmac_key
                 profiler_conn_str = cred.profiler_conn_str
         if profiler_hmac_key is None:
             return
         profiler.init(profiler_hmac_key)
         trace_id = profiler.get().get_base_id()
         complete_data = {"title": "OSProfiler Trace-ID",
                          "chart_plugin": "OSProfiler",
                          "data": {"trace_id": [trace_id],
                                   "conn_str": profiler_conn_str}}
         self.add_output(complete=complete_data)
Ejemplo n.º 2
0
    def _init_profiler(self, context):
        """Inits the profiler."""
        if not CONF.openstack.enable_profiler:
            return

        if context is not None:

            profiler_hmac_key = None
            profiler_conn_str = None
            if context.get("admin"):
                cred = context["admin"]["credential"]
                if cred.profiler_hmac_key is not None:
                    profiler_hmac_key = cred.profiler_hmac_key
                    profiler_conn_str = cred.profiler_conn_str
            if context.get("user"):
                cred = context["user"]["credential"]
                if cred.profiler_hmac_key is not None:
                    profiler_hmac_key = cred.profiler_hmac_key
                    profiler_conn_str = cred.profiler_conn_str
            if profiler_hmac_key is None:
                return
            profiler.init(profiler_hmac_key)
            trace_id = profiler.get().get_base_id()
            complete_data = {
                "title": "OSProfiler Trace-ID",
                "chart_plugin": "OSProfiler",
                "data": {
                    "trace_id": [trace_id],
                    "conn_str": profiler_conn_str
                }
            }
            self.add_output(complete=complete_data)
Ejemplo n.º 3
0
    def __init__(self, context=None, admin_clients=None, clients=None):
        super(OpenStackScenario, self).__init__(context)
        if context:
            api_info = {}
            if "api_versions@openstack" in context.get("config", {}):
                api_versions = context["config"]["api_versions@openstack"]
                for service in api_versions:
                    api_info[service] = {
                        "version": api_versions[service].get("version"),
                        "service_type": api_versions[service].get(
                            "service_type")}

            if admin_clients is None and "admin" in context:
                self._admin_clients = osclients.Clients(
                    context["admin"]["credential"], api_info)
            if clients is None:
                if "users" in context and "user" not in context:
                    self._choose_user(context)

                if "user" in context:
                    self._clients = osclients.Clients(
                        context["user"]["credential"], api_info)

        if admin_clients:
            self._admin_clients = admin_clients

        if clients:
            self._clients = clients

        self._init_profiler(context)
Ejemplo n.º 4
0
    def __init__(self, context=None, admin_clients=None, clients=None):
        super(OpenStackScenario, self).__init__(context)
        if context:
            api_info = {}
            if "api_versions@openstack" in context.get("config", {}):
                api_versions = context["config"]["api_versions@openstack"]
                for service in api_versions:
                    api_info[service] = {
                        "version": api_versions[service].get("version"),
                        "service_type":
                        api_versions[service].get("service_type")
                    }

            if admin_clients is None and "admin" in context:
                self._admin_clients = osclients.Clients(
                    context["admin"]["credential"], api_info)
            if clients is None:
                if "users" in context and "user" not in context:
                    self._choose_user(context)

                if "user" in context:
                    self._clients = osclients.Clients(
                        context["user"]["credential"], api_info)

        if admin_clients:
            self._admin_clients = admin_clients

        if clients:
            self._clients = clients

        self._init_profiler(context)
Ejemplo n.º 5
0
 def _init_profiler(self, context):
     """Inits the profiler."""
     if not CONF.benchmark.enable_profiler:
         return
     if context is not None:
         cred = None
         profiler_hmac_key = None
         if context.get("admin"):
             cred = context["admin"]["credential"]
             if cred.profiler_hmac_key is not None:
                 profiler_hmac_key = cred.profiler_hmac_key
         if context.get("user"):
             cred = context["user"]["credential"]
             if cred.profiler_hmac_key is not None:
                 profiler_hmac_key = cred.profiler_hmac_key
         if profiler_hmac_key is None:
             return
         profiler.init(profiler_hmac_key)
         trace_id = profiler.get().get_base_id()
         self.add_output(complete={
             "title": "OSProfiler Trace-ID",
             "chart_plugin": "TextArea",
             "data": [trace_id]})
Ejemplo n.º 6
0
    def _init_profiler(self, context):
        """Inits the profiler."""
        if not CONF.openstack.enable_profiler:
            return

        # False statement here means that Scenario class is used outside the
        # runner as some kind of utils
        if context is not None and "iteration" in context:

            profiler_hmac_key = None
            profiler_conn_str = None
            if context.get("admin"):
                cred = context["admin"]["credential"]
                if cred.profiler_hmac_key is not None:
                    profiler_hmac_key = cred.profiler_hmac_key
                    profiler_conn_str = cred.profiler_conn_str
            if context.get("user"):
                cred = context["user"]["credential"]
                if cred.profiler_hmac_key is not None:
                    profiler_hmac_key = cred.profiler_hmac_key
                    profiler_conn_str = cred.profiler_conn_str
            if profiler_hmac_key is None:
                return
            profiler.init(profiler_hmac_key)
            trace_id = profiler.get().get_base_id()
            complete_data = {
                "title": "OSProfiler Trace-ID",
                "chart_plugin": "OSProfiler",
                "data": {
                    "trace_id": trace_id,
                    "conn_str": profiler_conn_str,
                    "taskID": context["task"]["uuid"],
                    "workload_uuid": context["owner_id"],
                    "iteration": context["iteration"]
                }
            }
            self.add_output(complete=complete_data)
Ejemplo n.º 7
0
 def _init_profiler(self, context):
     """Inits the profiler."""
     if not CONF.openstack.enable_profiler:
         return
     if context is not None:
         cred = None
         profiler_hmac_key = None
         profiler_conn_str = None
         if context.get("admin"):
             cred = context["admin"]["credential"]
             if cred.profiler_hmac_key is not None:
                 profiler_hmac_key = cred.profiler_hmac_key
                 profiler_conn_str = cred.profiler_conn_str
         if context.get("user"):
             cred = context["user"]["credential"]
             if cred.profiler_hmac_key is not None:
                 profiler_hmac_key = cred.profiler_hmac_key
                 profiler_conn_str = cred.profiler_conn_str
         # NOTE(jethro): changes to add the sampling decision
         if profiler_hmac_key is None:
             if is_sampled(SAMPLING_RATE) is True:
                 profiler_hmac_key = "Devstack1"
                 pass
             else:
                 return
         profiler.init(profiler_hmac_key)
         trace_id = profiler.get().get_base_id()
         complete_data = {
             "title": "OSProfiler Trace-ID",
             "chart_plugin": "OSProfiler",
             "data": {
                 "trace_id": [trace_id],
                 "conn_str": profiler_conn_str
             }
         }
         self.add_output(complete=complete_data)