Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/fog/libvirt/models/compute/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,9 @@ def to_xml
else
is_block = volume.path.start_with?("/dev/")
xml.disk(:type => is_block ? "block" : "file", :device => "disk") do
xml.driver(:name => "qemu", :type => volume.format_type)
driver = xml.driver(:name => "qemu")
driver[:type] = volume.format_type if volume.format_type

if is_block
xml.source(:dev => volume.path)
else
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/libvirt/models/compute/volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def to_xml
xml.capacity(capacity_size, :unit => capacity_unit)

xml.target do
xml.format(:type => format_type)
xml.format(:type => format_type) if format_type
xml_permissions(xml)
end

Expand Down
34 changes: 34 additions & 0 deletions tests/libvirt/models/compute/server_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,39 @@

os_firmware && secure_boot && enrolled_keys && loader_attributes
end

test("with volumes") do
pool = Fog::Compute[:libvirt].pools.create(
:persistent => true,
:xml => <<~XML
<pool type='logical'>
<name>lvm-pool</name>
<source>
<name>vg_storage01</name>
<format type='lvm2'/>
</source>
<target>
<path>/dev/vg_storage01</path>
</target>
</pool>
XML
)
server = Fog::Compute[:libvirt].servers.new(
:nics => [],
:volumes => [
{
:path => "/dev/vg_storage01/volume01",
:pool_name => pool.name
}
]
)
server.volumes.each do |volume|
volume.save
# mock driver doesn't simulate the real thing
# LVM doesn't have a volume type
volume.format_type = nil
end
!server.save.nil?
end
end
end
Loading