diff options
author | chenjiankun <chenjiankun1@huawei.com> | 2017-02-25 00:48:07 +0000 |
---|---|---|
committer | chenjiankun <chenjiankun1@huawei.com> | 2017-03-08 08:42:32 +0000 |
commit | af3478e95314b5147c7837831dc8113d552ba067 (patch) | |
tree | e9411bebe78eca2f0d204d8a49464e7f620a0ff1 /yardstick/common | |
parent | 501175fbb095a771f5f1b9fb80dcf729192214d2 (diff) |
Bugfix: yardstick will create stacks with the same name when run using API in parallel
JIRA: YARDSTICK-575
Currently yardstick will create stacks with the same name when run using
API in parallel.
The reason is there is a global variable in context base and the core
will always deploy the first context in Context.list. When run in
parallel, it will run in the one process. So yardstick will deploy
stacks with the same name.
The solution is do not use Context.list in yardstick core. And using a
local variable instead.
BTW, if we use API to call yardstick core, we can not config the output
way. So I parse yardstick.conf when task start. And I think we can
include scenario_cfg, context_cfg, yardstick_cfg in one config object
later so that we can get all config in one object.
Change-Id: I1ada4ef486bd252e78c3a2e49c6a39b3f8f16a7c
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'yardstick/common')
-rw-r--r-- | yardstick/common/utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py index 3c5895f1e..e53f4b416 100644 --- a/yardstick/common/utils.py +++ b/yardstick/common/utils.py @@ -26,6 +26,7 @@ import sys from functools import reduce import yaml +from six.moves import configparser from oslo_utils import importutils from oslo_serialization import jsonutils @@ -144,3 +145,19 @@ def write_json_to_file(path, data, mode='w'): def write_file(path, data, mode='w'): with open(path, mode) as f: f.write(data) + + +def parse_ini_file(path): + parser = configparser.ConfigParser() + parser.read(path) + + try: + default = {k: v for k, v in parser.items('DEFAULT')} + except configparser.NoSectionError: + default = {} + + config = dict(DEFAULT=default, + **{s: {k: v for k, v in parser.items( + s)} for s in parser.sections()}) + + return config |