diff --git a/lib/fog/libvirt/models/compute/server.rb b/lib/fog/libvirt/models/compute/server.rb
index 0b886f65f..43dd9ccff 100644
--- a/lib/fog/libvirt/models/compute/server.rb
+++ b/lib/fog/libvirt/models/compute/server.rb
@@ -28,6 +28,7 @@ module Fog
attribute :nics
attribute :volumes
attribute :active
+ attribute :boot_order
attribute :state
@@ -46,6 +47,7 @@ module Fog
def initialize(attributes={} )
@xml = attributes.delete(:xml)
+ verify_boot_order(attributes[:boot_order])
super defaults.merge(attributes)
initialize_nics
initialize_volumes
@@ -380,10 +382,23 @@ module Fog
:iso_dir => default_iso_dir,
:network_interface_type => "network",
:network_nat_network => "default",
- :network_bridge_name => "br0"
+ :network_bridge_name => "br0",
+ :boot_order => default_boot_order
}
end
+ def default_boot_order
+ %w[hd cdrom network]
+ end
+
+ def verify_boot_order order = []
+ if order
+ order.each do |b|
+ raise "invalid boot order, possible values are: hd, network and/or cdrom" unless default_boot_order.include?(b)
+ end
+ end
+ end
+
end
end
diff --git a/lib/fog/libvirt/models/compute/templates/server.xml.erb b/lib/fog/libvirt/models/compute/templates/server.xml.erb
index 3123b80bc..7350c5e48 100644
--- a/lib/fog/libvirt/models/compute/templates/server.xml.erb
+++ b/lib/fog/libvirt/models/compute/templates/server.xml.erb
@@ -4,9 +4,8 @@
<%= cpus %>
<%= os_type %>
-
-<% if iso_file -%>
-
+<% boot_order.each do |dev| -%>
+
<% end -%>
diff --git a/lib/fog/libvirt/requests/compute/list_domains.rb b/lib/fog/libvirt/requests/compute/list_domains.rb
index f54b4f54d..2b7991207 100644
--- a/lib/fog/libvirt/requests/compute/list_domains.rb
+++ b/lib/fog/libvirt/requests/compute/list_domains.rb
@@ -29,6 +29,10 @@ module Fog
xml_elements(xml, "domain/devices/disk/source", "file")
end
+ def boot_order xml
+ xml_elements(xml, "domain/os/boot", "dev")
+ end
+
def domain_interfaces xml
ifs = xml_elements(xml, "domain/devices/interface")
ifs.map { |i|
@@ -56,6 +60,7 @@ module Fog
:os_type => dom.os_type,
:active => dom.active?,
:vnc_port => vnc_port(dom.xml_desc),
+ :boot_order => boot_order(dom.xml_desc),
:nics => domain_interfaces(dom.xml_desc),
:volumes_path => domain_volumes(dom.xml_desc),
:state => states[dom.info.state]