diff options
Diffstat (limited to 'yardstick/common')
-rw-r--r-- | yardstick/common/constants.py | 1 | ||||
-rw-r--r-- | yardstick/common/httpClient.py | 6 | ||||
-rw-r--r-- | yardstick/common/openstack_utils.py | 1 | ||||
-rwxr-xr-x | yardstick/common/task_template.py | 2 | ||||
-rw-r--r-- | yardstick/common/template_format.py | 6 | ||||
-rw-r--r-- | yardstick/common/utils.py | 18 |
6 files changed, 23 insertions, 11 deletions
diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py index 174d39bfe..d99e216f4 100644 --- a/yardstick/common/constants.py +++ b/yardstick/common/constants.py @@ -6,6 +6,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import os DOCKER_URL = 'unix://var/run/docker.sock' diff --git a/yardstick/common/httpClient.py b/yardstick/common/httpClient.py index 6acd0303d..11c2d752d 100644 --- a/yardstick/common/httpClient.py +++ b/yardstick/common/httpClient.py @@ -6,9 +6,11 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import json +from __future__ import absolute_import + import logging +from oslo_serialization import jsonutils import requests logger = logging.getLogger(__name__) @@ -17,7 +19,7 @@ logger = logging.getLogger(__name__) class HttpClient(object): def post(self, url, data): - data = json.dumps(data) + data = jsonutils.dump_as_bytes(data) headers = {'Content-Type': 'application/json'} try: response = requests.post(url, data=data, headers=headers) diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py index d8dc61ef6..e351d16d3 100644 --- a/yardstick/common/openstack_utils.py +++ b/yardstick/common/openstack_utils.py @@ -7,6 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from __future__ import absolute_import import os import logging diff --git a/yardstick/common/task_template.py b/yardstick/common/task_template.py index 2739323bd..bda8a1b13 100755 --- a/yardstick/common/task_template.py +++ b/yardstick/common/task_template.py @@ -7,12 +7,14 @@ # http://www.apache.org/licenses/LICENSE-2.0 # yardstick: this file is copied from rally and slightly modified ############################################################################## +from __future__ import absolute_import import re import jinja2 import jinja2.meta class TaskTemplate(object): + @classmethod def render(cls, task_template, **kwargs): """Render jinja2 task template to Yardstick input task. diff --git a/yardstick/common/template_format.py b/yardstick/common/template_format.py index 2deaf393c..2432c5dc6 100644 --- a/yardstick/common/template_format.py +++ b/yardstick/common/template_format.py @@ -12,8 +12,10 @@ # yardstick: this file is copied from python-heatclient and slightly modified -import json +from __future__ import absolute_import + import yaml +from oslo_serialization import jsonutils if hasattr(yaml, 'CSafeLoader'): yaml_loader = yaml.CSafeLoader @@ -46,7 +48,7 @@ def parse(tmpl_str): JSON or YAML format. ''' if tmpl_str.startswith('{'): - tpl = json.loads(tmpl_str) + tpl = jsonutils.loads(tmpl_str) else: try: tpl = yaml.load(tmpl_str, Loader=yaml_loader) diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py index 3ecb0ae20..57ace14e6 100644 --- a/yardstick/common/utils.py +++ b/yardstick/common/utils.py @@ -15,17 +15,21 @@ # yardstick comment: this is a modified copy of rally/rally/common/utils.py -import os -import sys -import yaml +from __future__ import absolute_import +from __future__ import print_function + import errno -import subprocess import logging +import os +import subprocess +import sys +from functools import reduce -from oslo_utils import importutils +import yaml from keystoneauth1 import identity from keystoneauth1 import session from neutronclient.v2_0 import client +from oslo_utils import importutils import yardstick @@ -94,12 +98,12 @@ def get_para_from_yaml(file_path, args): value = reduce(func, args.split('.'), value) if value is None: - print 'parameter not found' + print('parameter not found') return None return value else: - print 'file not exist' + print('file not exist') return None |