Class: Xen::VBD

Inherits:
Base
  • Object
show all
Defined in:
lib/xen/vbd.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #record, #to_s, #uuid

Constructor Details

This class inherits a constructor from Xen::Base

Class Method Details

.create(dev, vm, vdi, host) ⇒ Object

Creates a new VBD. Required paramters are the device (‘hda1’), the vm object, the vdi object and the host



15
16
17
18
19
20
21
# File 'lib/xen/vbd.rb', line 15

def self.create(dev, vm, vdi, host)
  o = @initial_config.merge({:device => dev, 
                                  :VM => vm.uuid,
                                  :VDI => vdi.uuid})
  uuid = host.get_value("VBD.create", o)
  self.new(uuid, host)
end

Instance Method Details

#destroy!Object

Destroys the VBD



29
30
31
# File 'lib/xen/vbd.rb', line 29

def destroy!
  @host.call('VBD.destroy', self.uuid)
end

#humanizeObject

Gives a nice description



34
35
36
37
# File 'lib/xen/vbd.rb', line 34

def humanize
  r = self.record
  "VBD #{self.uuid} is disk '#{r['device']}' in the VM, connected to VDI #{self.vdi}\n" + self.vdi.humanize('\--')
end

#vdiObject

Gets the connected VDI



24
25
26
# File 'lib/xen/vbd.rb', line 24

def vdi
  Xen::VDI.new(@host.get_value('VBD.get_VDI', self.uuid), @host)
end