summaryrefslogtreecommitdiffstats
path: root/utils/parser.py
diff options
context:
space:
mode:
authorYu Yang (Gabriel) <Gabriel.yuyang@huawei.com>2017-02-07 02:22:29 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-02-07 02:22:30 +0000
commitcb7f830d3e4a2a5665ff95687838c80a353687bf (patch)
treee523c9d8ddea4600ef798d668554051a16ee8afa /utils/parser.py
parent1616f4d418695ab7db1d18293f0ac4ccb71b79e1 (diff)
parentc6755e612b322facefc4edc32e948ab2b00bb3b0 (diff)
Merge "Bottlenecks POSCA testing code reconstruction"
Diffstat (limited to 'utils/parser.py')
-rw-r--r--utils/parser.py33
1 files changed, 24 insertions, 9 deletions
diff --git a/utils/parser.py b/utils/parser.py
index ce5096a3..c8715859 100644
--- a/utils/parser.py
+++ b/utils/parser.py
@@ -7,6 +7,11 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+'''This file realize the function of how to parser a config file.
+This contain Two part:
+Frist is Init some variables the will be used.
+Second is reading config file.'''
+
import os
import yaml
@@ -14,6 +19,7 @@ import yaml
class Parser():
bottlenecks_config = {}
+ bottlenecks_test = {}
@classmethod
def config_init(cls):
@@ -35,7 +41,7 @@ class Parser():
cls.config_dir_check(cls.bottlenecks_config["log_dir"])
@classmethod
- def config_read(cls, testcase, story_name):
+ def story_read(cls, testcase, story_name):
story_dir = os.path.join(
cls.test_dir,
testcase,
@@ -44,15 +50,23 @@ class Parser():
with open(story_dir) as file:
story_parser = yaml.load(file)
for case_name in story_parser['testcase']:
- testcase_dir = os.path.join(
- cls.test_dir,
- testcase,
- 'testcase_cfg',
- case_name)
- with open(testcase_dir) as f:
- cls.bottlenecks_config[case_name] = yaml.load(f)
+ Parser.testcase_read(cls, testcase, case_name)
+
+ return cls.bottlenecks_test
+
+ @classmethod
+ def testcase_read(cls, testcase, testcase_name):
- return cls.bottlenecks_config
+ testcase_dir = os.path.join(
+ cls.test_dir,
+ testcase,
+ 'testcase_cfg',
+ testcase_name)
+ testcase_local = testcase_dir + ".yaml"
+ with open(testcase_local) as f:
+ cls.bottlenecks_test[testcase_name] = yaml.load(f)
+
+ return cls.bottlenecks_test
@classmethod
def config_dir_check(cls, dirname):
@@ -67,3 +81,4 @@ class Parser():
stack_cfg = testcase_cfg['stack_config']
# TO-DO add cli parameters to stack_config.
return test_cfg, stack_cfg
+