Last active
July 26, 2017 00:04
-
-
Save yosshy/46b324ddf32198ac35c4bcfc7dad9efd to your computer and use it in GitHub Desktop.
OpenStack Ironic state machine diagram generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from automaton.converters import pydot | |
| from ironic.common import states | |
| def edge_attrs_cb(start_state, on_event, end_state): | |
| edge_attrs = {} | |
| edge_attrs['label'] = on_event.replace("_", " ").strip() | |
| if 'reverted' in on_event: | |
| edge_attrs['fontcolor'] = 'darkorange' | |
| if 'fail' in on_event: | |
| edge_attrs['fontcolor'] = 'red' | |
| if 'success' in on_event: | |
| edge_attrs['fontcolor'] = 'green' | |
| return edge_attrs | |
| k = pydot.convert(states.machine, "ironic tasks", edge_attrs_cb=edge_attrs_cb) | |
| with open("/tmp/ironic_node_state_machine.svg", "w") as f: | |
| f.write(k.create_svg()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment