Class: Fog::Compute::Ovirt::Server
- Inherits:
-
Server
show all
- Defined in:
- lib/fog/ovirt/models/compute/server.rb
Instance Attribute Summary
Attributes inherited from Server
#private_key, #private_key_path, #public_key, #public_key_path, #ssh_options, #ssh_port, #username
Attributes inherited from Model
#collection, #service
Instance Method Summary
collapse
Methods inherited from Server
#scp, #scp_download, #ssh, #sshable?
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#connection, #connection=, #prepare_service_value
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
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
108
109
110
111
112
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 108
def destroy(options = {})
(stop unless stopped?) rescue nil 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
82
83
84
85
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 82
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
attributes[:interfaces] ||= id.nil? ? [] : Fog::Compute::Ovirt::Interfaces.new(
:service => service,
:vm => self
)
end
|
#locked? ⇒ Boolean
36
37
38
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 36
def locked?
!!(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
32
33
34
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 32
def ready?
!(status =~ /down/i)
end
|
#reboot(options = {}) ⇒ Object
98
99
100
101
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 98
def reboot(options = {})
stop unless stopped?
start options.merge(:blocking => true)
end
|
#save ⇒ Object
119
120
121
122
123
124
125
126
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 119
def save
if persisted?
service.update_vm(attributes)
else
self.id = service.create_vm(attributes).id
end
reload
end
|
#start(options = {}) ⇒ Object
87
88
89
90
91
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 87
def start(options = {})
wait_for { !locked? } if options[:blocking]
service.vm_action(:id =>id, :action => :start)
reload
end
|
#stop(options = {}) ⇒ Object
93
94
95
96
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 93
def stop(options = {})
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
103
104
105
106
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 103
def suspend(options = {})
service.vm_action(:id =>id, :action => :suspend)
reload
end
|
#ticket(options = {}) ⇒ Object
114
115
116
117
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 114
def ticket(options = {})
raise "Can not set console ticket, Server is not ready. Server status: #{status}" unless ready?
service.vm_ticket(id, options)
end
|
#to_s ⇒ Object
128
129
130
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 128
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
|
#volumes ⇒ Object
70
71
72
73
74
75
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 70
def volumes
attributes[:volumes] ||= id.nil? ? [] : Fog::Compute::Ovirt::Volumes.new(
:service => service,
:vm => self
)
end
|