[Ovirt-devel] [PATCH server] Mark vms as 'stopped' after node reboot.

Ian Main imain at redhat.com
Fri Mar 6 21:12:29 UTC 2009


This patch marks vms as 'stopped' when a node comes back online via
qpid.  This lets any VMs that were previously unreachable useable again
in the WUI.  If it turns out the VMs are still running, dbomatic will
mark them as running when it sees the vm object again.

Signed-off-by: Ian Main <imain at redhat.com>
---
 src/db-omatic/db_omatic.rb |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/db-omatic/db_omatic.rb b/src/db-omatic/db_omatic.rb
index 8e62f54..4c8d60e 100755
--- a/src/db-omatic/db_omatic.rb
+++ b/src/db-omatic/db_omatic.rb
@@ -164,6 +164,22 @@ class DbOmatic < Qpid::Qmf::Console
             #db_host.is_disabled = 0
             db_host.save
             host_info[:synced] = true
+
+            if state == Host::STATE_AVAILABLE
+                # At this point we want to set all domains that are
+                # unreachable to stopped.  If a domain is indeed running
+                # then dbomatic will see that and set it either before
+                # or after.  If the node was rebooted, the VMs will all
+                # be gone and dbomatic won't see them so we need to set
+                # them to stopped.
+                db_vm = Vm.find(:all, :conditions => ["host_id = ? AND state = ?", db_host.id, Vm::STATE_UNREACHABLE])
+                db_vm.each do |vm|
+                    @logger.info "Moving vm #{vm.description} in state #{vm.state} to state stopped."
+                    vm.state = Vm::STATE_STOPPED
+                    vm.save!
+                end
+            end
+
         else
             # FIXME: This would be a newly registered host.  We could put it in the database.
             @logger.info "Unknown host #{host_info['hostname']}, probably not registered yet??"
-- 
1.6.0.6




More information about the ovirt-devel mailing list