From: Jason Dunsmore Date: Wed, 21 Aug 2013 20:15:17 +0000 (-0500) Subject: Add a script show all possible state transitions X-Git-Tag: 2014.1~163^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=1f7d5b07d62abd7fd041af3a425d22c5309acc40;p=openstack-build%2Fheat-build.git Add a script show all possible state transitions The output of this script will be useful in documenting all possible state transitions. Change-Id: I24e442ce20fe7730c915a77b85014f44075e03fd --- diff --git a/tools/state_transitions.py b/tools/state_transitions.py new file mode 100755 index 00000000..355e3194 --- /dev/null +++ b/tools/state_transitions.py @@ -0,0 +1,41 @@ +#!/usr/bin/python + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""Generate a list of all possible state transitions. + +Useful as a starting point for documentation. +""" + +from heat.engine import resource + +actions = resource.Resource.ACTIONS +stack_statuses = resource.Resource.STATUSES +engine_statuses = ("Alive", "Dead") + +print """\ +| Orig action | Stack status | Engine status | New action | Behavior | +|-------------+--------------+---------------+------------+------------------|\ +""" + +for orig_action in actions: + for stack_status in stack_statuses: + for new_action in actions: + if stack_status == resource.Resource.IN_PROGRESS: + for engine_status in engine_statuses: + print "| %11s | %12s | %13s | %10s | |" \ + % (orig_action, stack_status, engine_status, + new_action) + else: + print "| %11s | %12s | %13s | %10s | |" \ + % (orig_action, stack_status, "NA", new_action)