diff --git a/lib/fog/libvirt/models/compute/README.md b/lib/fog/libvirt/models/compute/README.md
index e681b73..208b144 100644
--- a/lib/fog/libvirt/models/compute/README.md
+++ b/lib/fog/libvirt/models/compute/README.md
@@ -26,6 +26,19 @@ Only ssh is supported as the transport for remote URI's. TLS is NOT supported, a
- To check the connection you need to override your libvirt socket location in the URI
- "qemu+ssh://patrick@myserver/system?socket=/var/run/libvirt/libvirt-sock"
+## Ceph RBD volumes
+To configure Ceph RBD volumes, the file ``/etc/foreman/ceph.conf`` is used.
+After adding the authentication key to a libvirt secret, it can be configured as follows:
+```
+monitor=mon001.example.com,mon002.example.com,mon003.example.com
+port=6789
+libvirt_ceph_pool=rbd_pool_name
+auth_username=libvirt
+auth_uuid=uuid_of_libvirt_secret
+```
+For more recent versions of libvirt which support using the secret by name (`usage` attribute in the `secret` tag),
+you can also drop `auth_uuid` and specify `auth_usage` instead. If both are specified, `auth_uuid` will be preferred for maximum compatibility.
+
## Configuration
The URI can be configured in two ways:
diff --git a/lib/fog/libvirt/models/compute/templates/server.xml.erb b/lib/fog/libvirt/models/compute/templates/server.xml.erb
index df55376..da6c880 100644
--- a/lib/fog/libvirt/models/compute/templates/server.xml.erb
+++ b/lib/fog/libvirt/models/compute/templates/server.xml.erb
@@ -37,13 +37,42 @@
<% end -%>
+<% args = {}
+ if File.file?('/etc/foreman/ceph.conf')
+ File.readlines('/etc/foreman/ceph.conf').each do |line|
+ pair = line.strip.split("=")
+ key = pair[0]
+ value = pair[1]
+ args[key] = value
+ end
+ end
+%>
<% volumes.each do |vol| -%>
+ <% if File.file?('/etc/foreman/ceph.conf') && vol.pool_name.include?(args["libvirt_ceph_pool"]) %>
+
+
+
+
+ <% if args.key?("auth_uuid") -%>
+
+ <% else -%>
+
+ <% end -%>
+
+ ' bus='scsi'/>
+
+ <% else %>
<%# we need to ensure a unique target dev -%>
' bus='virtio'/>
+ <% end %>
<% end -%>
<% if iso_file -%>
diff --git a/lib/fog/libvirt/requests/compute/list_domains.rb b/lib/fog/libvirt/requests/compute/list_domains.rb
index 5e13e5f..0ecd50e 100644
--- a/lib/fog/libvirt/requests/compute/list_domains.rb
+++ b/lib/fog/libvirt/requests/compute/list_domains.rb
@@ -39,7 +39,13 @@ def domain_display xml
end
def domain_volumes xml
- xml_elements(xml, "domain/devices/disk/source", "file")
+ vols_by_file = xml_elements(xml, "domain/devices/disk/source", "file")
+ vols_by_name = xml_elements(xml, "domain/devices/disk/source", "name")
+ vols = []
+ vols_by_file.zip(vols_by_name).each do |by_file,by_name|
+ vols.push(by_file.nil? ? by_name : by_file)
+ end
+ vols
end
def boot_order xml