summaryrefslogtreecommitdiffstats
path: root/features/support/helpers/storage_helper.rb
diff options
context:
space:
mode:
authoranonym <anonym@riseup.net>2015-07-15 19:04:32 +0200
committeranonym <anonym@riseup.net>2015-07-16 03:39:23 +0200
commitb3e908cc0ce93aaa4f6ef9761f0000deada94791 (patch)
tree5888da9d832cf956ccc5814a83dc8b9d65b54553 /features/support/helpers/storage_helper.rb
parentbf1bf0df98cd8e26b727f67e1b16b63e2cfebceb (diff)
Reintroduce the --keep-snapshots option.
It turns out that since pools, volumes and snapshots all have unique names, and libvirt can lookup_by_name them, it's pretty easy to recover the storage pool from a previous run and use any old volumes and snapshots in it. That depends on the correct names being used, which works well for us since we use the same ones each test suite run.
Diffstat (limited to 'features/support/helpers/storage_helper.rb')
-rw-r--r--features/support/helpers/storage_helper.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/features/support/helpers/storage_helper.rb b/features/support/helpers/storage_helper.rb
index 9a32db5..65e007b 100644
--- a/features/support/helpers/storage_helper.rb
+++ b/features/support/helpers/storage_helper.rb
@@ -18,18 +18,22 @@ class VMStorage
@xml_path = xml_path
pool_xml = REXML::Document.new(File.read("#{@xml_path}/storage_pool.xml"))
pool_name = pool_xml.elements['pool/name'].text
+ @pool_path = "#{$config["TMPDIR"]}/#{pool_name}"
begin
@pool = @virt.lookup_storage_pool_by_name(pool_name)
rescue Libvirt::RetrieveError
- # There's no pool with that name, so we don't have to clear it
- else
+ @pool = nil
+ end
+ if @pool and not(KEEP_SNAPSHOTS)
VMStorage.clear_storage_pool(@pool)
+ @pool = nil
end
- @pool_path = "#{$config["TMPDIR"]}/#{pool_name}"
- pool_xml.elements['pool/target/path'].text = @pool_path
- @pool = @virt.define_storage_pool_xml(pool_xml.to_s)
- @pool.build unless Dir.exists?(@pool_path)
- @pool.create
+ unless @pool
+ pool_xml.elements['pool/target/path'].text = @pool_path
+ @pool = @virt.define_storage_pool_xml(pool_xml.to_s)
+ @pool.build unless Dir.exists?(@pool_path)
+ end
+ @pool.create unless @pool.active?
@pool.refresh
end