dovetail tool: reorganize statements in class DovetailConfig 31/24931/3
authorxudan <xudan16@huawei.com>
Sat, 26 Nov 2016 08:43:47 +0000 (08:43 +0000)
committerDan Xu <xudan16@huawei.com>
Tue, 29 Nov 2016 09:10:51 +0000 (09:10 +0000)
1. move some statements in class DovetailConfig into function
   load_config_files()
2. call load_config_files() in run.py
3. this can only work correctly after moving clean_results_dir() into run.py,
   see JIRA:DOVETAIL-80 and gerrit https://gerrit.opnfv.org/gerrit/#/c/24929/

JIRA: DOVETAIL-55

Change-Id: I217c1c21dc6ba8849da7c00564f62d3c22cdc391
Signed-off-by: xudan <xudan16@huawei.com>
dovetail/conf/dovetail_config.py
dovetail/run.py

index 8fa1a6d..c37e8d0 100644 (file)
@@ -21,19 +21,23 @@ class DovetailConfig:
     # testarea supported tuple, should adjust accordingly
     testarea_supported = ('vimops', 'nfvi', 'ipv6')
 
-    curr_path = os.path.dirname(os.path.abspath(__file__))
+    dovetail_config = {}
 
-    with open(os.path.join(curr_path, 'dovetail_config.yml')) as f:
-        dovetail_config = yaml.safe_load(f)
+    @classmethod
+    def load_config_files(cls):
+        curr_path = os.path.dirname(os.path.abspath(__file__))
+        with open(os.path.join(curr_path, 'dovetail_config.yml')) as f:
+            cls.dovetail_config = yaml.safe_load(f)
 
-    for extra_config_file in dovetail_config['include_config']:
-        with open(os.path.join(curr_path, extra_config_file)) as f:
-            extra_config = yaml.safe_load(f)
-            dovetail_config.update(extra_config)
+        for extra_config_file in cls.dovetail_config['include_config']:
+            with open(os.path.join(curr_path, extra_config_file)) as f:
+                extra_config = yaml.safe_load(f)
+                cls.dovetail_config.update(extra_config)
 
-    with open(os.path.join(curr_path, dovetail_config['cli_file_name'])) as f:
-        cmd_yml = yaml.safe_load(f)
-        dovetail_config['cli'] = cmd_yml[cmd_yml.keys()[0]]
+        path = os.path.join(curr_path, cls.dovetail_config['cli_file_name'])
+        with open(path) as f:
+            cmd_yml = yaml.safe_load(f)
+            cls.dovetail_config['cli'] = cmd_yml[cmd_yml.keys()[0]]
 
     @classmethod
     def cmd_name_trans(cls, cmd_name):
index cc0e794..865b399 100755 (executable)
@@ -155,6 +155,8 @@ def main(*args, **kwargs):
                      (kwargs['testsuite'], testarea))
 
 
+dt_config.load_config_files()
+
 CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
 if dt_config.dovetail_config['cli']['options'] is not None:
     for key, value in dt_config.dovetail_config['cli']['options'].items():