Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-48-aria-cli 2f2751c3b -> 47fc1eaa3
few fixes Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/47fc1eaa Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/47fc1eaa Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/47fc1eaa Branch: refs/heads/ARIA-48-aria-cli Commit: 47fc1eaa345a3976d2b2e6b3420a46c85f23a427 Parents: 2f2751c Author: Ran Ziv <[email protected]> Authored: Wed Mar 29 12:57:24 2017 +0300 Committer: Ran Ziv <[email protected]> Committed: Wed Mar 29 12:57:24 2017 +0300 ---------------------------------------------------------------------- aria/cli/cli/aria.py | 21 ++++++++--------- aria/orchestrator/workflow_runner.py | 39 +++++++++++++++++++------------ 2 files changed, 34 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/47fc1eaa/aria/cli/cli/aria.py ---------------------------------------------------------------------- diff --git a/aria/cli/cli/aria.py b/aria/cli/cli/aria.py index e760c2d..b699d05 100644 --- a/aria/cli/cli/aria.py +++ b/aria/cli/cli/aria.py @@ -130,20 +130,19 @@ def set_cli_except_hook(global_verbosity_level): logger.info(' - {0}'.format(solution)) def new_excepthook(tpe, value, tb): - with open(env.logging.log_file, 'a') as log_file: - #TODO is this printed both via here and via logger?? - traceback.print_exception( - etype=tpe, - value=value, - tb=tb, - file=log_file) - - if global_verbosity_level or True: + if global_verbosity_level: # log error including traceback logger.error(get_exception_as_string(tpe, value, tb)) else: - # log only the error message - logger.error(value) + # write the full error to the log file + with open(env.logging.log_file, 'a') as log_file: + traceback.print_exception( + etype=tpe, + value=value, + tb=tb, + file=log_file) + # print only the error message + print value if hasattr(value, 'possible_solutions'): recommend(getattr(value, 'possible_solutions')) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/47fc1eaa/aria/orchestrator/workflow_runner.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflow_runner.py b/aria/orchestrator/workflow_runner.py index 3d790a8..d6b3b5c 100644 --- a/aria/orchestrator/workflow_runner.py +++ b/aria/orchestrator/workflow_runner.py @@ -44,27 +44,32 @@ class WorkflowRunner(object): task_retry_interval=DEFAULT_TASK_RETRY_INTERVAL): self._model_storage = model_storage - self._service = model_storage.service.get_by_name(service_name) self._workflow_name = workflow_name + service = model_storage.service.get_by_name(service_name) + # the IDs are stored rather than the models themselves, so this module could be used + # by several threads without raising errors on model objects shared between threads + self._service_id = service.id self._validate_workflow_exists_for_service() workflow_fn = self._get_workflow_fn() - self._execution = self._create_execution_models(inputs) + execution = self._create_execution_models(inputs) + self._execution_id = execution.id workflow_context = WorkflowContext( name=self.__class__.__name__, model_storage=self._model_storage, resource_storage=resource_storage, - service_id=self._service.id, - execution_id=self._execution.id, + service_id=service.id, + execution_id=execution.id, workflow_name=workflow_name, task_max_attempts=task_max_attempts, task_retry_interval=task_retry_interval) - merged_inputs_dict = {input.name: input.value for input in self._execution.inputs.values()} - self._tasks_graph = workflow_fn(ctx=workflow_context, **merged_inputs_dict) + # merged_inputs_dict = {input.name: input.value for input in self.execution.inputs.values()} + # self._tasks_graph = workflow_fn(ctx=workflow_context, **merged_inputs_dict) + self._tasks_graph = workflow_fn(ctx=workflow_context) self._engine = Engine( executor=ProcessExecutor(plugin_manager=plugin_manager), @@ -73,10 +78,14 @@ class WorkflowRunner(object): @property def execution(self): - return self._execution + return self._model_storage.execution.get(self._execution_id) + + @property + def service(self): + return self._model_storage.service.get(self._service_id) def execute(self): - self._validate_no_active_executions() + # self._validate_no_active_executions() self._engine.execute() def cancel(self): @@ -85,11 +94,11 @@ class WorkflowRunner(object): def _create_execution_models(self, inputs): execution = models.Execution( created_at=datetime.utcnow(), - service=self._service, + service=self.service, workflow_name=self._workflow_name) # workflow_inputs = {k: v for k, v in - # self._service.workflows[self._workflow_name].properties + # self.service.workflows[self._workflow_name].properties # if k not in WORKFLOW_POLICY_INTERNAL_PROPERTIES} # input_models = storage_utils.create_inputs(inputs, workflow_inputs) @@ -99,26 +108,26 @@ class WorkflowRunner(object): return execution def _validate_workflow_exists_for_service(self): - if self._workflow_name not in self._service.workflows and \ + if self._workflow_name not in self.service.workflows and \ self._workflow_name not in BUILTIN_WORKFLOWS: raise AriaException('No workflow policy {0} declared in service instance {1}' - .format(self._workflow_name, self._service.name)) + .format(self._workflow_name, self.service.name)) def _validate_no_active_executions(self): - active_executions_filter = dict(service=self._service, + active_executions_filter = dict(service=self.service, status=models.Execution.ACTIVE_STATES) active_executions = self._model_storage.execution.list(filter=active_executions_filter) if active_executions: raise AriaException("Can't start execution; Service {0} has a running " "execution with id {1}" - .format(self._service.name, active_executions[0].id)) + .format(self.service.name, active_executions[0].id)) def _get_workflow_fn(self): if self._workflow_name in BUILTIN_WORKFLOWS: return import_fullname('{0}.{1}'.format(BUILTIN_WORKFLOWS_PATH_PREFIX, self._workflow_name)) - workflow = self._service.workflows[self._workflow_name] + workflow = self.service.workflows[self._workflow_name] try: # TODO: perhaps pass to import_fullname as paths instead of appending to sys path?
