class Fog::Compute::Vsphere::Server

Public Instance Methods

clone(options = {}) click to toggle source
# File lib/fog/vsphere/models/compute/server.rb, line 91
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
config_vnc(options = {}) click to toggle source

defines VNC attributes on the hypervisor

# File lib/fog/vsphere/models/compute/server.rb, line 118
def config_vnc(options = {})
  requires :instance_uuid
  connection.vm_config_vnc(options.merge('instance_uuid' => instance_uuid))
end
create(options ={}) click to toggle source
# File lib/fog/vsphere/models/compute/server.rb, line 83
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
destroy(options = {}) click to toggle source
# File lib/fog/vsphere/models/compute/server.rb, line 72
def destroy(options = {})
  requires :instance_uuid
  connection.vm_destroy('instance_uuid' => instance_uuid)
end
memory() click to toggle source
# File lib/fog/vsphere/models/compute/server.rb, line 129
def memory
  memory_mb * 1024 * 1024
end
migrate(options = {}) click to toggle source
# File lib/fog/vsphere/models/compute/server.rb, line 77
def migrate(options = {})
  options = { :priority => 'defaultPriority' }.merge(options)
  requires :instance_uuid
  connection.vm_migrate('instance_uuid' => instance_uuid, 'priority' => options[:priority])
end
ready?() click to toggle source
# File lib/fog/vsphere/models/compute/server.rb, line 109
def ready?
  power_state == "poweredOn"
end
reboot(options = {}) click to toggle source
# 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
start(options = {}) click to toggle source
# 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
stop(options = {}) click to toggle source
# 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
tools_installed?() click to toggle source
# File lib/fog/vsphere/models/compute/server.rb, line 113
def tools_installed?
  tools_state != "toolsNotInstalled"
end
vm_reconfig_cpus(options = {}) click to toggle source
# 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
vm_reconfig_hardware(options = {}) click to toggle source
# 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
vm_reconfig_memory(options = {}) click to toggle source
# 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
vnc() click to toggle source

returns a hash of VNC attributes required for connection

# File lib/fog/vsphere/models/compute/server.rb, line 124
def vnc
  requires :instance_uuid
  connection.vm_get_vnc(instance_uuid)
end