diff options
Diffstat (limited to 'cucumber/features/support/helpers/storage_helper.rb')
-rw-r--r-- | cucumber/features/support/helpers/storage_helper.rb | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/cucumber/features/support/helpers/storage_helper.rb b/cucumber/features/support/helpers/storage_helper.rb index de782eed..3bbdb69c 100644 --- a/cucumber/features/support/helpers/storage_helper.rb +++ b/cucumber/features/support/helpers/storage_helper.rb @@ -25,7 +25,8 @@ class VMStorage rescue Libvirt::RetrieveError @pool = nil end - if @pool and not(KEEP_SNAPSHOTS) + if @pool and (not(KEEP_SNAPSHOTS) or + (KEEP_SNAPSHOTS and not(Dir.exists?(@pool_path)))) VMStorage.clear_storage_pool(@pool) @pool = nil end @@ -79,6 +80,10 @@ class VMStorage VMStorage.clear_storage_pool_volumes(@pool) end + def list_volumes + @pool.list_volumes + end + def delete_volume(name) @pool.lookup_volume_by_name(name).delete end @@ -144,13 +149,7 @@ class VMStorage end def disk_mklabel(name, parttype) - disk = { - :path => disk_path(name), - :opts => { - :format => disk_format(name) - } - } - guestfs_disk_helper(disk) do |g, disk_handle| + guestfs_disk_helper(name) do |g, disk_handle| g.part_init(disk_handle, parttype) end end @@ -158,13 +157,7 @@ class VMStorage def disk_mkpartfs(name, parttype, fstype, opts = {}) opts[:label] ||= nil opts[:luks_password] ||= nil - disk = { - :path => disk_path(name), - :opts => { - :format => disk_format(name) - } - } - guestfs_disk_helper(disk) do |g, disk_handle| + guestfs_disk_helper(name) do |g, disk_handle| g.part_disk(disk_handle, parttype) g.part_set_name(disk_handle, 1, opts[:label]) if opts[:label] primary_partition = g.list_partitions()[0] @@ -182,13 +175,7 @@ class VMStorage end def disk_mkswap(name, parttype) - disk = { - :path => disk_path(name), - :opts => { - :format => disk_format(name) - } - } - guestfs_disk_helper(disk) do |g, disk_handle| + guestfs_disk_helper(name) do |g, disk_handle| g.part_disk(disk_handle, parttype) primary_partition = g.list_partitions()[0] g.mkswap(primary_partition) @@ -206,7 +193,13 @@ class VMStorage Guestfs::EVENT_TRACE) g.set_autosync(1) disks.each do |disk| - g.add_drive_opts(disk[:path], disk[:opts]) + if disk.class == String + g.add_drive_opts(disk_path(disk), format: disk_format(disk)) + elsif disk.class == Hash + g.add_drive_opts(disk[:path], disk[:opts]) + else + raise "cannot handle type '#{disk.class}'" + end end g.launch() yield(g, *g.list_devices()) |