Class: VirtualMachineDevice::Device
- Inherits:
-
Object
- Object
- VirtualMachineDevice::Device
- Defined in:
- lib/vm_device.rb
Overview
Device Classes
Device base class
Instance Method Summary collapse
- #detached? ⇒ Boolean
- #exists? ⇒ Boolean
- #id ⇒ Object
-
#initialize(id, one_res, vc_res) ⇒ Device
constructor
A new instance of Device.
- #managed? ⇒ Boolean
- #no_exists? ⇒ Boolean
- #one? ⇒ Boolean
- #one_item ⇒ Object
-
#raise_if_no_exists_in_one ⇒ Object
Fails if the device is not present in OpenNebula.
-
#raise_if_no_exists_in_vcenter ⇒ Object
Fails if the device is not present in vCenter.
- #synced? ⇒ Boolean
- #unsynced? ⇒ Boolean
- #vc_item ⇒ Object
Constructor Details
#initialize(id, one_res, vc_res) ⇒ Device
Returns a new instance of Device.
14 15 16 17 18 |
# File 'lib/vm_device.rb', line 14 def initialize(id, one_res, vc_res) @id = id @one_res = one_res @vc_res = vc_res end |
Instance Method Details
#detached? ⇒ Boolean
65 66 67 |
# File 'lib/vm_device.rb', line 65 def detached? !one? end |
#exists? ⇒ Boolean
39 40 41 |
# File 'lib/vm_device.rb', line 39 def exists? !@vc_res.nil? end |
#id ⇒ Object
20 21 22 23 |
# File 'lib/vm_device.rb', line 20 def id raise_if_no_exists_in_one @id end |
#managed? ⇒ Boolean
69 70 71 72 73 74 75 76 |
# File 'lib/vm_device.rb', line 69 def managed? raise_if_no_exists_in_one return unless @one_res !(@one_res['OPENNEBULA_MANAGED'] && @one_res['OPENNEBULA_MANAGED'].downcase == 'no') end |
#no_exists? ⇒ Boolean
53 54 55 |
# File 'lib/vm_device.rb', line 53 def no_exists? !exists? end |
#one? ⇒ Boolean
35 36 37 |
# File 'lib/vm_device.rb', line 35 def one? !@one_res.nil? end |
#one_item ⇒ Object
25 26 27 28 |
# File 'lib/vm_device.rb', line 25 def one_item raise_if_no_exists_in_one @one_res end |
#raise_if_no_exists_in_one ⇒ Object
Fails if the device is not present in OpenNebula
44 45 46 |
# File 'lib/vm_device.rb', line 44 def raise_if_no_exists_in_one raise 'OpenNebula device does not exist at the moment' unless one? end |
#raise_if_no_exists_in_vcenter ⇒ Object
Fails if the device is not present in vCenter
49 50 51 |
# File 'lib/vm_device.rb', line 49 def raise_if_no_exists_in_vcenter raise 'vCenter device does not exist at the moment' unless exists? end |
#synced? ⇒ Boolean
57 58 59 |
# File 'lib/vm_device.rb', line 57 def synced? one? && exists? end |
#unsynced? ⇒ Boolean
61 62 63 |
# File 'lib/vm_device.rb', line 61 def unsynced? !synced? end |
#vc_item ⇒ Object
30 31 32 33 |
# File 'lib/vm_device.rb', line 30 def vc_item raise_if_no_exists_in_vcenter @vc_res end |