David Lutterkort
2009-Jan-07 01:07 UTC
[Ovirt-devel] [PATCH server] Rake task to generate a dot drawing of the possible VM states
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 2001From: 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>
Hugh O. Brock
2009-Jan-07 14:40 UTC
[Ovirt-devel] [PATCH server] Rake task to generate a dot drawing of the possible VM states
On Tue, Jan 06, 2009 at 05:07:20PM -0800, David Lutterkort wrote:> 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 >A flying spaghetti monster! Awesome! --Hugh
Ian Main
2009-Jan-07 23:53 UTC
[Ovirt-devel] [PATCH server] Rake task to generate a dot drawing of the possible VM states
On Tue, 06 Jan 2009 17:07:20 -0800 David Lutterkort <lutter at redhat.com> wrote:> 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. > > DavidWow, that's pretty neat! Pretty graph. I must say however that these states don't really reflect the states provided by libvirt. Libvirt has no sense of intermediate states like 'starting', 'migrating' etc. There's also no distinction regarding 'saved' state vs stopped. 'saved' is merely a stopped vm that has had an image taken of it. I know the 'starting' etc. is mostly for user feedback and also to prevent race conditions where you can try to start a vm multiple times. However while testing the taskomatic changes I was able to queue 5 or so 'start_vm' tasks just because the UI was slow to update (I kept pressing the button and it lagged but queued them all). So anyway, I'm not sure about these intermediate states, and the 'saved' state is actually broken.. something we'll have to remember to fix. The intermediate states present a problem in that you can get out of sync with what db-omatic and even taskomatic know the real libvirt state to be if you are not careful. Ian