177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
# File 'lib/fog/vcloud/models/compute/server.rb', line 177
def save
if new_record?
raise RuntimeError, "Should not be here"
else
if on?
if @changed
raise RuntimeError, "Can't save cpu, name or memory changes while the VM is on."
end
end
if @update_password
guest_customization[:AdminPassword] = @update_password.to_s
connection.configure_vm_password(guest_customization)
wait_for { ready? }
end
if @update_cpu_value
cpu_mess[:"rasd:VirtualQuantity"] = @update_cpu_value.to_s
connection.configure_vm_cpus(cpu_mess)
wait_for { ready? }
end
if @update_memory_value
memory_mess[:"rasd:VirtualQuantity"] = @update_memory_value.to_s
connection.configure_vm_memory(memory_mess)
wait_for { ready? }
end
if @disk_change == :deleted
data = disk_mess.delete_if do |vh|
vh[:'rasd:ResourceType'] == '17' &&
vh[:'rasd:AddressOnParent'].to_s == @remove_disk.to_s
end
connection.configure_vm_disks(self.href, data)
wait_for { ready? }
end
if @disk_change == :added
data = disk_mess
data << @add_disk
connection.configure_vm_disks(self.href, data)
wait_for { ready? }
end
if @name_changed || @description_changed
edit_uri = links.select {|i| i[:rel] == 'edit'}
edit_uri = edit_uri.kind_of?(Array) ? edit_uri.flatten[0][:href] : edit_uri[:href]
connection.configure_vm_name_description(edit_uri, self.name, self.description)
wait_for { ready? }
end
end
reset_tracking
true
end
|