Ian Main
2009-May-29 16:18 UTC
[Ovirt-devel] [PATCH server] Add more debugging to storage tasks
This patch adds more debug calling in storage related tasks. Signed-off-by: Ian Main <imain at redhat.com> --- src/task-omatic/task_storage.rb | 29 ++++++++++++++++++----------- src/task-omatic/taskomatic.rb | 18 +++++++++--------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/task-omatic/task_storage.rb b/src/task-omatic/task_storage.rb index cdc0043..bfffa36 100644 --- a/src/task-omatic/task_storage.rb +++ b/src/task-omatic/task_storage.rb @@ -92,11 +92,12 @@ class LibvirtPool attr_reader :remote_pool - def initialize(type, name = nil) + def initialize(type, name = nil, logger = nil) @remote_pool = nil @build_on_start = true @remote_pool_defined = false @remote_pool_started = false + @logger = logger if name == nil @name = type + "-" + String.random_alphanumeric @@ -124,11 +125,13 @@ class LibvirtPool xml_desc = result.description if self.xmlequal?(Document.new(xml_desc).root) @remote_pool = pool + @logger.debug("Found existing storage pool #{pool.name} on host: #{node.hostname}") break end end if @remote_pool == nil + @logger.debug("Defining new storage pool: #{@xml.to_s} on host: #{node.hostname}") result = node.storagePoolDefineXML(@xml.to_s, :timeout => 60 * 2) raise "Error creating pool: #{result.text}" unless result.status == 0 @remote_pool = session.object(:object_id => result.pool) @@ -137,6 +140,7 @@ class LibvirtPool # we need this because we don't want to "build" LVM pools, which would # destroy existing data if @build_on_start + @logger.debug("Building remote pool #{@remote_pool.name}") result = @remote_pool.build(:timeout => 60 * 2) raise "Error building pool: #{result.text}" unless result.status == 0 end @@ -193,11 +197,11 @@ class LibvirtPool return false end - def self.factory(pool) + def self.factory(pool, logger) if pool[:type] == "IscsiStoragePool" - return IscsiLibvirtPool.new(pool.ip_addr, pool[:target], pool[:port]) + return IscsiLibvirtPool.new(pool.ip_addr, pool[:target], pool[:port], logger) elsif pool[:type] == "NfsStoragePool" - return NFSLibvirtPool.new(pool.ip_addr, pool.export_path) + return NFSLibvirtPool.new(pool.ip_addr, pool.export_path, logger) elsif pool[:type] == "LvmStoragePool" # OK, if this is LVM storage, there are two cases we need to care about: # 1) this is a LUN with LVM already on it. In this case, all we need to @@ -212,7 +216,7 @@ class LibvirtPool phys_volume = StorageVolume.find(:first, :conditions => [ "lvm_pool_id = ?", pool.id]) return LVMLibvirtPool.new(pool.vg_name, phys_volume.path, - pool.state == StoragePool::STATE_PENDING_SETUP) + pool.state == StoragePool::STATE_PENDING_SETUP, logger) else raise "Unknown storage pool type " + pool[:type].to_s end @@ -220,9 +224,9 @@ class LibvirtPool end class IscsiLibvirtPool < LibvirtPool - def initialize(ip_addr, target, port) + def initialize(ip_addr, target, port, logger) mount = "#{ip_addr}-#{target}-#{port}" - super('iscsi', mount) + super('iscsi', mount, logger) @type = 'iscsi' @ipaddr = ip_addr @@ -242,9 +246,9 @@ class IscsiLibvirtPool < LibvirtPool end class NFSLibvirtPool < LibvirtPool - def initialize(ip_addr, export_path) + def initialize(ip_addr, export_path, logger) target = "#{ip_addr}-#{export_path.tr('/', '_')}" - super('netfs', target) + super('netfs', target, logger) @type = 'netfs' @host = ip_addr @@ -276,6 +280,7 @@ class NFSLibvirtPool < LibvirtPool # however. We want to have non-sparse files for performance reasons. @vol_xml.root.add_element("allocation").add_text('0') + @logger.debug("Creating new volume on pool #{@remote_pool.name} - XML: #{@vol_xml.to_s}") result = @remote_pool.createVolumeXML(@vol_xml.to_s) raise "Error creating remote pool: #{result.text}" unless result.status == 0 return result.volume @@ -289,8 +294,8 @@ class NFSLibvirtPool < LibvirtPool end class LVMLibvirtPool < LibvirtPool - def initialize(vg_name, device, build_on_start) - super('logical', vg_name) + def initialize(vg_name, device, build_on_start, logger) + super('logical', vg_name, logger) @type = 'logical' @build_on_start = build_on_start @@ -302,6 +307,8 @@ class LVMLibvirtPool < LibvirtPool def create_vol(name, size, owner, group, mode) super("logical", name, size, owner, group, mode) + + @logger.debug("Creating new volume on pool #{@remote_pool.name} - XML: #{@vol_xml.to_s}") result = @remote_pool.createVolumeXML(@vol_xml.to_s) raise "Error creating remote pool: #{result.text}" unless result.status == 0 return result.volume diff --git a/src/task-omatic/taskomatic.rb b/src/task-omatic/taskomatic.rb index da933bf..11d13cb 100755 --- a/src/task-omatic/taskomatic.rb +++ b/src/task-omatic/taskomatic.rb @@ -207,7 +207,7 @@ class TaskOmatic end @logger.debug "Verifying mount of pool #{db_pool.ip_addr}:#{db_pool.type}:#{db_pool.target}:#{db_pool.export_path}" - libvirt_pool = LibvirtPool.factory(db_pool) + libvirt_pool = LibvirtPool.factory(db_pool, @logger) libvirt_pool.connect(@session, node) # OK, the pool should be all set. The last thing we need to do is get @@ -631,7 +631,7 @@ class TaskOmatic begin @logger.info("refresh being done on node #{node.hostname}") - phys_libvirt_pool = LibvirtPool.factory(db_pool_phys) + phys_libvirt_pool = LibvirtPool.factory(db_pool_phys, @logger) phys_libvirt_pool.connect(@session, node) db_pool_phys.state = StoragePool::STATE_AVAILABLE db_pool_phys.save! @@ -651,14 +651,14 @@ class TaskOmatic if not existing_vol add_volume_to_db(db_pool_phys, volume); else - @logger.info "Scanned volume #{volume.name} already exists in db.." + @logger.debug "Scanned volume #{volume.name} already exists in db.." end # Now check for an LVM pool carving up this volume. lvm_name = volume.childLVMName next if lvm_name == '' - @logger.info "Child LVM exists for this volume - #{lvm_name}" + @logger.debug "Child LVM exists for this volume - #{lvm_name}" lvm_db_pool = LvmStoragePool.find(:first, :conditions => [ "vg_name = ?", lvm_name ]) if lvm_db_pool == nil @@ -683,7 +683,7 @@ class TaskOmatic physical_vol.lvm_pool_id = lvm_db_pool.id physical_vol.save! - lvm_libvirt_pool = LibvirtPool.factory(lvm_db_pool) + lvm_libvirt_pool = LibvirtPool.factory(lvm_db_pool, @logger) lvm_libvirt_pool.connect(@session, node) lvm_volumes = @session.objects(:class => 'volume', @@ -725,7 +725,7 @@ class TaskOmatic end begin - libvirt_pool = LibvirtPool.factory(db_pool) + libvirt_pool = LibvirtPool.factory(db_pool, @logger) begin libvirt_pool.connect(@session, node) @@ -733,9 +733,9 @@ class TaskOmatic volume = @session.object(:object_id => volume_id) raise "Unable to find newly created volume" unless volume - @logger.info " volume:" + @logger.debug " volume:" for (key, val) in volume.properties - @logger.info " property: #{key}, #{val}" + @logger.debug " property: #{key}, #{val}" end # FIXME: Should have this too I think.. @@ -790,7 +790,7 @@ class TaskOmatic end begin - libvirt_pool = LibvirtPool.factory(db_pool) + libvirt_pool = LibvirtPool.factory(db_pool, @logger) libvirt_pool.connect(@session, node) begin -- 1.6.0.6
Maybe Matching Threads
- [PATCH 1/5 ovirt-server] Add glusterfs to task-omatic API for {task_storage,utils}
- [PATCH server] Remove ununsed utils.rb file.
- [PATCH server] Use fixed mount points and add timeouts to various calls.
- [PATCH server] Use qpid for migration and add more debugging to taskomatic.
- [TAKE-2][PATCH 1/5] Add glusterfs to task-omatic API for task_storage