Add 'stopped' and 'deleted' states

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

Branch: refs/heads/ARIA-126-update-node-statuses
Commit: 3fe8b06d7ff49e9f8f7e6a954d8dcf7626a235a0
Parents: 5a6d3d8
Author: Avia Efrat <[email protected]>
Authored: Wed Mar 22 18:01:57 2017 +0200
Committer: Avia Efrat <[email protected]>
Committed: Thu Mar 23 11:16:12 2017 +0200

----------------------------------------------------------------------
 aria/modeling/service_instance.py | 30 ++++++++++++++++++++++++++++--
 tests/mock/models.py              |  2 +-
 2 files changed, 29 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3fe8b06d/aria/modeling/service_instance.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_instance.py 
b/aria/modeling/service_instance.py
index 7b82341..f9e8d7b 100644
--- a/aria/modeling/service_instance.py
+++ b/aria/modeling/service_instance.py
@@ -359,17 +359,26 @@ class NodeBase(InstanceModelMixin): # pylint: 
disable=too-many-public-methods
     STARTING = 'starting'
     STARTED = 'started'
     STOPPING = 'stopping'
+    STOPPED = 'stopped'
     DELETING = 'deleting'
+    DELETED = 'deleted'
     ERROR = 'error'
 
     STATES = {INITIAL, CREATING, CREATED, CONFIGURING, CONFIGURED, STARTING, 
STARTED, STOPPING,
               DELETING, ERROR}
+    
+    # TODO implement validation method
+    # VALID_TRANSITIONS = {
+    #     INITIALIZED: [CREATING],
+    #     STARTED: END_STATES + [CANCELLING],
+    #     CANCELLING: END_STATES + [FORCE_CANCELLING]
+    # }
 
     _op_to_state = {'create': {'transitional': CREATING, 'finished': CREATED},
                     'configure': {'transitional': CONFIGURING, 'finished': 
CONFIGURED},
                     'start': {'transitional': STARTING, 'finished': STARTED},
-                    'stop': {'transitional': STOPPING},
-                    'delete': {'transitional': DELETING}}
+                    'stop': {'transitional': STOPPING, 'finished': STOPPED},
+                    'delete': {'transitional': DELETING, 'finished': DELETED}}
 
     @classmethod
     def determine_state(cls, op_name, transitional):
@@ -379,6 +388,23 @@ class NodeBase(InstanceModelMixin): # pylint: 
disable=too-many-public-methods
         except AttributeError:
             return None
 
+    # # TODO implement validation method
+    # @orm.validates('state')
+    # def validate_status(self, key, value):
+    #     """Validation function that verifies node state transitions are OK"""
+    #     try:
+    #         current_status = getattr(self, key)
+    #     except AttributeError:
+    #         return
+    #     valid_transitions = self.VALID_TRANSITIONS.get(current_status, [])
+    #     if all([current_status is not None,
+    #             current_status != value,
+    #             value not in valid_transitions]):
+    #         raise ValueError('Cannot change execution status from {current} 
to {new}'.format(
+    #             current=current_status,
+    #             new=value))
+    #     return value
+
     @declared_attr
     def node_template(cls):
         return relationship.many_to_one(cls, 'node_template')

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3fe8b06d/tests/mock/models.py
----------------------------------------------------------------------
diff --git a/tests/mock/models.py b/tests/mock/models.py
index 3695898..9b75aec 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -121,7 +121,7 @@ def create_dependency_node(dependency_node_template, 
service):
         runtime_properties={'ip': '1.1.1.1'},
         version=None,
         node_template=dependency_node_template,
-        state='',
+        state=models.Node.INITIAL,
         scaling_groups=[],
         service=service
     )

Reply via email to