diff options
-rw-r--r-- | api/resources/env_action.py | 13 | ||||
-rw-r--r-- | api/resources/write_hosts.py | 23 | ||||
-rw-r--r-- | tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml | 2 | ||||
-rw-r--r-- | tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-noha_daily.yaml | 2 | ||||
-rw-r--r-- | tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml | 2 | ||||
-rw-r--r-- | tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-noha_daily.yaml | 2 | ||||
-rw-r--r-- | tests/opnfv/test_suites/opnfv_os-odl_l3-ovs-ha_daily.yaml | 2 | ||||
-rw-r--r-- | yardstick/benchmark/core/task.py | 6 | ||||
-rw-r--r-- | yardstick/cmd/commands/task.py | 7 |
9 files changed, 50 insertions, 9 deletions
diff --git a/api/resources/env_action.py b/api/resources/env_action.py index 2ea64ef1a..fed987063 100644 --- a/api/resources/env_action.py +++ b/api/resources/env_action.py @@ -18,6 +18,7 @@ import uuid import glob import yaml import collections +from subprocess import PIPE from six.moves import configparser from oslo_serialization import jsonutils @@ -415,10 +416,12 @@ def update_hosts(hosts_ip): if not isinstance(hosts_ip, dict): return result_handler(consts.API_ERROR, 'Error, args should be a dict') LOG.info('Writing hosts: Writing') - hosts_list = ['\n{} {}'.format(ip, host_name) - for host_name, ip in hosts_ip.items()] - LOG.debug('Writing: %s', hosts_list) - with open(consts.ETC_HOSTS, 'a') as f: - f.writelines(hosts_list) + LOG.debug('Writing: %s', hosts_ip) + cmd = ["sudo", "python", "write_hosts.py"] + p = subprocess.Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, + cwd = os.path.join(consts.REPOS_DIR, "api/resources")) + _, err = p.communicate(jsonutils.dumps(hosts_ip)) + if p.returncode != 0 : + return result_handler(consts.API_ERROR, err) LOG.info('Writing hosts: Done') return result_handler(consts.API_SUCCESS, 'success') diff --git a/api/resources/write_hosts.py b/api/resources/write_hosts.py new file mode 100644 index 000000000..e4b69846b --- /dev/null +++ b/api/resources/write_hosts.py @@ -0,0 +1,23 @@ +############################################################################## +# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +from __future__ import absolute_import + +import sys +import json + + +def write_hosts(hosts_ip): + hosts_list = ('\n{} {}'.format(ip, host_name) + for host_name, ip in hosts_ip.items()) + with open("/etc/hosts", 'a') as f: + f.writelines(hosts_list) + f.write("\n") + +if __name__ == "__main__": + write_hosts(json.load(sys.stdin)) diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml index 674c9a8be..b8b8c4695 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-ha_daily.yaml @@ -22,6 +22,8 @@ test_cases: file_name: opnfv_yardstick_tc010.yaml - file_name: opnfv_yardstick_tc011.yaml + constraint: + installer: compass - file_name: opnfv_yardstick_tc012.yaml - diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-noha_daily.yaml index 0f00bd7ea..cd352cc1b 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l2-nofeature-noha_daily.yaml @@ -22,6 +22,8 @@ test_cases: file_name: opnfv_yardstick_tc010.yaml - file_name: opnfv_yardstick_tc011.yaml + constraint: + installer: compass - file_name: opnfv_yardstick_tc012.yaml - diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml index 0459a13a3..a503db99e 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-ha_daily.yaml @@ -22,6 +22,8 @@ test_cases: file_name: opnfv_yardstick_tc010.yaml - file_name: opnfv_yardstick_tc011.yaml + constraint: + installer: compass - file_name: opnfv_yardstick_tc012.yaml - diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-noha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-noha_daily.yaml index d7429b136..e83aaec9d 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-noha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l3-nofeature-noha_daily.yaml @@ -22,6 +22,8 @@ test_cases: file_name: opnfv_yardstick_tc010.yaml - file_name: opnfv_yardstick_tc011.yaml + constraint: + installer: compass - file_name: opnfv_yardstick_tc012.yaml - diff --git a/tests/opnfv/test_suites/opnfv_os-odl_l3-ovs-ha_daily.yaml b/tests/opnfv/test_suites/opnfv_os-odl_l3-ovs-ha_daily.yaml index 4411b2cac..4165c5464 100644 --- a/tests/opnfv/test_suites/opnfv_os-odl_l3-ovs-ha_daily.yaml +++ b/tests/opnfv/test_suites/opnfv_os-odl_l3-ovs-ha_daily.yaml @@ -22,6 +22,8 @@ test_cases: file_name: opnfv_yardstick_tc010.yaml - file_name: opnfv_yardstick_tc011.yaml + constraint: + installer: compass - file_name: opnfv_yardstick_tc012.yaml - diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py index a985c86ef..30ad98f4b 100644 --- a/yardstick/benchmark/core/task.py +++ b/yardstick/benchmark/core/task.py @@ -375,10 +375,10 @@ class TaskParser(object): # pragma: no cover tc_fit_installer = constraint.get('installer', None) LOG.info("cur_pod:%s, cur_installer:%s,tc_constraints:%s", cur_pod, cur_installer, constraint) - if cur_pod and tc_fit_pod and cur_pod not in tc_fit_pod: + if (cur_pod is None) or (tc_fit_pod and cur_pod not in tc_fit_pod): return False - if cur_installer and tc_fit_installer and \ - cur_installer not in tc_fit_installer: + if (cur_installer is None) or (tc_fit_installer and cur_installer + not in tc_fit_installer): return False return True diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py index 0f98cabdc..03f6b1b1e 100644 --- a/yardstick/cmd/commands/task.py +++ b/yardstick/cmd/commands/task.py @@ -11,6 +11,8 @@ from __future__ import print_function from __future__ import absolute_import +import logging + from yardstick.benchmark.core.task import Task from yardstick.common.utils import cliargs from yardstick.common.utils import write_json_to_file @@ -19,6 +21,9 @@ from yardstick.cmd.commands import change_osloobj_to_paras output_file_default = "/tmp/yardstick.out" +LOG = logging.getLogger(__name__) + + class TaskCommands(object): # pragma: no cover """Task commands. @@ -49,7 +54,7 @@ class TaskCommands(object): # pragma: no cover Task().start(param, **kwargs) except Exception as e: self._write_error_data(e) - raise + LOG.exception("") def _write_error_data(self, error): data = {'status': 2, 'result': str(error)} |