[Ovirt-devel] [PATCH server] Fixed db-omatic to update the host for a running vm when the object_props callback is fired.
Arjun Roy
arroy at redhat.com
Fri Aug 7 21:16:08 UTC 2009
This fixes a bug where if db-omatic restarted, any running vm lost the
association with the host it is running on in the db.
---
src/db-omatic/db_omatic.rb | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/db-omatic/db_omatic.rb b/src/db-omatic/db_omatic.rb
index b5b7b81..d2540e1 100755
--- a/src/db-omatic/db_omatic.rb
+++ b/src/db-omatic/db_omatic.rb
@@ -202,7 +202,18 @@ class DbOmatic < Qpid::Qmf::Console
set_vm_stopped(vm)
end
end
+ # If we are running, update the node that the domain is running on
+ elsif state == Vm::STATE_RUNNING
+ @logger.info "VM is running, determine the node it is running on"
+ qmf_vm = @session.object(:class => "domain", 'uuid' => vm.uuid)
+ if qmf_vm
+ qmf_host = @session.object(:class => "node", :object_id => qmf_vm.node)
+ db_host = Host.find(:first, :conditions => ['hostname = ?', qmf_host.hostname])
+ @logger.info "VM #{vm.description} is running on node #{db_host.hostname}"
+ vm.host_id = db_host.id
+ end
end
+
vm.state = state
vm.save!
--
1.6.2.5
More information about the ovirt-devel
mailing list