Skip to content

Instantly share code, notes, and snippets.

@yosshy
Last active July 26, 2017 00:04
Show Gist options
  • Select an option

  • Save yosshy/46b324ddf32198ac35c4bcfc7dad9efd to your computer and use it in GitHub Desktop.

Select an option

Save yosshy/46b324ddf32198ac35c4bcfc7dad9efd to your computer and use it in GitHub Desktop.
OpenStack Ironic state machine diagram generator
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())
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment