Class: Libvirt::Spec::Device::Disk
- Inherits:
-
Object
- Object
- Libvirt::Spec::Device::Disk
- Defined in:
- lib/libvirt/spec/device/disk.rb
Overview
Any device that looks like a disk, be it a floppy, harddisk, cdrom, or paravirtualized driver is specified via the disk element.
Instance Attribute Summary (collapse)
-
- (Object) driver
Returns the value of attribute driver.
-
- (Object) driver_cache
Returns the value of attribute driver_cache.
-
- (Object) driver_type
Returns the value of attribute driver_type.
-
- (Object) serial
Returns the value of attribute serial.
-
- (Object) shareable
Returns the value of attribute shareable.
-
- (Object) source
Returns the value of attribute source.
-
- (Object) target_bus
Returns the value of attribute target_bus.
-
- (Object) target_dev
Returns the value of attribute target_dev.
-
- (Object) type
Returns the value of attribute type.
Instance Method Summary (collapse)
-
- (Disk) initialize(type)
constructor
Initialize a new disk element with the given type.
-
- (Object) to_xml(xml = Nokogiri::XML::Builder.new)
Returns the XML representation of this device.
Constructor Details
- (Disk) initialize(type)
Initialize a new disk element with the given type. Examples
of valid types are "disk," "floppy," and "cdrom."
20 21 22 23 |
# File 'lib/libvirt/spec/device/disk.rb', line 20 def initialize(type) @type = type @shareable = false end |
Instance Attribute Details
- (Object) driver
Returns the value of attribute driver
12 13 14 |
# File 'lib/libvirt/spec/device/disk.rb', line 12 def driver @driver end |
- (Object) driver_cache
Returns the value of attribute driver_cache
14 15 16 |
# File 'lib/libvirt/spec/device/disk.rb', line 14 def driver_cache @driver_cache end |
- (Object) driver_type
Returns the value of attribute driver_type
13 14 15 |
# File 'lib/libvirt/spec/device/disk.rb', line 13 def driver_type @driver_type end |
- (Object) serial
Returns the value of attribute serial
16 17 18 |
# File 'lib/libvirt/spec/device/disk.rb', line 16 def serial @serial end |
Returns the value of attribute shareable
15 16 17 |
# File 'lib/libvirt/spec/device/disk.rb', line 15 def shareable @shareable end |
- (Object) source
Returns the value of attribute source
9 10 11 |
# File 'lib/libvirt/spec/device/disk.rb', line 9 def source @source end |
- (Object) target_bus
Returns the value of attribute target_bus
11 12 13 |
# File 'lib/libvirt/spec/device/disk.rb', line 11 def target_bus @target_bus end |
- (Object) target_dev
Returns the value of attribute target_dev
10 11 12 |
# File 'lib/libvirt/spec/device/disk.rb', line 10 def target_dev @target_dev end |
- (Object) type
Returns the value of attribute type
8 9 10 |
# File 'lib/libvirt/spec/device/disk.rb', line 8 def type @type end |
Instance Method Details
- (Object) to_xml(xml = Nokogiri::XML::Builder.new)
Returns the XML representation of this device.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/libvirt/spec/device/disk.rb', line 26 def to_xml(xml=Nokogiri::XML::Builder.new) xml.disk(:type => type) do |d| if source # Source tag, the attribute depends on the type. attribute = type == :block ? :dev : :file d.source(attribute => source) end if target_dev # Target tag has optional "bus" parameter = { :dev => target_dev } [:bus] = target_bus if target_bus d.target() end if driver # Driver tag has a couple optional parameters = { :name => driver } [:type] = driver_type if driver_type [:cache] = driver_cache if driver_cache d.driver() end d.shareable if shareable d.serial serial if serial end xml.to_xml end |