Class: Fog::Compute::Vsphere::Server

Inherits:
Server show all
Defined in:
lib/fog/vsphere/models/compute/server.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Server

#scp, #scp_download, #ssh

Methods inherited from Model

#initialize, #inspect, #reload, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#clone(options = {}) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/fog/vsphere/models/compute/server.rb', line 78

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

#create(options = {}) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/fog/vsphere/models/compute/server.rb', line 71

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 = {}) ⇒ Object



67
68
69
70
# File 'lib/fog/vsphere/models/compute/server.rb', line 67

def destroy(options = {})
  requires :instance_uuid
  connection.vm_destroy('instance_uuid' => instance_uuid)
end

#reboot(options = {}) ⇒ Object



61
62
63
64
65
# File 'lib/fog/vsphere/models/compute/server.rb', line 61

def reboot(options = {})
  options = { :force => false }.merge(options)
  requires :instance_uuid
  connection.vm_reboot('instance_uuid' => instance_uuid, 'force' => options[:force])
end

#start(options = {}) ⇒ Object



50
51
52
53
# File 'lib/fog/vsphere/models/compute/server.rb', line 50

def start(options = {})
  requires :instance_uuid
  connection.vm_power_on('instance_uuid' => instance_uuid)
end

#stop(options = {}) ⇒ Object



55
56
57
58
59
# File 'lib/fog/vsphere/models/compute/server.rb', line 55

def stop(options = {})
  options = { :force => false }.merge(options)
  requires :instance_uuid
  connection.vm_power_off('instance_uuid' => instance_uuid, 'force' => options[:force])
end

#vm_reconfig_cpus(options = {}) ⇒ Object



42
43
44
45
# File 'lib/fog/vsphere/models/compute/server.rb', line 42

def vm_reconfig_cpus(options = {})
  requires :instance_uuid, :cpus
  connection.vm_reconfig_cpus('instance_uuid' => instance_uuid, 'cpus' => cpus)
end

#vm_reconfig_hardware(options = {}) ⇒ Object



46
47
48
49
# File 'lib/fog/vsphere/models/compute/server.rb', line 46

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 = {}) ⇒ Object



38
39
40
41
# File 'lib/fog/vsphere/models/compute/server.rb', line 38

def vm_reconfig_memory(options = {})
  requires :instance_uuid, :memory
  connection.vm_reconfig_memory('instance_uuid' => instance_uuid, 'memory' => memory)
end