Ian Main
2009-Apr-30 23:17 UTC
[Ovirt-devel] [PATCH server] Call refresh() on pools whenever we use them.
This patch calls the refresh method (recently added to libvirt-qpid) on
the storage pool every time we 'connect' to one, or whenever we create
a new volume on one.
This requires the newest libvirt (0.2.14-0) which is now in the ovirt
repository and will be pushed into fedora soon.
Signed-off-by: Ian Main <imain at redhat.com>
---
src/task-omatic/task_storage.rb | 7 +++++++
src/task-omatic/taskomatic.rb | 14 +++++++++++++-
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/src/task-omatic/task_storage.rb b/src/task-omatic/task_storage.rb
index afc8964..a2188d7 100644
--- a/src/task-omatic/task_storage.rb
+++ b/src/task-omatic/task_storage.rb
@@ -159,6 +159,13 @@ class LibvirtPool
@remote_pool_started = true
end
+
+ # Refresh the remote pool requesting that it rescan its volumes. Putting
+ # it here means it will call this every time we connect to a pool from
+ # taskomatic. This includes when starting a VM which is probably the most
+ # important time.
+ result = @remote_pool.refresh
+ puts "Error refreshing storage pool: #{result.text}" unless
result.status == 0
end
def create_vol(type, name, size, owner, group, mode)
diff --git a/src/task-omatic/taskomatic.rb b/src/task-omatic/taskomatic.rb
index c651f1a..22c3599 100755
--- a/src/task-omatic/taskomatic.rb
+++ b/src/task-omatic/taskomatic.rb
@@ -677,7 +677,7 @@ class TaskOmatic
if not existing_vol
add_volume_to_db(lvm_db_pool, lvm_volume, "0744",
"0744", "0744");
else
- @logger.error "volume #{lvm_volume.name} already exists in
db.."
+ @logger.info "volume #{lvm_volume.name} already exists in
db.."
end
end
end
@@ -737,6 +737,18 @@ class TaskOmatic
end
end
end
+
+ # Now that we created a new volume, we need to refresh
+ # the storage pools to ensure that they pick up the changes.
+ # I currently refresh ALL storage pools at this time as it
+ # shouldn't be a long operation and it doesn't hurt to refresh
+ # them once in a while.
+ pools = @session.objects(:class => 'pool')
+ pools.each do |pool|
+ result = pool.refresh
+ @logger.info "Problem refreshing pool (you can probably ignore
this): #{result.text}" unless result.status == 0
+ end
+
end
def task_delete_volume(task)
--
1.6.0.6
Ian Main
2009-Apr-30 23:41 UTC
[Ovirt-devel] Re: [PATCH server] Call refresh() on pools whenever we use them.
On Thu, 30 Apr 2009 16:17:38 -0700 Ian Main <imain at redhat.com> wrote:> This patch calls the refresh method (recently added to libvirt-qpid) on > the storage pool every time we 'connect' to one, or whenever we create > a new volume on one. > > This requires the newest libvirt (0.2.14-0) which is now in the ovirt > repository and will be pushed into fedora soon. > > Signed-off-by: Ian Main <imain at redhat.com>I'm not going to be around tomorrow, but I was hoping Mike could try this out and see if it fixes his volumes-out-of-sync issues. I know the call is made ok and the volumes should get automatically synced up in terms of libvirt-qpid so this should fix it nicely. The packages were just pushed out to fedora so they should be in soon. I uploaded them to the ovirt repo in the interim. Ian