2012-04-02 07:25:03 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class XenServer
|
|
|
|
|
|
|
|
class VBD < Fog::Model
|
|
|
|
# API Reference here:
|
|
|
|
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=VBD
|
|
|
|
|
|
|
|
identity :reference
|
|
|
|
|
|
|
|
attribute :uuid
|
|
|
|
attribute :currently_attached
|
2012-04-04 13:48:21 -04:00
|
|
|
attribute :allowed_operations
|
|
|
|
attribute :current_operations
|
2012-04-02 07:48:04 -04:00
|
|
|
attribute :__vdi, :aliases => :VDI
|
|
|
|
attribute :__vm, :aliases => :VM
|
2012-04-02 07:25:03 -04:00
|
|
|
attribute :device
|
|
|
|
attribute :status_detail
|
2012-04-04 13:48:21 -04:00
|
|
|
attribute :status_code
|
2012-04-02 07:25:03 -04:00
|
|
|
attribute :type
|
|
|
|
attribute :userdevice
|
2012-04-04 13:48:21 -04:00
|
|
|
attribute :empty
|
|
|
|
attribute :type
|
|
|
|
attribute :mode
|
2012-04-10 02:01:17 -04:00
|
|
|
attribute :storage_lock
|
2012-04-04 13:48:21 -04:00
|
|
|
attribute :runtime_properties
|
|
|
|
attribute :unpluggable
|
2012-04-10 02:01:17 -04:00
|
|
|
attribute :bootable
|
2012-04-12 08:16:14 -04:00
|
|
|
attribute :qos_supported_algorithms
|
|
|
|
attribute :qos_algorithm_params
|
|
|
|
attribute :qos_algorithm_type
|
2012-04-10 02:01:17 -04:00
|
|
|
attribute :empty
|
|
|
|
attribute :__metrics, :aliases => :metrics
|
2012-04-04 13:48:21 -04:00
|
|
|
|
2012-04-04 03:01:55 -04:00
|
|
|
#
|
|
|
|
# May return nil
|
|
|
|
#
|
2012-04-02 07:25:03 -04:00
|
|
|
def vdi
|
|
|
|
connection.vdis.get __vdi
|
|
|
|
end
|
2012-04-12 08:16:14 -04:00
|
|
|
|
2012-04-04 03:01:55 -04:00
|
|
|
#
|
|
|
|
# TODO: May it return nil?
|
|
|
|
#
|
2012-04-02 07:48:04 -04:00
|
|
|
def server
|
|
|
|
connection.servers.get __vm
|
|
|
|
end
|
2012-04-02 07:25:03 -04:00
|
|
|
|
2012-04-12 08:16:14 -04:00
|
|
|
def save
|
|
|
|
requires :vdi, :server
|
|
|
|
ref = connection.create_vbd attributes[:server], attributes[:vdi], attributes
|
|
|
|
merge_attributes connection.vbds.get(ref).attributes
|
|
|
|
end
|
|
|
|
|
2012-04-10 02:01:17 -04:00
|
|
|
def unplug
|
|
|
|
connection.unplug_vbd reference
|
|
|
|
end
|
|
|
|
|
|
|
|
def unplug_force
|
|
|
|
connection.unplug_force_vbd reference
|
|
|
|
end
|
|
|
|
|
|
|
|
def eject
|
|
|
|
connection.eject_vbd reference
|
|
|
|
end
|
|
|
|
|
|
|
|
def insert(vdi)
|
|
|
|
connection.insert_vbd reference, vdi.reference
|
|
|
|
end
|
|
|
|
|
2012-04-19 04:53:56 -04:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2012-04-10 02:01:17 -04:00
|
|
|
def metrics
|
2012-04-19 04:53:56 -04:00
|
|
|
return nil unless currently_attached
|
2012-04-10 02:01:17 -04:00
|
|
|
rec = connection.get_record( __metrics, 'VBD_metrics' )
|
|
|
|
Fog::Compute::XenServer::VbdMetrics.new(rec)
|
|
|
|
end
|
|
|
|
|
2012-04-02 07:25:03 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|