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_to_affinity_group(attrs) ⇒ Object
- #add_volume(attrs) ⇒ Object
- #attach_volume(attrs) ⇒ Object
- #destroy(options = {}) ⇒ Object
- #destroy_interface(attrs) ⇒ Object
- #destroy_volume(attrs) ⇒ Object
- #detach_volume(attrs) ⇒ Object
- #interfaces ⇒ Object
- #locked? ⇒ Boolean
- #mac ⇒ Object
- #ready? ⇒ Boolean
- #reboot(options = {}) ⇒ Object
- #remove_from_affinity_group(attrs) ⇒ Object
- #save ⇒ Object
- #start(options = {}) ⇒ Object
- #start_with_cloudinit(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
59 60 61 62 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 59 def add_interface attrs wait_for { stopped? } if attrs[:blocking] service.add_interface(id, attrs) end |
#add_to_affinity_group(attrs) ⇒ Object
106 107 108 109 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 106 def add_to_affinity_group(attrs) wait_for { stopped? } if attrs[:blocking] service.add_to_affinity_group(id, attrs) end |
#add_volume(attrs) ⇒ Object
81 82 83 84 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 81 def add_volume attrs wait_for { stopped? } if attrs[:blocking] service.add_volume(id, attrs) end |
#attach_volume(attrs) ⇒ Object
96 97 98 99 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 96 def attach_volume(attrs) wait_for { stopped? } if attrs[:blocking] service.attach_volume(id, attrs) end |
#destroy(options = {}) ⇒ Object
144 145 146 147 148 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 144 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
69 70 71 72 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 69 def destroy_interface attrs wait_for { stopped? } if attrs[:blocking] service.destroy_interface(id, attrs) end |
#destroy_volume(attrs) ⇒ Object
86 87 88 89 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 86 def destroy_volume attrs wait_for { stopped? } if attrs[:blocking] service.destroy_volume(id, attrs) end |
#detach_volume(attrs) ⇒ Object
101 102 103 104 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 101 def detach_volume(attrs) wait_for { stopped? } if attrs[:blocking] service.detach_volume(id, attrs) end |
#interfaces ⇒ Object
52 53 54 55 56 57 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 52 def interfaces @interfaces ||= id.nil? ? [] : Fog::Compute::Ovirt::Interfaces.new( :service => service, :vm => self ) end |
#locked? ⇒ Boolean
39 40 41 42 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 39 def locked? @volumes = nil # force reload volumes !!(status =~ /locked/i) || (attributes[:volumes]=nil) || volumes.any?{|v| !!(v.status =~ /locked/i)} end |
#mac ⇒ Object
48 49 50 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 48 def mac interfaces.first.mac unless interfaces.empty? end |
#ready? ⇒ Boolean
35 36 37 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 35 def ready? !(status =~ /down/i) end |
#reboot(options = {}) ⇒ Object
134 135 136 137 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 134 def reboot( = {}) stop unless stopped? start .merge(:blocking => true) end |
#remove_from_affinity_group(attrs) ⇒ Object
111 112 113 114 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 111 def remove_from_affinity_group(attrs) wait_for { stopped? } if attrs[:blocking] service.remove_from_affinity_group(id, attrs) end |
#save ⇒ Object
155 156 157 158 159 160 161 162 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 155 def save if persisted? service.update_vm(attributes) else self.id = service.create_vm(attributes).id end reload end |
#start(options = {}) ⇒ Object
116 117 118 119 120 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 116 def start( = {}) wait_for { !locked? } if [:blocking] service.vm_action(:id =>id, :action => :start) reload end |
#start_with_cloudinit(options = {}) ⇒ Object
122 123 124 125 126 127 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 122 def start_with_cloudinit( = {}) wait_for { !locked? } if [:blocking] user_data = Hash[YAML.load([:user_data]).map{|a| [a.first.to_sym, a.last]}] service.vm_start_with_cloudinit(:id =>id, :user_data =>user_data) reload end |
#stop(options = {}) ⇒ Object
129 130 131 132 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 129 def stop( = {}) service.vm_action(:id =>id, :action => :stop) reload end |
#stopped? ⇒ Boolean
44 45 46 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 44 def stopped? !!(status =~ /down/i) end |
#suspend(options = {}) ⇒ Object
139 140 141 142 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 139 def suspend( = {}) service.vm_action(:id =>id, :action => :suspend) reload end |
#ticket(options = {}) ⇒ Object
150 151 152 153 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 150 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
164 165 166 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 164 def to_s name end |
#update_interface(attrs) ⇒ Object
64 65 66 67 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 64 def update_interface attrs wait_for { stopped? } if attrs[:blocking] service.update_interface(id, attrs) end |
#update_volume(attrs) ⇒ Object
91 92 93 94 |
# File 'lib/fog/ovirt/models/compute/server.rb', line 91 def update_volume attrs wait_for { stopped? } if attrs[:blocking] service.update_volume(id, attrs) end |