aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/dispatcher
diff options
context:
space:
mode:
authorrexlee8776 <limingjiang@huawei.com>2017-07-05 02:50:06 +0000
committerrexlee8776 <limingjiang@huawei.com>2017-07-06 07:49:10 +0000
commit25a37b2048281c64719bd6ad67860f65f6c31546 (patch)
tree726e1ff64ea3470ab6b91db8fdbc386383f08903 /yardstick/dispatcher
parent3369461d0e51b22aa96e5bfd0d80b3f0f7f82c67 (diff)
move flatten dict key to common utils
So it can easily be used by other testcase to unify result JIRA: YARDSTICK-702 Change-Id: Id4fde38a9a0c2a87a6c870bdb7b0c8f3a3b371ac Signed-off-by: rexlee8776 <limingjiang@huawei.com>
Diffstat (limited to 'yardstick/dispatcher')
-rw-r--r--yardstick/dispatcher/influxdb.py26
1 files changed, 2 insertions, 24 deletions
diff --git a/yardstick/dispatcher/influxdb.py b/yardstick/dispatcher/influxdb.py
index 373aae13a..f157e91f9 100644
--- a/yardstick/dispatcher/influxdb.py
+++ b/yardstick/dispatcher/influxdb.py
@@ -12,10 +12,9 @@ from __future__ import absolute_import
import logging
import time
-import collections
import requests
-import six
+from yardstick.common import utils
from third_party.influxdb.influxdb_line_protocol import make_lines
from yardstick.dispatcher.base import Base as DispatchBase
@@ -80,7 +79,7 @@ class InfluxdbDispatcher(DispatchBase):
msg = {}
point = {
"measurement": case,
- "fields": self._dict_key_flatten(data["data"]),
+ "fields": utils.flatten_dict_key(data["data"]),
"time": self._get_nano_timestamp(data),
"tags": self._get_extended_tags(criteria),
}
@@ -89,27 +88,6 @@ class InfluxdbDispatcher(DispatchBase):
return make_lines(msg).encode('utf-8')
- def _dict_key_flatten(self, data):
- next_data = {}
-
- # use list, because iterable is too generic
- if not [v for v in data.values() if
- isinstance(v, (collections.Mapping, list))]:
- return data
-
- for k, v in six.iteritems(data):
- if isinstance(v, collections.Mapping):
- for n_k, n_v in six.iteritems(v):
- next_data["%s.%s" % (k, n_k)] = n_v
- # use list because iterable is too generic
- elif isinstance(v, list):
- for index, item in enumerate(v):
- next_data["%s%d" % (k, index)] = item
- else:
- next_data[k] = v
-
- return self._dict_key_flatten(next_data)
-
def _get_nano_timestamp(self, results):
try:
timestamp = results["timestamp"]