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

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#ejectObject



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

def eject
  service.eject_vbd reference
end

#insert(vdi) ⇒ Object



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

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.



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

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

#saveObject



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

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?



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

def server
  service.servers.get __vm
end

#unplugObject



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

def unplug
  service.unplug_vbd reference
end

#unplug_forceObject



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

def unplug_force
  service.unplug_force_vbd reference
end

#vdiObject

May return nil



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

def vdi
  service.vdis.get __vdi
end