Class: Fog::Compute::Ovirt::Server
- Inherits:
-
Server
- Object
- Server
- Fog::Compute::Ovirt::Server
- Defined in:
- lib/fog/ovirt/models/compute/server.rb
Instance Method Summary collapse
- #add_interface(attrs) ⇒ Object
- #add_volume(attrs) ⇒ Object
- #destroy(options = {}) ⇒ Object
- #destroy_interface(attrs) ⇒ Object
- #destroy_volume(attrs) ⇒ Object
- #interfaces ⇒ Object
- #locked? ⇒ Boolean
- #mac ⇒ Object
- #ready? ⇒ Boolean
- #reboot(options = {}) ⇒ Object
- #save ⇒ Object
- #start(options = {}) ⇒ Object
- #stop(options = {}) ⇒ Object
- #stopped? ⇒ Boolean
- #suspend(options = {}) ⇒ Object
- #ticket(options = {}) ⇒ Object
- #to_s ⇒ Object
- #update_interface(attrs) ⇒ Object
- #update_volume(attrs) ⇒ Object
- #volumes ⇒ Object
Instance Method Details
#add_interface(attrs) ⇒ Object
55 56 57 58 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 55 def add_interface attrs wait_for { stopped? } if attrs[:blocking] service.add_interface(id, attrs) end |
#add_volume(attrs) ⇒ Object
77 78 79 80 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 77 def add_volume attrs wait_for { stopped? } if attrs[:blocking] service.add_volume(id, attrs) end |
#destroy(options = {}) ⇒ Object
113 114 115 116 117 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 113 def destroy( = {}) (stop unless stopped?) rescue nil #ignore failure, destroy the machine anyway. wait_for { stopped? } service.destroy_vm(:id => id) end |
#destroy_interface(attrs) ⇒ Object
65 66 67 68 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 65 def destroy_interface attrs wait_for { stopped? } if attrs[:blocking] service.destroy_interface(id, attrs) end |
#destroy_volume(attrs) ⇒ Object
87 88 89 90 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 87 def destroy_volume attrs wait_for { stopped? } if attrs[:blocking] service.destroy_volume(id, attrs) end |
#interfaces ⇒ Object
48 49 50 51 52 53 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 48 def interfaces @interfaces ||= id.nil? ? [] : Fog::Compute::Ovirt::Interfaces.new( :service => service, :vm => self ) end |
#locked? ⇒ Boolean
35 36 37 38 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 35 def locked? @volumes = nil # force reload volumes !!(status =~ /locked/i) || (attributes[:volumes]=nil) || volumes.any?{|v| !!(v.status =~ /locked/i)} end |
#mac ⇒ Object
44 45 46 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 44 def mac interfaces.first.mac unless interfaces.empty? end |
#ready? ⇒ Boolean
31 32 33 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 31 def ready? !(status =~ /down/i) end |
#reboot(options = {}) ⇒ Object
103 104 105 106 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 103 def reboot( = {}) stop unless stopped? start .merge(:blocking => true) end |
#save ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 124 def save if persisted? service.update_vm(attributes) else self.id = service.create_vm(attributes).id end reload end |
#start(options = {}) ⇒ Object
92 93 94 95 96 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 92 def start( = {}) wait_for { !locked? } if [:blocking] service.vm_action(:id =>id, :action => :start) reload end |
#stop(options = {}) ⇒ Object
98 99 100 101 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 98 def stop( = {}) service.vm_action(:id =>id, :action => :stop) reload end |
#stopped? ⇒ Boolean
40 41 42 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 40 def stopped? !!(status =~ /down/i) end |
#suspend(options = {}) ⇒ Object
108 109 110 111 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 108 def suspend( = {}) service.vm_action(:id =>id, :action => :suspend) reload end |
#ticket(options = {}) ⇒ Object
119 120 121 122 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 119 def ticket( = {}) raise "Can not set console ticket, Server is not ready. Server status: #{status}" unless ready? service.vm_ticket(id, ) end |
#to_s ⇒ Object
133 134 135 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 133 def to_s name end |
#update_interface(attrs) ⇒ Object
60 61 62 63 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 60 def update_interface attrs wait_for { stopped? } if attrs[:blocking] service.update_interface(id, attrs) end |
#update_volume(attrs) ⇒ Object
82 83 84 85 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 82 def update_volume attrs wait_for { stopped? } if attrs[:blocking] service.update_volume(id, attrs) end |