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, #connection

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 Attributes::InstanceMethods

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

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#ejectObject



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

def eject
  connection.eject_vbd reference
end

#insert(vdi) ⇒ Object



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

def insert(vdi)
  connection.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 = connection.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 = connection.create_vbd attributes[:server], attributes[:vdi], attributes
  merge_attributes connection.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
  connection.servers.get __vm
end

#unplugObject



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

def unplug
  connection.unplug_vbd reference
end

#unplug_forceObject



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

def unplug_force
  connection.unplug_force_vbd reference
end

#vdiObject

May return nil



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

def vdi
  connection.vdis.get __vdi
end