mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add supports for defining/extracting libvit boot order
This commit is contained in:
parent
9d78d29a19
commit
e983c672d4
3 changed files with 23 additions and 4 deletions
|
@ -28,6 +28,7 @@ module Fog
|
||||||
attribute :nics
|
attribute :nics
|
||||||
attribute :volumes
|
attribute :volumes
|
||||||
attribute :active
|
attribute :active
|
||||||
|
attribute :boot_order
|
||||||
|
|
||||||
attribute :state
|
attribute :state
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ module Fog
|
||||||
|
|
||||||
def initialize(attributes={} )
|
def initialize(attributes={} )
|
||||||
@xml = attributes.delete(:xml)
|
@xml = attributes.delete(:xml)
|
||||||
|
verify_boot_order(attributes[:boot_order])
|
||||||
super defaults.merge(attributes)
|
super defaults.merge(attributes)
|
||||||
initialize_nics
|
initialize_nics
|
||||||
initialize_volumes
|
initialize_volumes
|
||||||
|
@ -380,10 +382,23 @@ module Fog
|
||||||
:iso_dir => default_iso_dir,
|
:iso_dir => default_iso_dir,
|
||||||
:network_interface_type => "network",
|
:network_interface_type => "network",
|
||||||
:network_nat_network => "default",
|
:network_nat_network => "default",
|
||||||
:network_bridge_name => "br0"
|
:network_bridge_name => "br0",
|
||||||
|
:boot_order => default_boot_order
|
||||||
}
|
}
|
||||||
end
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
<vcpu><%= cpus %></vcpu>
|
<vcpu><%= cpus %></vcpu>
|
||||||
<os>
|
<os>
|
||||||
<type arch='<%= arch %>'><%= os_type %></type>
|
<type arch='<%= arch %>'><%= os_type %></type>
|
||||||
<boot dev='hd'/>
|
<% boot_order.each do |dev| -%>
|
||||||
<% if iso_file -%>
|
<boot dev='<%= dev %>'/>
|
||||||
<boot dev='cdrom'/>
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</os>
|
</os>
|
||||||
<features>
|
<features>
|
||||||
|
|
|
@ -29,6 +29,10 @@ module Fog
|
||||||
xml_elements(xml, "domain/devices/disk/source", "file")
|
xml_elements(xml, "domain/devices/disk/source", "file")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def boot_order xml
|
||||||
|
xml_elements(xml, "domain/os/boot", "dev")
|
||||||
|
end
|
||||||
|
|
||||||
def domain_interfaces xml
|
def domain_interfaces xml
|
||||||
ifs = xml_elements(xml, "domain/devices/interface")
|
ifs = xml_elements(xml, "domain/devices/interface")
|
||||||
ifs.map { |i|
|
ifs.map { |i|
|
||||||
|
@ -56,6 +60,7 @@ module Fog
|
||||||
:os_type => dom.os_type,
|
:os_type => dom.os_type,
|
||||||
:active => dom.active?,
|
:active => dom.active?,
|
||||||
:vnc_port => vnc_port(dom.xml_desc),
|
:vnc_port => vnc_port(dom.xml_desc),
|
||||||
|
:boot_order => boot_order(dom.xml_desc),
|
||||||
:nics => domain_interfaces(dom.xml_desc),
|
:nics => domain_interfaces(dom.xml_desc),
|
||||||
:volumes_path => domain_volumes(dom.xml_desc),
|
:volumes_path => domain_volumes(dom.xml_desc),
|
||||||
:state => states[dom.info.state]
|
:state => states[dom.info.state]
|
||||||
|
|
Loading…
Add table
Reference in a new issue