# File lib/fog/vsphere/models/compute/server.rb, line 92 def clone(options = {}) requires :name, :path # Convert symbols to strings req_options = options.inject({}) { |hsh, (k,v)| hsh[k.to_s] = v; hsh } # Give our path to the request req_options['path'] ="#{path}/#{name}" # Perform the actual clone clone_results = connection.vm_clone(req_options) # Create the new VM model. new_vm = self.class.new(clone_results['vm_attributes']) # We need to assign the collection and the connection otherwise we # cannot reload the model. new_vm.collection = self.collection new_vm.connection = self.connection # Return the new VM model. new_vm end
defines VNC attributes on the hypervisor
# File lib/fog/vsphere/models/compute/server.rb, line 119 def config_vnc(options = {}) requires :instance_uuid connection.vm_config_vnc(options.merge('instance_uuid' => instance_uuid)) end
# File lib/fog/vsphere/models/compute/server.rb, line 84 def create(options ={}) requires :name, :path new_vm = self.class.new(create_results['vm_attributes']) new_vm.collection = self.collection new_vm.connection = self.connection new_vm end
# File lib/fog/vsphere/models/compute/server.rb, line 72 def destroy(options = {}) requires :instance_uuid stop if ready? # need to turn it off before destroying connection.vm_destroy('instance_uuid' => instance_uuid) end
# File lib/fog/vsphere/models/compute/server.rb, line 130 def memory memory_mb * 1024 * 1024 end
# File lib/fog/vsphere/models/compute/server.rb, line 78 def migrate(options = {}) options = { :priority => 'defaultPriority' }.merge(options) requires :instance_uuid connection.vm_migrate('instance_uuid' => instance_uuid, 'priority' => options[:priority]) end
# File lib/fog/vsphere/models/compute/server.rb, line 110 def ready? power_state == "poweredOn" end
# File lib/fog/vsphere/models/compute/server.rb, line 66 def reboot(options = {}) options = { :force => false }.merge(options) requires :instance_uuid connection.vm_reboot('instance_uuid' => instance_uuid, 'force' => options[:force]) end
# File lib/fog/vsphere/models/compute/server.rb, line 55 def start(options = {}) requires :instance_uuid connection.vm_power_on('instance_uuid' => instance_uuid) end
# File lib/fog/vsphere/models/compute/server.rb, line 60 def stop(options = {}) options = { :force => !tools_installed? }.merge(options) requires :instance_uuid connection.vm_power_off('instance_uuid' => instance_uuid, 'force' => options[:force]) end
# File lib/fog/vsphere/models/compute/server.rb, line 114 def tools_installed? tools_state != "toolsNotInstalled" end
# File lib/fog/vsphere/models/compute/server.rb, line 45 def vm_reconfig_cpus(options = {}) requires :instance_uuid, :cpus connection.vm_reconfig_cpus('instance_uuid' => instance_uuid, 'cpus' => cpus) end
# File lib/fog/vsphere/models/compute/server.rb, line 50 def vm_reconfig_hardware(options = {}) requires :instance_uuid, :hardware_spec connection.vm_reconfig_hardware('instance_uuid' => instance_uuid, 'hardware_spec' => hardware_spec) end
# File lib/fog/vsphere/models/compute/server.rb, line 40 def vm_reconfig_memory(options = {}) requires :instance_uuid, :memory connection.vm_reconfig_memory('instance_uuid' => instance_uuid, 'memory' => memory) end
returns a hash of VNC attributes required for connection
# File lib/fog/vsphere/models/compute/server.rb, line 125 def vnc requires :instance_uuid connection.vm_get_vnc(instance_uuid) end