lib/fog/vcloud_director/models/compute/vm.rb in fog-2.0.0.pre.0 vs lib/fog/vcloud_director/models/compute/vm.rb in fog-2.0.0
- old
+ new
@@ -9,17 +9,20 @@
attribute :vapp_id
attribute :vapp_name
attribute :name
attribute :type
+ attribute :description
attribute :href
attribute :status
+ attribute :deployed
attribute :operating_system
attribute :ip_address
attribute :cpu, :type => :integer
attribute :memory, :type => :integer
attribute :hard_disks, :aliases => :disks
+ attribute :network_adapters
def reload
# when collection.vapp is nil, it means it's fatherless,
# vms from different vapps are loaded in the same collection.
# This situation comes from a "query" result
@@ -87,10 +90,21 @@
return false
end
service.process_task(response.body)
end
+ def undeploy
+ requires :id
+ begin
+ response = service.post_undeploy_vapp(id)
+ rescue Fog::Compute::VcloudDirector::BadRequest => ex
+ Fog::Logger.debug(ex.message)
+ return false
+ end
+ service.process_task(response.body)
+ end
+
# Shut down the VM.
def shutdown
requires :id
begin
response = service.post_shutdown_vapp(id)
@@ -152,10 +166,23 @@
if not_first_set && has_changed
response = service.put_cpu(id, cpu)
service.process_task(response.body)
end
end
-
+
+ # Reconfigure a VM using any of the options documented in
+ # post_reconfigure_vm
+ def reconfigure(options)
+ options[:name] ||= name # name has to be sent
+ # Delete those things that are not changing for performance
+ [:cpu, :memory, :description].each do |k|
+ options.delete(k) if options.key? k and options[k] == attributes[k]
+ end
+ response = service.post_reconfigure_vm(id, options)
+ service.process_task(response.body)
+ options.each {|k,v| attributes[k] = v}
+ end
+
def ready?
reload
status == 'on'
end