use nokogiri for snapshot xml

This commit is contained in:
dima 2017-02-11 20:02:20 +01:00
parent e5635f2da2
commit a1e06dda0a
2 changed files with 31 additions and 27 deletions

View File

@ -41,8 +41,38 @@ module VagrantPlugins
# Create new volume from xml template. Fog currently doesn't support
# volume snapshots directly.
begin
xml = Nokogiri::XML::Builder.new do |xml|
xml.volume do
xml.name @name
xml.capacity(unit: 'G') @capacity
xml.target do
xml.format(type: 'qcow2')
xml.permissions do
xml.owner 0
xml.group 0
xml.mode '0600'
xml.label 'virt_image_t'
end
end
xml.backingStore do
xml.path @backing_file
xml.format(type: 'qcow2')
xml.permissions do
xml.owner 0
xml.group 0
xml.mode '0600'
xml.label 'virt_image_t'
end
end
end
end.to_xml(
save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION |
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
Nokogiri::XML::Node::SaveOptions::FORMAT
)
domain_volume = env[:machine].provider.driver.connection.volumes.create(
xml: to_xml('volume_snapshot'),
xml: xml,
pool_name: config.storage_pool_name
)
rescue Fog::Errors::Error => e

View File

@ -1,26 +0,0 @@
<volume>
<name><%= @name %></name>
<capacity unit="G"><%= @capacity %></capacity>
<target>
<format type='qcow2'/>
<permissions>
<owner>0</owner>
<group>0</group>
<mode>0600</mode>
<label>virt_image_t</label>
</permissions>
</target>
<backingStore>
<path><%= @backing_file %></path>
<format type='qcow2'/>
<permissions>
<owner>0</owner>
<group>0</group>
<mode>0600</mode>
<label>virt_image_t</label>
</permissions>
</backingStore>
</volume>