]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Add a script show all possible state transitions
authorJason Dunsmore <jasondunsmore@gmail.com>
Wed, 21 Aug 2013 20:15:17 +0000 (15:15 -0500)
committerJason Dunsmore <jasondunsmore@gmail.com>
Thu, 22 Aug 2013 16:16:22 +0000 (11:16 -0500)
The output of this script will be useful in documenting all possible
state transitions.

Change-Id: I24e442ce20fe7730c915a77b85014f44075e03fd

tools/state_transitions.py [new file with mode: 0755]

diff --git a/tools/state_transitions.py b/tools/state_transitions.py
new file mode 100755 (executable)
index 0000000..355e319
--- /dev/null
@@ -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)