diff options
Diffstat (limited to 'yardstick/cmd')
-rw-r--r-- | yardstick/cmd/commands/task.py | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py index 17e8f4c42..55898e1cb 100644 --- a/yardstick/cmd/commands/task.py +++ b/yardstick/cmd/commands/task.py @@ -84,9 +84,13 @@ class TaskCommands(object): one_task_start_time = time.time() parser.path = task_files[i] task_name = os.path.splitext(os.path.basename(task_files[i]))[0] - scenarios, run_in_parallel = parser.parse_task(task_name, - task_args[i], - task_args_fnames[i]) + scenarios, run_in_parallel, meet_precondition = parser.parse_task( + task_name, task_args[i], task_args_fnames[i]) + + if not meet_precondition: + LOG.info("meet_precondition is %s, please check envrionment", + meet_precondition) + continue self._run(scenarios, run_in_parallel, args.output_file) @@ -232,6 +236,7 @@ class TaskParser(object): sys.exit(ioerror) self._check_schema(cfg["schema"], "task") + meet_precondition = self._check_precondition(cfg) # TODO: support one or many contexts? Many would simpler and precise # TODO: support hybrid context type @@ -261,7 +266,7 @@ class TaskParser(object): scenario["task_id"] = task_id # TODO we need something better here, a class that represent the file - return cfg["scenarios"], run_in_parallel + return cfg["scenarios"], run_in_parallel, meet_precondition def _check_schema(self, cfg_schema, schema_type): '''Check if config file is using the correct schema type''' @@ -270,6 +275,26 @@ class TaskParser(object): sys.exit("error: file %s has unknown schema %s" % (self.path, cfg_schema)) + def _check_precondition(self, cfg): + '''Check if the envrionment meet the preconditon''' + + if "precondition" in cfg: + precondition = cfg["precondition"] + installer_type = precondition.get("installer_type", None) + deploy_scenarios = precondition.get("deploy_scenarios", None) + installer_type_env = os.environ.get('INSTALL_TYPE', None) + deploy_scenario_env = os.environ.get('DEPLOY_SCENARIO', None) + if installer_type and installer_type_env: + if installer_type_env not in installer_type: + return False + if deploy_scenarios and deploy_scenario_env: + deploy_scenarios_list = deploy_scenarios.split(',') + for deploy_scenario in deploy_scenarios_list: + if deploy_scenario_env.startswith(deploy_scenario): + return True + return False + return True + def atexit_handler(): '''handler for process termination''' |