Module: VagrantPlugins::VSphere::Util::VimHelpers

Included in:
Action::Clone, Action::Destroy, Action::GetSshInfo, Action::GetState, Action::PowerOff, Action::PowerOn
Defined in:
lib/vSphere/util/vim_helpers.rb

Instance Method Summary collapse

Instance Method Details

#get_customization_spec_info_by_name(connection, machine) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/vSphere/util/vim_helpers.rb', line 24

def get_customization_spec_info_by_name(connection, machine)
  name = machine.provider_config.customization_spec_name
  return if name.nil? || name.empty?

  manager = connection.serviceContent.customizationSpecManager or fail Errors::VSphereError, :null_configuration_spec_manager if manager.nil?
  spec = manager.GetCustomizationSpec(:name => name) or fail Errors::VSphereError, :missing_configuration_spec if spec.nil?
end

#get_datacenter(connection, machine) ⇒ Object



7
8
9
# File 'lib/vSphere/util/vim_helpers.rb', line 7

def get_datacenter(connection, machine)
  connection.serviceInstance.find_datacenter(machine.provider_config.data_center_name) or fail Errors::VSphereError, :missing_datacenter
end

#get_datastore(connection, machine) ⇒ Object



32
33
34
35
36
37
# File 'lib/vSphere/util/vim_helpers.rb', line 32

def get_datastore(connection, machine)
  name = machine.provider_config.data_store_name
  return if name.nil? || name.empty?

  get_datacenter(connection, machine).find_datastore name or fail Errors::VSphereError, :missing_datastore
end

#get_resource_pool(connection, machine) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/vSphere/util/vim_helpers.rb', line 15

def get_resource_pool(connection, machine)
  cr = get_datacenter(connection, machine).find_compute_resource(machine.provider_config.compute_resource_name) or fail Errors::VSphereError, :missing_compute_resource
  rp = cr.resourcePool
  if !(machine.provider_config.resource_pool_name.nil?)
    rp = cr.resourcePool.find(machine.provider_config.resource_pool_name) or  fail Errors::VSphereError, :missing_resource_pool
  end
  rp
end

#get_vm_by_uuid(connection, machine) ⇒ Object



11
12
13
# File 'lib/vSphere/util/vim_helpers.rb', line 11

def get_vm_by_uuid(connection, machine)
  get_datacenter(connection, machine).vmFolder.findByUuid machine.id
end