summaryrefslogtreecommitdiffstats
path: root/utils/parser.py
diff options
context:
space:
mode:
authorliyin <liyin11@huawei.com>2017-01-11 19:10:57 +0800
committerAce Lee <liyin11@huawei.com>2017-01-12 08:36:38 +0000
commit9512f7cabad8cb1d7aaee22efe018c6539148dc2 (patch)
treee5fa5532cb7d8c00428999c3d09d64d466080004 /utils/parser.py
parente1a54d34819563946d1ff1ec673d1d261b826ad8 (diff)
Bottlenecks stack environment prepare
JIRA: BOTTLENECK-124 This code is for Bottlenecks to have a common way to prepare stack environment. those action are divided into three part: fetch os file, source file and adding ext-net to source file. those function also need change other file like fetch_os_creds.sh. And add some config to config file. remove parser file logging function. This code is relying on the patch: Modify utils/ code into PEP8 style Change-Id: I54405776b6dc3f5fb939e511c96963a9c1624938 Signed-off-by: liyin <liyin11@huawei.com>
Diffstat (limited to 'utils/parser.py')
-rw-r--r--utils/parser.py59
1 files changed, 36 insertions, 23 deletions
diff --git a/utils/parser.py b/utils/parser.py
index 7ddf02a2..ce5096a3 100644
--- a/utils/parser.py
+++ b/utils/parser.py
@@ -7,50 +7,63 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from logger import Logger
import os
import yaml
class Parser():
- def __init__(self):
- self.code_dir = os.path.dirname(os.path.abspath(__file__))
- self.root_dir = os.path.dirname(self.code_dir)
- self.test_dir = os.path.join(self.root_dir, 'testsuites')
+
+ bottlenecks_config = {}
+
+ @classmethod
+ def config_init(cls):
+ cls.code_dir = os.path.dirname(os.path.abspath(__file__))
+ cls.root_dir = os.path.dirname(cls.code_dir)
+ cls.test_dir = os.path.join(cls.root_dir, 'testsuites')
config_dir = os.path.join(
- self.root_dir,
+ cls.root_dir,
'config',
'config.yaml')
+
with open(config_dir) as file:
- log_info = yaml.load(file)
- self.logdir = log_info['common_config']
- self.LOG = Logger(__name__).getLogger()
-
- def config_read(self, testcase, story_name):
- self.LOG.info("begin to parser config file!")
- testcase_parser = {}
- self.story_dir = os.path.join(
- self.test_dir,
+ config_info = yaml.load(file)
+ common_config = config_info['common_config']
+ cls.bottlenecks_config["releng_dir"] = common_config["releng_dir"]
+ cls.bottlenecks_config["fetch_os"] = common_config["fetch_os_file"]
+ cls.bottlenecks_config["log_dir"] = common_config['log_dir']
+ cls.bottlenecks_config["rc_dir"] = common_config['rc_dir']
+ cls.config_dir_check(cls.bottlenecks_config["log_dir"])
+
+ @classmethod
+ def config_read(cls, testcase, story_name):
+ story_dir = os.path.join(
+ cls.test_dir,
testcase,
'testsuite_story',
story_name)
- with open(self.story_dir) as file:
- self.LOG.info('testsuite:' + testcase + 'story:' + story_name)
+ with open(story_dir) as file:
story_parser = yaml.load(file)
for case_name in story_parser['testcase']:
testcase_dir = os.path.join(
- self.test_dir,
+ cls.test_dir,
testcase,
'testcase_cfg',
case_name)
with open(testcase_dir) as f:
- self.LOG.info('story: %s, testcase: %s' % (story_name, case_name))
- testcase_parser[case_name] = yaml.load(f)
+ cls.bottlenecks_config[case_name] = yaml.load(f)
+
+ return cls.bottlenecks_config
- return testcase_parser
+ @classmethod
+ def config_dir_check(cls, dirname):
+ if dirname is None:
+ dirname = '/tmp/'
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
- def config_parser(self, testcase_cfg, parameters):
+ @staticmethod
+ def config_parser(testcase_cfg, parameters):
test_cfg = testcase_cfg['test_config']
stack_cfg = testcase_cfg['stack_config']
# TO-DO add cli parameters to stack_config.
- return test_cfg, stack_cfg \ No newline at end of file
+ return test_cfg, stack_cfg