[Ovirt-devel] [PATCH server] Call refresh() on pools whenever we use them.

Ian Main imain at redhat.com
Thu Apr 30 23:17:38 UTC 2009


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




More information about the ovirt-devel mailing list