mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
use nokogiri for snapshot xml
This commit is contained in:
parent
e5635f2da2
commit
a1e06dda0a
@ -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
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user