Class: Fog::Compute::ProfitBricks::Server
Instance Attribute Summary collapse
Instance Method Summary
collapse
#flatten
#failed?, #ready?, #request_status, #wait_for
Constructor Details
#initialize(attributes = {}) ⇒ Server
Returns a new instance of Server.
42
43
44
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 42
def initialize(attributes = {})
super
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
40
41
42
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 40
def options
@options
end
|
Instance Method Details
#attach_cdrom(cdrom_image_id) ⇒ Object
107
108
109
110
111
112
113
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 107
def attach_cdrom(cdrom_image_id)
requires :datacenter_id, :id
data = service.attach_cdrom(datacenter_id, id, cdrom_image_id)
flatten(data.body)
end
|
#attach_volume(storage_id) ⇒ Object
84
85
86
87
88
89
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 84
def attach_volume(storage_id)
requires :datacenter_id, :id
data = service.attach_volume(datacenter_id, id, storage_id)
flatten(data.body)
end
|
#delete ⇒ Object
147
148
149
150
151
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 147
def delete
requires :datacenter_id, :id
service.delete_server(datacenter_id, id)
true
end
|
#detach_cdrom(cdrom_id) ⇒ Object
122
123
124
125
126
127
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 122
def detach_cdrom(cdrom_id)
requires :datacenter_id, :id
service.detach_cdrom(datacenter_id, id, cdrom_id)
true
end
|
#detach_volume(storage_id) ⇒ Object
100
101
102
103
104
105
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 100
def detach_volume(storage_id)
requires :datacenter_id, :id
service.detach_volume(datacenter_id, id, storage_id)
true
end
|
#get_attached_cdrom(cdrom_image_id) ⇒ Object
115
116
117
118
119
120
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 115
def get_attached_cdrom(cdrom_image_id)
requires :datacenter_id, :id
data = service.get_attached_cdrom(datacenter_id, id, cdrom_image_id)
flatten(data.body)
end
|
#get_attached_volume(volume_id) ⇒ Object
91
92
93
94
95
96
97
98
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 91
def get_attached_volume(volume_id)
requires :datacenter_id, :id
data = service.get_attached_volume(datacenter_id, id, volume_id)
volume = data.body
volume['datacenter_id'] = datacenter_id
flatten(data.body)
end
|
#list_cdroms ⇒ Object
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 180
def list_cdroms
requires :datacenter_id, :id
result = service.list_attached_cdroms(datacenter_id, id)
cdroms = result.body['items'].each { |cdrom| cdrom['datacenter_id'] = datacenter_id }
result.body['items'] = cdroms
result.body
end
|
#list_nics ⇒ Object
191
192
193
194
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 191
def list_nics
requires :datacenter_id, :id
service.nics.all(datacenter_id, id)
end
|
#list_volumes ⇒ Object
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 169
def list_volumes
requires :datacenter_id, :id
result = service.list_attached_volumes(datacenter_id, id)
volumes = result.body['items'].each { |volume| volume['datacenter_id'] = datacenter_id }
result.body['items'] = volumes
result.body
end
|
#reboot ⇒ Object
129
130
131
132
133
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 129
def reboot
requires :datacenter_id, :id
service.reboot_server(datacenter_id, id)
true
end
|
#reload ⇒ Object
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 153
def reload
requires :datacenter_id, :id
data = begin
collection.get(datacenter_id, id)
rescue Excon::Errors::SocketError
nil
end
return unless data
new_attributes = data.attributes
merge_attributes(new_attributes)
self
end
|
#running? ⇒ Boolean
200
201
202
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 200
def running?
vm_state == 'RUNNING'
end
|
#save ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 46
def save
requires :datacenter_id, :name, :cores, :ram
properties = {}
properties[:name] = name if name
properties[:cores] = cores if cores
properties[:ram] = ram if ram
properties[:availabilityZone] = availability_zone if availability_zone
properties[:bootVolume] = boot_volume if boot_volume
properties[:bootCdrom] = boot_cdrom if boot_cdrom
properties[:cpuFamily] = cpu_family if cpu_family
entities = {}
entities[:volumes] = get_volumes(volumes) if volumes
entities[:nics] = get_nics(nics) if nics
data = service.create_server(datacenter_id, properties, entities)
merge_attributes(flatten(data.body))
true
end
|
#shutoff? ⇒ Boolean
196
197
198
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 196
def shutoff?
vm_state == 'SHUTOFF'
end
|
#start ⇒ Object
135
136
137
138
139
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 135
def start
requires :datacenter_id, :id
service.start_server(datacenter_id, id)
true
end
|
#stop ⇒ Object
141
142
143
144
145
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 141
def stop
requires :datacenter_id, :id
service.stop_server(datacenter_id, id)
true
end
|
#update ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/fog/profitbricks/models/compute/server.rb', line 68
def update
requires :datacenter_id, :id
properties = {}
properties[:name] = name if name
properties[:cores] = cores if cores
properties[:ram] = ram if ram
properties[:availabilityZone] = availability_zone if availability_zone
properties[:cpuFamily] = cpu_family if cpu_family
properties[:allowReboot] = allow_reboot if allow_reboot
data = service.update_server(datacenter_id, id, properties)
merge_attributes(flatten(data.body))
true
end
|