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/719ad742 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/719ad742 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/719ad742 Branch: refs/heads/ARIA-126-update-node-statuses Commit: 719ad7428801c12a749b0a169027ac672d941aec Parents: e8e760a Author: Avia Efrat <[email protected]> Authored: Wed Mar 22 18:01:57 2017 +0200 Committer: Avia Efrat <[email protected]> Committed: Sun Mar 26 12:25:33 2017 +0300 ---------------------------------------------------------------------- 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/719ad742/aria/modeling/service_instance.py ---------------------------------------------------------------------- diff --git a/aria/modeling/service_instance.py b/aria/modeling/service_instance.py index b38d214..bd69f2e 100644 --- a/aria/modeling/service_instance.py +++ b/aria/modeling/service_instance.py @@ -357,17 +357,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): @@ -377,6 +386,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/719ad742/tests/mock/models.py ---------------------------------------------------------------------- diff --git a/tests/mock/models.py b/tests/mock/models.py index 6e8eae4..9ae2815 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 )
