diff options
author | 2015-11-23 08:23:47 -0800 | |
---|---|---|
committer | 2015-11-23 20:15:59 -0800 | |
commit | 002920e29d7fa4a28abec96773b470c90bafe55d (patch) | |
tree | 893f45209a84f197ef6ec3848ed83fc9df3eab8f /storperf/carbon/converter.py | |
parent | d480e8746512caf8821c42582e7ab75d25b3127b (diff) |
Adding workload modules
Adding the ablity to define workloads in modules which can be
referenced from the API. Breaking out the test execution into
its own class so it will be easier to support ReST or other
interfaces.
Added flake8 and code coverage reports where possible to
merge and verify jobs
Change-Id: Ieb51e4e7e1e989288a6f81f4757709669914a196
JIRA: STORPERF-21
Signed-off-by: mbeierl <mark.beierl@emc.com>
Diffstat (limited to 'storperf/carbon/converter.py')
-rw-r--r-- | storperf/carbon/converter.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/storperf/carbon/converter.py b/storperf/carbon/converter.py index 42dbeef..d551822 100644 --- a/storperf/carbon/converter.py +++ b/storperf/carbon/converter.py @@ -10,7 +10,9 @@ import calendar import logging import time + class JSONToCarbon(object): + def __init__(self): self.logger = logging.getLogger(__name__) @@ -18,11 +20,13 @@ class JSONToCarbon(object): # Use the timestamp reported by fio, or current time if # not present. if 'timestamp' in json_object: - self.timestamp = str(json_object['timestamp']) + timestamp = str(json_object.pop('timestamp')) else: - self.timestamp = str(calendar.timegm(time.gmtime())) + timestamp = str(calendar.timegm(time.gmtime())) self.flat_dictionary = {} + self.flat_dictionary['timestamp'] = timestamp + self.resurse_to_flat_dictionary(json_object, prefix) return self.flat_dictionary @@ -36,19 +40,18 @@ class JSONToCarbon(object): if hasattr(v, '__iter__'): self.resurse_to_flat_dictionary(v, key) else: - self.flat_dictionary[key] = str(v).replace(" ", "_") + " " + self.timestamp + self.flat_dictionary[key] = str(v).replace(" ", "_") elif type(json) == list: index = 0 for v in json: index += 1 if hasattr(v, '__iter__'): - self.resurse_to_flat_dictionary(v, prefix+"."+str(index)) + self.resurse_to_flat_dictionary( + v, prefix + "." + str(index)) else: if prefix is None: self.flat_dictionary[index] = str(v).replace(" ", "_") + " " + self.timestamp else: - key = prefix + "." + index; - self.flat_dictionary[key] = str(v).replace(" ", "_") + " " + self.timestamp - else: - self.flat_dictionary[json] = self.timestamp + key = prefix + "." + index + self.flat_dictionary[key] = str(v).replace(" ", "_") |