[Ovirt-devel] [PATCH] Use volume key instead of path to identify volume.
Ian Main
imain at redhat.com
Mon Jul 13 20:45:54 UTC 2009
This patch teaches taskomatic to use the volume 'key' instead of the
path from libvirt to key the volume off of in the database. This fixes
the duplicate iscsi volume bug we were seeing. The issue was that
libvirt changed the way they name storage volumes and included a local
ID that changed each time it was attached.
Note that the first run with this new patch will cause duplicate
volumes because of the key change. Ideally you would delete all storage
pools and readd them after applying this patch.
Signed-off-by: Ian Main <imain at redhat.com>
---
src/task-omatic/taskomatic.rb | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/task-omatic/taskomatic.rb b/src/task-omatic/taskomatic.rb
index b3c0592..6c68397 100755
--- a/src/task-omatic/taskomatic.rb
+++ b/src/task-omatic/taskomatic.rb
@@ -219,7 +219,7 @@ class TaskOmatic
@logger.debug "Pool mounted: #{pool.name}; state: #{pool.state}"
volume = @session.object(:class => 'volume',
- 'name' => volume_name,
+ 'key' => volume_name,
'storagePool' => pool.object_id)
raise "Unable to find volume #{volume_name} attached to pool #{pool.name}." unless volume
@logger.debug "Verified volume of pool #{volume.path}"
@@ -591,7 +591,7 @@ class TaskOmatic
storage_volume.path = volume.path
storage_volume.size = volume.capacity / 1024
storage_volume.storage_pool_id = db_pool.id
- storage_volume.write_attribute(storage_volume.volume_name, volume.name)
+ storage_volume.write_attribute(storage_volume.volume_name, volume.key)
storage_volume.lv_owner_perms = owner
storage_volume.lv_group_perms = group
storage_volume.lv_mode_perms = mode
@@ -644,13 +644,14 @@ class TaskOmatic
existing_vol = StorageVolume.find(:first, :conditions =>
["storage_pool_id = ? AND #{storage_volume.volume_name} = ?",
- db_pool_phys.id, volume.name])
+ db_pool_phys.id, volume.key])
+ puts "Existing volume is #{existing_vol}, searched for storage volume name and #{volume.key}"
# Only add if it's not already there.
if not existing_vol
add_volume_to_db(db_pool_phys, volume);
else
- @logger.debug "Scanned volume #{volume.name} already exists in db.."
+ @logger.debug "Scanned volume #{volume.key} already exists in db.."
end
# Now check for an LVM pool carving up this volume.
@@ -692,11 +693,11 @@ class TaskOmatic
lvm_storage_volume = StorageVolume.factory(lvm_db_pool.get_type_label)
existing_vol = StorageVolume.find(:first, :conditions =>
["storage_pool_id = ? AND #{lvm_storage_volume.volume_name} = ?",
- lvm_db_pool.id, lvm_volume.name])
+ lvm_db_pool.id, lvm_volume.key])
if not existing_vol
add_volume_to_db(lvm_db_pool, lvm_volume, "0744", "0744", "0744");
else
- @logger.info "volume #{lvm_volume.name} already exists in db.."
+ @logger.info "volume #{lvm_volume.key} already exists in db.."
end
end
end
--
1.6.0.6
More information about the ovirt-devel
mailing list