Ian Main
2009-Mar-06 21:12 UTC
[Ovirt-devel] [PATCH server] Mark vms as 'stopped' after node reboot.
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
Ian Main
2009-Mar-07 01:02 UTC
[Ovirt-devel] Re: [PATCH server] Mark vms as 'stopped' after node reboot.
On Fri, 6 Mar 2009 13:12:29 -0800 Ian Main <imain at redhat.com> wrote:> 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>I pushed this. Ian