You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by av...@apache.org on 2017/03/28 09:56:20 UTC

incubator-ariatosca git commit: Add is_active and is_ended methods to the Execution model [Forced Update!]

Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-133-add-is-active-and-is-ended-to-execution-model a5ae00221 -> 5699aba1d (forced update)


Add is_active and is_ended methods to the Execution model

We are adding these methods so it will be easier to filter executions
from the storage according to their status, and to not make use of the
`status` constants outside of the Execution model.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/5699aba1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/5699aba1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/5699aba1

Branch: refs/heads/ARIA-133-add-is-active-and-is-ended-to-execution-model
Commit: 5699aba1d803f18aa49089caf0ff48e436d3c811
Parents: 07cbfcd
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Tue Mar 28 12:51:42 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Tue Mar 28 12:55:56 2017 +0300

----------------------------------------------------------------------
 aria/modeling/orchestration.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/5699aba1/aria/modeling/orchestration.py
----------------------------------------------------------------------
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index 2d58671..fe65a94 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -69,7 +69,6 @@ class ExecutionBase(ModelMixin):
 
     STATES = [TERMINATED, FAILED, CANCELLED, PENDING, STARTED, CANCELLING, FORCE_CANCELLING]
     END_STATES = [TERMINATED, FAILED, CANCELLED]
-    ACTIVE_STATES = [state for state in STATES if state not in END_STATES]
 
     VALID_TRANSITIONS = {
         PENDING: [STARTED, CANCELLED],
@@ -102,6 +101,12 @@ class ExecutionBase(ModelMixin):
     status = Column(Enum(*STATES, name='execution_status'), default=PENDING)
     workflow_name = Column(Text)
 
+    def is_ended(self):
+        return self.status in self.END_STATES
+
+    def is_active(self):
+        return not self.is_ended()
+
     @declared_attr
     def service(cls):
         return relationship.many_to_one(cls, 'service')