From b2d5207fbaff36881a28eaf9fcb6b4e5d023af86 Mon Sep 17 00:00:00 2001 From: Patrick Debois Date: Mon, 1 Aug 2011 15:33:25 +0200 Subject: [PATCH] Allow creation of persistent or non persistent volumes --- lib/fog/compute/models/libvirt/volume.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/fog/compute/models/libvirt/volume.rb b/lib/fog/compute/models/libvirt/volume.rb index a5d5ddb4e..5119a09a0 100644 --- a/lib/fog/compute/models/libvirt/volume.rb +++ b/lib/fog/compute/models/libvirt/volume.rb @@ -10,6 +10,7 @@ module Fog attribute :poolname attribute :xml + attribute :create_persistent # Can be created by passing in :xml => "" # A volume always belongs to a pool, :pool => "" @@ -18,6 +19,7 @@ module Fog def initialize(attributes={} ) self.xml ||= nil unless attributes[:xml] self.poolname ||= nil unless attributes[:poolname] + self.create_persistent ||=true unless attribues[:create_persistent] super end @@ -30,7 +32,11 @@ module Fog volume=nil unless poolname.nil? pool=connection.lookup_storage_pool_by_name(poolname) - volume=pool.create_volume_xml(xml) + if create_persistent + volume=pool.define_volume_xml(xml) + else + volume=pool.create_volume_xml(xml) + end self.raw=volume true else