Class: Fog::Compute::Ovirt::Server
- Inherits:
-
Server
show all
- Defined in:
- lib/fog/ovirt/models/compute/server.rb
Instance Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Server
#scp, #scp_download, #ssh
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
Instance Method Details
#add_interface(attrs) ⇒ Object
53
54
55
56
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 53
def add_interface attrs
wait_for { stopped? } if attrs[:blocking]
connection.add_interface(id, attrs)
end
|
#destroy(options = {}) ⇒ Object
89
90
91
92
93
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 89
def destroy(options = {})
(stop unless stopped?) rescue nil
wait_for { stopped? }
connection.destroy_vm(:id => id)
end
|
#destroy_interface(attrs) ⇒ Object
63
64
65
66
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 63
def destroy_interface attrs
wait_for { stopped? } if attrs[:blocking]
connection.destroy_interface(id, attrs)
end
|
#interfaces ⇒ Object
46
47
48
49
50
51
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 46
def interfaces
attributes[:interfaces] ||= id.nil? ? [] : Fog::Compute::Ovirt::Interfaces.new(
:connection => connection,
:vm => self
)
end
|
#locked? ⇒ Boolean
34
35
36
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 34
def locked?
!!(status =~ /locked/i)
end
|
#mac ⇒ Object
42
43
44
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 42
def mac
interfaces.first.mac unless interfaces.empty?
end
|
#ready? ⇒ Boolean
30
31
32
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 30
def ready?
!(status =~ /down/i)
end
|
#reboot(options = {}) ⇒ Object
79
80
81
82
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 79
def reboot(options = {})
stop unless stopped?
start options.merge(:blocking => true)
end
|
#save ⇒ Object
100
101
102
103
104
105
106
107
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 100
def save
if identity
connection.update_vm(attributes)
else
self.id = connection.create_vm(attributes).id
end
reload
end
|
#start(options = {}) ⇒ Object
68
69
70
71
72
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 68
def start(options = {})
wait_for { stopped? } if options[:blocking]
connection.vm_action(:id =>id, :action => :start)
reload
end
|
#stop(options = {}) ⇒ Object
74
75
76
77
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 74
def stop(options = {})
connection.vm_action(:id =>id, :action => :stop)
reload
end
|
#stopped? ⇒ Boolean
38
39
40
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 38
def stopped?
!!(status =~ /down/i)
end
|
#suspend(options = {}) ⇒ Object
84
85
86
87
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 84
def suspend(options = {})
connection.vm_action(:id =>id, :action => :suspend)
reload
end
|
#ticket(options = {}) ⇒ Object
95
96
97
98
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 95
def ticket(options = {})
raise "Can not set console ticket, Server is not ready. Server status: #{status}" unless ready?
connection.vm_ticket(id, options)
end
|
#to_s ⇒ Object
109
110
111
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 109
def to_s
name
end
|
#update_interface(attrs) ⇒ Object
58
59
60
61
|
# File 'lib/fog/ovirt/models/compute/server.rb', line 58
def update_interface attrs
wait_for { stopped? } if attrs[:blocking]
connection.update_interface(id, attrs)
end
|