Class: Libvirt::Spec::Domain::OSBooting
- Inherits:
-
Object
- Object
- Libvirt::Spec::Domain::OSBooting
- Includes:
- Util
- Defined in:
- lib/libvirt/spec/domain/os_booting.rb
Overview
The OS booting section of a domain specification indicates to libvirt how to configure the virtual machine to boot. There are three main ways to configure booting. Each hypervisor supports one or more of the following:
- BIOS bootloader
- Host bootloader
- Direct kernel boot
TODO: Host bootloader and direct kernel bootloader options.
Instance Attribute Summary collapse
-
#arch ⇒ Object
Returns the value of attribute arch.
-
#boot ⇒ Object
Returns the value of attribute boot.
-
#bootloader ⇒ Object
Host bootloader configuration options.
-
#bootloader_args ⇒ Object
Returns the value of attribute bootloader_args.
-
#bootmenu_enabled ⇒ Object
Returns the value of attribute bootmenu_enabled.
-
#cmdline ⇒ Object
Returns the value of attribute cmdline.
-
#initrd ⇒ Object
Returns the value of attribute initrd.
-
#kernel ⇒ Object
Direct kernel boot.
-
#loader ⇒ Object
Part of the BIOS bootloader.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(xml = nil) ⇒ OSBooting
constructor
Initializes an OS booting specification.
-
#load!(root) ⇒ Object
Loads the OS booting information from the given XML string.
-
#to_xml(parent = Nokogiri::XML::Builder.new) ⇒ Object
Convert just the OS booting section to its XML representation.
Methods included from Util
Constructor Details
#initialize(xml = nil) ⇒ OSBooting
Initializes an OS booting specification. This shouldn't be called directly since the domain spec automatically loads this.
34 35 36 37 38 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 34 def initialize(xml=nil) @boot = [] load!(xml) if xml end |
Instance Attribute Details
#arch ⇒ Object
Returns the value of attribute arch.
17 18 19 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 17 def arch @arch end |
#boot ⇒ Object
Returns the value of attribute boot.
19 20 21 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 19 def boot @boot end |
#bootloader ⇒ Object
Host bootloader configuration options
23 24 25 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 23 def bootloader @bootloader end |
#bootloader_args ⇒ Object
Returns the value of attribute bootloader_args.
24 25 26 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 24 def bootloader_args @bootloader_args end |
#bootmenu_enabled ⇒ Object
Returns the value of attribute bootmenu_enabled.
20 21 22 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 20 def @bootmenu_enabled end |
#cmdline ⇒ Object
Returns the value of attribute cmdline.
29 30 31 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 29 def cmdline @cmdline end |
#initrd ⇒ Object
Returns the value of attribute initrd.
28 29 30 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 28 def initrd @initrd end |
#kernel ⇒ Object
Direct kernel boot
27 28 29 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 27 def kernel @kernel end |
#loader ⇒ Object
Part of the BIOS bootloader
18 19 20 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 18 def loader @loader end |
#type ⇒ Object
Returns the value of attribute type.
16 17 18 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 16 def type @type end |
Instance Method Details
#load!(root) ⇒ Object
Loads the OS booting information from the given XML string. This shouldn't be called directly, since the domain spec automatically calls this.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 49 def load!(root) root = Nokogiri::XML(root).root if !root.is_a?(Nokogiri::XML::Element) try(root.xpath("//os/type[@arch]"), :preserve => true) { |result| self.arch = result["arch"].to_sym } try(root.xpath("//os/type")) { |result| self.type = result.text.to_sym } try(root.xpath("//os/boot"), :multi => true) do |results| self.boot = [] results.each do |result| self.boot << result["dev"].to_sym end end raise_if_unparseables(root.xpath("//os/*")) end |
#to_xml(parent = Nokogiri::XML::Builder.new) ⇒ Object
Convert just the OS booting section to its XML representation.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/libvirt/spec/domain/os_booting.rb', line 66 def to_xml(parent=Nokogiri::XML::Builder.new) parent.os do |os| # Build the arguments for the OS booting type type_args = [type] type_args << { :arch => arch } if arch # Setup the specification os.type_ *type_args os.loader loader if loader os.(:enable => ? 'yes' : 'no') if !.nil? # Boot order for BIOS booting boot.each { |dev| os.boot :dev => dev } if boot.is_a?(Array) # Host bootloader configuration options os.bootloader bootloader if bootloader os.bootloader_args bootloader_args if bootloader_args # Direct kernel boot options os.kernel kernel if kernel os.initrd initrd if initrd os.cmdline cmdline if cmdline end parent.to_xml end |