Arjun Roy
2009-Aug-07 21:16 UTC
[Ovirt-devel] [PATCH server] Fixed db-omatic to update the host for a running vm when the object_props callback is fired.
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
Jason Guiditta
2009-Aug-10 15:28 UTC
[Ovirt-devel] [PATCH server] Fixed db-omatic to update the host for a running vm when the object_props callback is fired.
On Fri, 2009-08-07 at 17:16 -0400, Arjun Roy wrote:> 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(-) >ACK, I can now restart dbomatic with a running vm, and the vm remains associated with the correct node. -j
Maybe Matching Threads
- [PATCH server] Replace the occurence of the type @qmfc.object(Qmf::Query.new(:class => "xxx", 'key' => search_key)) for @qmfc.object(Qmf::Query.new(:class => "xxx"), 'key' => search_key) else the search on the key is not functionnal.
- [PATCH server] Fixed db-omatic so it doesn't die due to an unhandled ActiveRecord::StaleObjectError exception.
- [PATCH server] Update daemons to use new QMF.
- [PATCH server] Fixed db-omatic so it doesn't die due to unhandled exceptions related to saving db objects in update_host_state and update_domain_state.
- [PATCH] Fix dbomatic state changes.