[Ovirt-devel] [PATCH server] Rake task to generate a dot drawing of the possible VM states
David Lutterkort
lutter at redhat.com
Wed Jan 7 01:07:20 UTC 2009
I was curious what all the VM state transitions taken together look like
- below is a rake task that generates a dot drawing of the FSM of VM
states.
Attached is a picture of all that for everybody's amusement.
David
>From 08d72ae336afedcfa0dac9a57e5a79a2b6effac8 Mon Sep 17 00:00:00 2001
From: David Lutterkort <lutter at redhat.com>
Date: Tue, 6 Jan 2009 16:54:31 -0800
Subject: [PATCH server] Rake task to generate a dot drawing of the possible VM states
---
src/lib/tasks/vm-states-dot.rake | 40 ++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
create mode 100644 src/lib/tasks/vm-states-dot.rake
diff --git a/src/lib/tasks/vm-states-dot.rake b/src/lib/tasks/vm-states-dot.rake
new file mode 100644
index 0000000..74f1f8e
--- /dev/null
+++ b/src/lib/tasks/vm-states-dot.rake
@@ -0,0 +1,40 @@
+# -*- ruby -*-
+require 'permission'
+require 'task'
+require 'vm'
+require 'vm_task'
+
+desc "Generate a dot file for VM state transitions (pass output file in\nvariable 'output')"
+task "vm:states:dot" do
+ out = $stdout
+ out = File::open(ENV['output'], 'w') if ENV['output']
+
+ # Classify states
+ states = {}
+ [:start, :running, :success, :failure].each do |tag|
+ VmTask::ACTIONS.values.each { |a|
+ states[a[tag]] ||= []
+ states[a[tag]] << tag
+ }
+ end
+
+ out.puts "digraph \"VM Task Transitions\" {"
+ states.each do |state, tags|
+ out.print " #{state} ["
+ if tags == [:running]
+ out.print("shape=box color=\"#666666\" fontcolor=\"#666666\"")
+ end
+ out.puts "];"
+ end
+ VmTask::ACTIONS.values.each do |a|
+ out.puts "#{a[:start]} -> #{a[:running]} [ label = \"#{a[:label]}\" ];"
+ out.puts "#{a[:running]} -> #{a[:success]} [ color = green ];"
+ out.puts "#{a[:running]} -> #{a[:failure]} [ color= red ];"
+ end
+ out.puts '":running" [shape=box color="#666666" fontcolor="#666666"];'
+ out.puts '":start" -> ":running" [ label = "Action" ];'
+ out.puts '":running" -> ":success" [ color = green ];'
+ out.puts '":running" -> ":failure" [ color= red ];'
+ out.puts "}"
+ out.close
+end
--
1.6.0.6
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fsm.png
Type: image/png
Size: 93683 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20090106/b28232e5/attachment.png>
More information about the ovirt-devel
mailing list