Exemple #1
0
    def test_helper_set_qs_on_url(self):

        params = {'metricType': 'requestCount', 'domain': 'poppy.org'}

        url_with_qs_set = helper.set_qs_on_url(self.url, **params)

        self.assertIn('metricType=requestCount', url_with_qs_set)
        self.assertIn('domain=poppy.org', url_with_qs_set)
Exemple #2
0
    def test_helper_set_qs_on_url(self):

        params = {
            'metricType': 'requestCount',
            'domain': 'poppy.org'
        }

        url_with_qs_set = helper.set_qs_on_url(self.url, **params)

        self.assertIn('metricType=requestCount', url_with_qs_set)
        self.assertIn('domain=poppy.org', url_with_qs_set)
Exemple #3
0
    def read(self, metric_names, from_timestamp, to_timestamp, resolution):
        """read metrics from metrics driver.

        """
        curr_resolution = \
            helper.resolution_converter_seconds_to_enum(resolution)
        context_dict = context_utils.get_current().to_dict()

        project_id = context_dict['tenant']
        auth_token = None
        if self.driver.metrics_conf.use_keystone_auth:
            auth_token = context_dict['auth_token']

        tenanted_blueflood_url = \
            self.driver.metrics_conf.blueflood_url.format(
                project_id=project_id
            )
        from_timestamp = int(helper.datetime_to_epoch(from_timestamp))
        to_timestamp = int(helper.datetime_to_epoch(to_timestamp))
        urls = []
        params = {
            'to': to_timestamp,
            'from': from_timestamp,
            'resolution': curr_resolution
        }
        for metric_name in metric_names:
            tenanted_blueflood_url_with_metric = helper.join_url(
                tenanted_blueflood_url,
                metric_name.strip().replace(" ", ""))
            LOG.info("Querying BlueFlood Metric: {0}".format(
                tenanted_blueflood_url_with_metric))
            urls.append(
                helper.set_qs_on_url(tenanted_blueflood_url_with_metric,
                                     **params))
        executors = self.driver.metrics_conf.no_of_executors
        blueflood_client = client.BlueFloodMetricsClient(token=auth_token,
                                                         project_id=project_id,
                                                         executors=executors)
        results = blueflood_client.async_requests(urls)
        reordered_metric_names = []
        for result in results:
            metric_name = helper.retrieve_last_relative_url(result.url)
            reordered_metric_names.append(metric_name)

        formatted_results = []
        for metric_name, result in zip(reordered_metric_names, results):
            formatted_result = self._result_formatter(result)
            # NOTE(TheSriram): Tuple to pass the associated metric name, along
            # with the formatted result
            formatted_results.append((metric_name, formatted_result))

        return formatted_results
Exemple #4
0
    def read(self, metric_names, from_timestamp, to_timestamp, resolution):
        """read metrics from metrics driver.

        """
        curr_resolution = \
            helper.resolution_converter_seconds_to_enum(resolution)
        context_dict = context_utils.get_current().to_dict()

        project_id = context_dict['tenant']
        auth_token = None
        if self.driver.metrics_conf.use_keystone_auth:
            auth_token = context_dict['auth_token']

        tenanted_blueflood_url = \
            self.driver.metrics_conf.blueflood_url.format(
                project_id=project_id
            )
        from_timestamp = int(helper.datetime_to_epoch(from_timestamp))
        to_timestamp = int(helper.datetime_to_epoch(to_timestamp))
        urls = []
        params = {
            'to': to_timestamp,
            'from': from_timestamp,
            'resolution': curr_resolution
        }
        for metric_name in metric_names:
            tenanted_blueflood_url_with_metric = helper.join_url(
                tenanted_blueflood_url, metric_name.strip().replace(" ", ""))
            LOG.info("Querying BlueFlood Metric: {0}".format(
                tenanted_blueflood_url_with_metric))
            urls.append(helper.set_qs_on_url(
                        tenanted_blueflood_url_with_metric,
                        **params))
        executors = self.driver.metrics_conf.no_of_executors
        blueflood_client = client.BlueFloodMetricsClient(token=auth_token,
                                                         project_id=project_id,
                                                         executors=executors)
        results = blueflood_client.async_requests(urls)
        reordered_metric_names = []
        for result in results:
            metric_name = helper.retrieve_last_relative_url(result.url)
            reordered_metric_names.append(metric_name)

        formatted_results = []
        for metric_name, result in zip(reordered_metric_names, results):
            formatted_result = self._result_formatter(result)
            # NOTE(TheSriram): Tuple to pass the associated metric name, along
            # with the formatted result
            formatted_results.append((metric_name, formatted_result))

        return formatted_results