Class: Fog::Compute::XenServer::VBD

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/xenserver/models/compute/vbd.rb

Instance Method Summary collapse

Instance Method Details

#ejectObject



65
66
67
# File 'lib/fog/xenserver/models/compute/vbd.rb', line 65

def eject
  service.eject_vbd reference
end

#insert(vdi) ⇒ Object



69
70
71
# File 'lib/fog/xenserver/models/compute/vbd.rb', line 69

def insert(vdi)
  service.insert_vbd reference, vdi.reference
end

#metricsObject

return nil if the VBD is not attached

TODO: Confirm that the VBD_metrics handle is invalid when the VBD is NOT attached. I get a HANDLE_INVALID exception in that case.



80
81
82
83
84
# File 'lib/fog/xenserver/models/compute/vbd.rb', line 80

def metrics
  return nil unless currently_attached
  rec = service.get_record( __metrics, 'VBD_metrics' )
  Fog::Compute::XenServer::VbdMetrics.new(rec)
end

#saveObject



51
52
53
54
55
# File 'lib/fog/xenserver/models/compute/vbd.rb', line 51

def save
  requires :vdi, :server
  ref = service.create_vbd attributes[:server], attributes[:vdi], attributes
  merge_attributes service.vbds.get(ref).attributes
end

#serverObject

TODO: May it return nil?



47
48
49
# File 'lib/fog/xenserver/models/compute/vbd.rb', line 47

def server
  service.servers.get __vm
end

#unplugObject



57
58
59
# File 'lib/fog/xenserver/models/compute/vbd.rb', line 57

def unplug
  service.unplug_vbd reference
end

#unplug_forceObject



61
62
63
# File 'lib/fog/xenserver/models/compute/vbd.rb', line 61

def unplug_force
  service.unplug_force_vbd reference
end

#vdiObject

May return nil



40
41
42
# File 'lib/fog/xenserver/models/compute/vbd.rb', line 40

def vdi
  service.vdis.get __vdi
end