Miscalenous py3 fixes
Use six to fix compatibility issues betwen python2.7 and python3. Change-Id: Ia4cb715edf5cb5b86b83c2da0ef2de83078732bf Signed-off-by: Charles Short <chucks@redhat.com>
This commit is contained in:
parent
cda7cc180b
commit
22e620d221
@ -16,6 +16,9 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
|
|
||||||
class Metadata(object):
|
class Metadata(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -35,7 +38,7 @@ class Metadata(object):
|
|||||||
|
|
||||||
def get_hardware_metadata(self, sys_data):
|
def get_hardware_metadata(self, sys_data):
|
||||||
hard_dict = {}
|
hard_dict = {}
|
||||||
for item, dictionary in sys_data.iteritems():
|
for item, dictionary in six.iteritems(sys_data):
|
||||||
if any(node in sys_data[item]['group_names'] for node in self._supported_node_types):
|
if any(node in sys_data[item]['group_names'] for node in self._supported_node_types):
|
||||||
if 'hardware_details' not in hard_dict:
|
if 'hardware_details' not in hard_dict:
|
||||||
hard_dict['hardware_details'] = []
|
hard_dict['hardware_details'] = []
|
||||||
@ -59,24 +62,24 @@ class Metadata(object):
|
|||||||
|
|
||||||
def get_environment_metadata(self, sys_data):
|
def get_environment_metadata(self, sys_data):
|
||||||
env_dict = {}
|
env_dict = {}
|
||||||
for item, dictionary in sys_data.iteritems():
|
for item, dictionary in six.iteritems(sys_data):
|
||||||
if 'environment_setup' not in env_dict:
|
if 'environment_setup' not in env_dict:
|
||||||
env_dict['environment_setup'] = {}
|
env_dict['environment_setup'] = {}
|
||||||
for key, value in sys_data[item].iteritems():
|
for key, value in six.iteritems(sys_data[item]):
|
||||||
if 'stockpile_osp_env' in key:
|
if 'stockpile_osp_env' in key:
|
||||||
for nodes, number in value.iteritems():
|
for nodes, number in six.iteritems(value):
|
||||||
env_dict['environment_setup'][nodes] = number
|
env_dict['environment_setup'][nodes] = number
|
||||||
return env_dict
|
return env_dict
|
||||||
|
|
||||||
def get_software_metadata(self, sys_data):
|
def get_software_metadata(self, sys_data):
|
||||||
soft_all_dict = []
|
soft_all_dict = []
|
||||||
bad_output_list = [{},[],""]
|
bad_output_list = [{},[],""]
|
||||||
for item, dictionary in sys_data.iteritems():
|
for item, dictionary in six.iteritems(sys_data):
|
||||||
if any(node in sys_data[item]['group_names'] for node in self._supported_node_types):
|
if any(node in sys_data[item]['group_names'] for node in self._supported_node_types):
|
||||||
software_dict = {}
|
software_dict = {}
|
||||||
sample_vuln_dict = {}
|
sample_vuln_dict = {}
|
||||||
node = sys_data[item]['inventory_hostname']
|
node = sys_data[item]['inventory_hostname']
|
||||||
for key, output in sys_data[item].iteritems():
|
for key, output in six.iteritems(sys_data[item]):
|
||||||
if 'stockpile_yum' in key and output not in bad_output_list:
|
if 'stockpile_yum' in key and output not in bad_output_list:
|
||||||
software_dict['repos_enabled'] = {}
|
software_dict['repos_enabled'] = {}
|
||||||
software_dict['repos_enabled']['repos'] = []
|
software_dict['repos_enabled']['repos'] = []
|
||||||
@ -113,10 +116,10 @@ class Metadata(object):
|
|||||||
software_dict[service_name]['node_name'] = node
|
software_dict[service_name]['node_name'] = node
|
||||||
if key_name not in software_dict[service_name].keys():
|
if key_name not in software_dict[service_name].keys():
|
||||||
software_dict[service_name][key_name] = {}
|
software_dict[service_name][key_name] = {}
|
||||||
for obj, value in output.iteritems():
|
for obj, value in six.iteritems(output):
|
||||||
software_dict[service_name][key_name][obj] = value
|
software_dict[service_name][key_name][obj] = value
|
||||||
else:
|
else:
|
||||||
for obj, value in output.iteritems():
|
for obj, value in six.iteritems(output):
|
||||||
if obj not in software_dict.keys():
|
if obj not in software_dict.keys():
|
||||||
software_dict[obj] = value
|
software_dict[obj] = value
|
||||||
software_dict[obj]['node_name'] = node
|
software_dict[obj]['node_name'] = node
|
||||||
|
@ -27,6 +27,9 @@ from browbeat.path import get_workload_venv
|
|||||||
from browbeat.path import results_path
|
from browbeat.path import results_path
|
||||||
from browbeat.workloads import base
|
from browbeat.workloads import base
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
|
|
||||||
class PerfKit(base.WorkloadBase):
|
class PerfKit(base.WorkloadBase):
|
||||||
|
|
||||||
def __init__(self, config, result_dir_ts):
|
def __init__(self, config, result_dir_ts):
|
||||||
@ -41,7 +44,7 @@ class PerfKit(base.WorkloadBase):
|
|||||||
def string_to_dict(self, string):
|
def string_to_dict(self, string):
|
||||||
"""Function for converting "|" quoted hash data into python dictionary."""
|
"""Function for converting "|" quoted hash data into python dictionary."""
|
||||||
dict_data = {}
|
dict_data = {}
|
||||||
split_data = string.split('|,|')
|
split_data = '|,|'.split()
|
||||||
split_data[0] = split_data[0][1:]
|
split_data[0] = split_data[0][1:]
|
||||||
split_data[-1] = split_data[-1][:-1]
|
split_data[-1] = split_data[-1][:-1]
|
||||||
for item in split_data:
|
for item in split_data:
|
||||||
@ -110,7 +113,7 @@ class PerfKit(base.WorkloadBase):
|
|||||||
get_workload_venv('perfkit', True),
|
get_workload_venv('perfkit', True),
|
||||||
self.overcloudrc,
|
self.overcloudrc,
|
||||||
get_workload_venv('perfkit', False), cloud_type))
|
get_workload_venv('perfkit', False), cloud_type))
|
||||||
for parameter, value in benchmark_config.iteritems():
|
for parameter, value in six.iteritems(benchmark_config):
|
||||||
if not parameter == 'name':
|
if not parameter == 'name':
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
"Parameter: {}, Value: {}".format(parameter, value))
|
"Parameter: {}, Value: {}".format(parameter, value))
|
||||||
@ -168,7 +171,7 @@ class PerfKit(base.WorkloadBase):
|
|||||||
self.logger.info("Benchmark: {}".format(workload['name']))
|
self.logger.info("Benchmark: {}".format(workload['name']))
|
||||||
self.update_total_scenarios()
|
self.update_total_scenarios()
|
||||||
# Add default parameters as necessary
|
# Add default parameters as necessary
|
||||||
for default_item, value in self.config['perfkit']['default'].iteritems():
|
for default_item, value in six.iteritems(self.config['perfkit']['default']):
|
||||||
if default_item not in workload:
|
if default_item not in workload:
|
||||||
workload[default_item] = value
|
workload[default_item] = value
|
||||||
|
|
||||||
|
@ -28,6 +28,9 @@ from browbeat.path import results_path
|
|||||||
from browbeat.workloads import base
|
from browbeat.workloads import base
|
||||||
|
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
|
|
||||||
class Shaker(base.WorkloadBase):
|
class Shaker(base.WorkloadBase):
|
||||||
|
|
||||||
def __init__(self, config, result_dir_ts):
|
def __init__(self, config, result_dir_ts):
|
||||||
@ -59,7 +62,7 @@ class Shaker(base.WorkloadBase):
|
|||||||
|
|
||||||
def accommodation_to_list(self, accommodation):
|
def accommodation_to_list(self, accommodation):
|
||||||
accommodation_list = []
|
accommodation_list = []
|
||||||
for key, value in accommodation.iteritems():
|
for key, value in six.iteritems(accommodation):
|
||||||
if value is True:
|
if value is True:
|
||||||
accommodation_list.append(key)
|
accommodation_list.append(key)
|
||||||
else:
|
else:
|
||||||
@ -100,7 +103,7 @@ class Shaker(base.WorkloadBase):
|
|||||||
return True
|
return True
|
||||||
# Dictionary to capture common test data
|
# Dictionary to capture common test data
|
||||||
shaker_test_meta = {}
|
shaker_test_meta = {}
|
||||||
for scenario in data['scenarios'].iterkeys():
|
for scenario in data['scenarios']:
|
||||||
# Populating common test data
|
# Populating common test data
|
||||||
if 'shaker_test_info' not in shaker_test_meta:
|
if 'shaker_test_info' not in shaker_test_meta:
|
||||||
shaker_test_meta['shaker_test_info'] = data[
|
shaker_test_meta['shaker_test_info'] = data[
|
||||||
@ -135,7 +138,7 @@ class Shaker(base.WorkloadBase):
|
|||||||
shaker_test_meta['deployment']['template'] = data[
|
shaker_test_meta['deployment']['template'] = data[
|
||||||
'scenarios'][scenario]['deployment']['template']
|
'scenarios'][scenario]['deployment']['template']
|
||||||
# Iterating through each record to get result values
|
# Iterating through each record to get result values
|
||||||
for record in data['records'].iterkeys():
|
for record in data['records']:
|
||||||
if data['records'][record]['status'] == "ok" and data[
|
if data['records'][record]['status'] == "ok" and data[
|
||||||
'records'][record]['executor'] != "shell":
|
'records'][record]['executor'] != "shell":
|
||||||
if 'stdout' in data['records'][record]:
|
if 'stdout' in data['records'][record]:
|
||||||
@ -148,7 +151,7 @@ class Shaker(base.WorkloadBase):
|
|||||||
outputs[metric[0]] = metric[1]
|
outputs[metric[0]] = metric[1]
|
||||||
# Iterate over each result type for each sample in record and
|
# Iterate over each result type for each sample in record and
|
||||||
# get associated value
|
# get associated value
|
||||||
for key in outputs.iterkeys():
|
for key in outputs:
|
||||||
if key == "time":
|
if key == "time":
|
||||||
continue
|
continue
|
||||||
# Iterate in step lock over each list of samples in the
|
# Iterate in step lock over each list of samples in the
|
||||||
@ -259,7 +262,7 @@ class Shaker(base.WorkloadBase):
|
|||||||
|
|
||||||
def get_uuidlist(self, data):
|
def get_uuidlist(self, data):
|
||||||
uuidlist = []
|
uuidlist = []
|
||||||
for key in data['records'].iterkeys():
|
for key in data['records']:
|
||||||
uuidlist.append(key)
|
uuidlist.append(key)
|
||||||
return uuidlist
|
return uuidlist
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@ import csv
|
|||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import StringIO
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import browbeat.elastic
|
import browbeat.elastic
|
||||||
|
import six
|
||||||
|
|
||||||
from rally.common import sshutils
|
from rally.common import sshutils
|
||||||
from rally_openstack import consts
|
from rally_openstack import consts
|
||||||
@ -237,7 +237,7 @@ class BrowbeatPbenchUperf(neutron_utils.NeutronScenario,
|
|||||||
'timestamp': es_ts,
|
'timestamp': es_ts,
|
||||||
'num_pairs': num_pairs}}
|
'num_pairs': num_pairs}}
|
||||||
elastic = browbeat.elastic.Elastic(config, 'pbench')
|
elastic = browbeat.elastic.Elastic(config, 'pbench')
|
||||||
json_result = StringIO.StringIO(stdout_json)
|
json_result = six.StringIO(stdout_json)
|
||||||
json_data = json.load(json_result)
|
json_data = json.load(json_result)
|
||||||
for iteration in json_data:
|
for iteration in json_data:
|
||||||
elastic.index_result(iteration, test_name, 'results/')
|
elastic.index_result(iteration, test_name, 'results/')
|
||||||
@ -245,7 +245,7 @@ class BrowbeatPbenchUperf(neutron_utils.NeutronScenario,
|
|||||||
LOG.error("Error with PBench Results")
|
LOG.error("Error with PBench Results")
|
||||||
|
|
||||||
# Parse results
|
# Parse results
|
||||||
result = StringIO.StringIO('\n'.join(stdout.split('\n')[1:]))
|
result = six.StringIO('\n'.join(stdout.split('\n')[1:]))
|
||||||
creader = csv.reader(result)
|
creader = csv.reader(result)
|
||||||
report = []
|
report = []
|
||||||
for row in creader:
|
for row in creader:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user