diff --git a/mistral/api/controllers/v2/execution.py b/mistral/api/controllers/v2/execution.py index 387b07829..347bb096c 100644 --- a/mistral/api/controllers/v2/execution.py +++ b/mistral/api/controllers/v2/execution.py @@ -3,6 +3,7 @@ # Copyright 2015 Huawei Technologies Co., Ltd. # Copyright 2016 - Brocade Communications Systems, Inc. # Copyright 2018 - Extreme Networks, Inc. +# Copyright 2019 - NetCracker Technology Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -331,15 +332,18 @@ class ExecutionsController(rest.RestController): @rest_utils.wrap_wsme_controller_exception @wsme_pecan.wsexpose(resources.Executions, types.uuid, int, types.uniquelist, types.list, types.uniquelist, - wtypes.text, types.uuid, wtypes.text, types.jsontype, - types.uuid, types.uuid, STATE_TYPES, wtypes.text, + wtypes.text, types.uuid, wtypes.text, + types.uniquelist, types.jsontype, types.uuid, + types.uuid, STATE_TYPES, wtypes.text, types.jsontype, types.jsontype, wtypes.text, - wtypes.text, bool, types.uuid, bool, types.list) - def get_all(self, marker=None, limit=None, sort_keys='created_at', - sort_dirs='asc', fields='', workflow_name=None, - workflow_id=None, description=None, params=None, - task_execution_id=None, root_execution_id=None, state=None, - state_info=None, input=None, output=None, created_at=None, + wtypes.text, bool, types.uuid, + bool, types.list) + def get_all(self, marker=None, limit=None, + sort_keys='created_at', sort_dirs='asc', fields='', + workflow_name=None, workflow_id=None, description=None, + tags=None, params=None, task_execution_id=None, + root_execution_id=None, state=None, state_info=None, + input=None, output=None, created_at=None, updated_at=None, include_output=None, project_id=None, all_projects=False, nulls=''): @@ -365,6 +369,7 @@ class ExecutionsController(rest.RestController): workflow ID. :param description: Optional. Keep only resources with a specific description. + :param tags: Optional. Keep only resources containing specific tags. :param params: Optional. Keep only resources with specific parameters. :param task_execution_id: Optional. Keep only resources with a specific task execution ID. @@ -400,6 +405,7 @@ class ExecutionsController(rest.RestController): created_at=created_at, workflow_name=workflow_name, workflow_id=workflow_id, + tags=tags, params=params, task_execution_id=task_execution_id, state=state, diff --git a/mistral/api/controllers/v2/resources.py b/mistral/api/controllers/v2/resources.py index f26794323..df6b0ac33 100644 --- a/mistral/api/controllers/v2/resources.py +++ b/mistral/api/controllers/v2/resources.py @@ -1,5 +1,6 @@ # Copyright 2013 - Mirantis, Inc. # Copyright 2018 - Extreme Networks, Inc. +# Copyright 2019 - NetCracker Technology Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -271,6 +272,9 @@ class Execution(resource.Resource): description = wtypes.text "description of workflow execution" + tags = [wtypes.text] + "tags of workflow execution" + params = types.jsontype """'params' define workflow type specific parameters. Specific parameters are: @@ -324,6 +328,7 @@ class Execution(resource.Resource): workflow_namespace='some_namespace', workflow_id='123e4567-e89b-12d3-a456-426655441111', description='this is the first execution.', + tags=['simple', 'amazing'], project_id='40a908dbddfe48ad80a87fb30fa70a03', state='SUCCESS', input={}, @@ -389,6 +394,8 @@ class Task(resource.Resource): workflow_id = wtypes.text workflow_execution_id = wtypes.text + tags = [wtypes.text] + state = wtypes.text """state can take one of the following values: IDLE, RUNNING, SUCCESS, ERROR, DELAYED""" @@ -423,6 +430,7 @@ class Task(resource.Resource): workflow_name='flow', workflow_id='123e4567-e89b-12d3-a456-426655441111', workflow_execution_id='123e4567-e89b-12d3-a456-426655440000', + tags=['long', 'security'], name='task', state=states.SUCCESS, project_id='40a908dbddfe48ad80a87fb30fa70a03', diff --git a/mistral/api/controllers/v2/task.py b/mistral/api/controllers/v2/task.py index 2e75672a4..28157b118 100644 --- a/mistral/api/controllers/v2/task.py +++ b/mistral/api/controllers/v2/task.py @@ -1,5 +1,6 @@ # Copyright 2013 - Mirantis, Inc. # Copyright 2015 - StackStorm, Inc. +# Copyright 2019 - NetCracker Technology Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -114,14 +115,16 @@ class TaskExecutionsController(rest.RestController): @rest_utils.wrap_wsme_controller_exception @wsme_pecan.wsexpose(resources.Executions, types.uuid, types.uuid, int, types.uniquelist, types.list, types.uniquelist, - wtypes.text, types.uuid, wtypes.text, types.jsontype, - STATE_TYPES, wtypes.text, types.jsontype, - types.jsontype, wtypes.text, wtypes.text) + wtypes.text, types.uuid, wtypes.text, + types.uniquelist, types.jsontype, STATE_TYPES, + wtypes.text, types.jsontype, types.jsontype, + wtypes.text, wtypes.text) def get_all(self, task_execution_id, marker=None, limit=None, sort_keys='created_at', sort_dirs='asc', fields='', workflow_name=None, workflow_id=None, description=None, - params=None, state=None, state_info=None, input=None, - output=None, created_at=None, updated_at=None): + tags=None, params=None, state=None, + state_info=None, input=None, output=None, + created_at=None, updated_at=None): """Return all executions that belong to the given task execution. :param task_execution_id: Task task execution ID. @@ -145,6 +148,7 @@ class TaskExecutionsController(rest.RestController): workflow ID. :param description: Optional. Keep only resources with a specific description. + :param tags: Optional. Keep only resources containing specific tags. :param params: Optional. Keep only resources with specific parameters. :param state: Optional. Keep only resources with a specific state. :param state_info: Optional. Keep only resources with specific @@ -163,6 +167,7 @@ class TaskExecutionsController(rest.RestController): created_at=created_at, workflow_name=workflow_name, workflow_id=workflow_id, + tags=tags, params=params, state=state, state_info=state_info, @@ -213,14 +218,18 @@ class TasksController(rest.RestController): @rest_utils.wrap_wsme_controller_exception @wsme_pecan.wsexpose(resources.Tasks, types.uuid, int, types.uniquelist, types.list, types.uniquelist, wtypes.text, - wtypes.text, types.uuid, types.uuid, STATE_TYPES, - wtypes.text, wtypes.text, types.jsontype, bool, - wtypes.text, wtypes.text, bool, types.jsontype) + wtypes.text, types.uuid, + types.uuid, types.uniquelist, STATE_TYPES, + wtypes.text, wtypes.text, types.jsontype, + bool, wtypes.text, wtypes.text, + bool, types.jsontype) def get_all(self, marker=None, limit=None, sort_keys='created_at', - sort_dirs='asc', fields='', name=None, workflow_name=None, - workflow_id=None, workflow_execution_id=None, state=None, - state_info=None, result=None, published=None, processed=None, - created_at=None, updated_at=None, reset=None, env=None): + sort_dirs='asc', fields='', name=None, + workflow_name=None, workflow_id=None, + workflow_execution_id=None, tags=None, state=None, + state_info=None, result=None, published=None, + processed=None, created_at=None, updated_at=None, + reset=None, env=None): """Return all tasks. Where project_id is the same as the requester or @@ -269,6 +278,7 @@ class TasksController(rest.RestController): created_at=created_at, workflow_name=workflow_name, workflow_id=workflow_id, + tags=tags, state=state, state_info=state_info, updated_at=updated_at, @@ -373,13 +383,15 @@ class ExecutionTasksController(rest.RestController): @rest_utils.wrap_wsme_controller_exception @wsme_pecan.wsexpose(resources.Tasks, types.uuid, types.uuid, int, types.uniquelist, types.list, types.uniquelist, - wtypes.text, wtypes.text, types.uuid, STATE_TYPES, - wtypes.text, wtypes.text, types.jsontype, bool, + wtypes.text, wtypes.text, types.uuid, + types.uniquelist, STATE_TYPES, wtypes.text, + wtypes.text, types.jsontype, bool, wtypes.text, wtypes.text, bool, types.jsontype) def get_all(self, workflow_execution_id, marker=None, limit=None, - sort_keys='created_at', sort_dirs='asc', fields='', name=None, - workflow_name=None, workflow_id=None, state=None, - state_info=None, result=None, published=None, processed=None, + sort_keys='created_at', sort_dirs='asc', fields='', + name=None, workflow_name=None, workflow_id=None, + tags=None, state=None, state_info=None, + result=None, published=None, processed=None, created_at=None, updated_at=None, reset=None, env=None): """Return all tasks within the execution. @@ -407,6 +419,7 @@ class ExecutionTasksController(rest.RestController): workflow ID. :param workflow_execution_id: Optional. Keep only resources with a specific workflow execution ID. + :param tags: Optional. Keep only resources containing specific tags. :param state: Optional. Keep only resources with a specific state. :param state_info: Optional. Keep only resources with specific state information. @@ -430,6 +443,7 @@ class ExecutionTasksController(rest.RestController): created_at=created_at, workflow_name=workflow_name, workflow_id=workflow_id, + tags=tags, state=state, state_info=state_info, updated_at=updated_at, diff --git a/mistral/engine/tasks.py b/mistral/engine/tasks.py index ea38b82d1..518c7abec 100644 --- a/mistral/engine/tasks.py +++ b/mistral/engine/tasks.py @@ -1,6 +1,7 @@ # Copyright 2016 - Nokia Networks. # Copyright 2016 - Brocade Communications Systems, Inc. # Copyright 2018 - Extreme Networks, Inc. +# Copyright 2019 - NetCracker Technology Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -403,6 +404,7 @@ class Task(object): task_id = utils.generate_unicode_uuid() task_name = self.task_spec.get_name() task_type = self.task_spec.get_type() + task_tags = self.task_spec.get_tags() values = { 'id': task_id, @@ -411,6 +413,7 @@ class Task(object): 'workflow_name': self.wf_ex.workflow_name, 'workflow_namespace': self.wf_ex.workflow_namespace, 'workflow_id': self.wf_ex.workflow_id, + 'tags': task_tags, 'state': state, 'state_info': state_info, 'spec': self.task_spec.to_dict(), diff --git a/mistral/engine/workflows.py b/mistral/engine/workflows.py index de31e3f35..b6e1defd2 100644 --- a/mistral/engine/workflows.py +++ b/mistral/engine/workflows.py @@ -1,6 +1,7 @@ # Copyright 2016 - Nokia Networks. # Copyright 2016 - Brocade Communications Systems, Inc. # Copyright 2018 - Extreme Networks, Inc. +# Copyright 2019 - NetCracker Technology Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -356,6 +357,7 @@ class Workflow(object): 'id': wf_ex_id, 'name': wf_def.name, 'description': desc, + 'tags': wf_def.tags, 'workflow_name': wf_def.name, 'workflow_namespace': wf_def.namespace, 'workflow_id': wf_def.id, diff --git a/mistral/lang/v2/tasks.py b/mistral/lang/v2/tasks.py index 1dd7c5bd8..a40d37e75 100644 --- a/mistral/lang/v2/tasks.py +++ b/mistral/lang/v2/tasks.py @@ -1,5 +1,6 @@ # Copyright 2014 - Mirantis, Inc. # Copyright 2015 - StackStorm, Inc. +# Copyright 2019 - NetCracker Technology Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -110,6 +111,7 @@ class TaskSpec(base.BaseSpec): self._description = data.get('description') self._action = data.get('action') self._workflow = data.get('workflow') + self._tags = data.get('tags', []) self._input = data.get('input', {}) self._with_items = self._transform_with_items() self._publish = data.get('publish', {}) @@ -223,6 +225,9 @@ class TaskSpec(base.BaseSpec): def get_workflow_name(self): return self._workflow + def get_tags(self): + return self._tags + def get_input(self): return self._input diff --git a/mistral/tests/unit/api/v2/test_tasks.py b/mistral/tests/unit/api/v2/test_tasks.py index ddfcde89b..a14096184 100644 --- a/mistral/tests/unit/api/v2/test_tasks.py +++ b/mistral/tests/unit/api/v2/test_tasks.py @@ -1,5 +1,6 @@ # Copyright 2013 - Mirantis, Inc. # Copyright 2015 - StackStorm, Inc. +# Copyright 2019 - NetCracker Technology Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -109,6 +110,7 @@ TASK = { 'name': 'task', 'workflow_name': 'flow', 'workflow_id': '123e4567-e89b-12d3-a456-426655441111', + 'tags': ['a', 'b'], 'state': 'RUNNING', 'workflow_execution_id': WF_EX.id, 'created_at': '1970-01-01 00:00:00',