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
- #get_customization_spec_info_by_name(connection, machine) ⇒ Object
- #get_datacenter(connection, machine) ⇒ Object
- #get_datastore(connection, machine) ⇒ Object
- #get_resource_pool(connection, machine) ⇒ Object
- #get_vm_by_uuid(connection, machine) ⇒ Object
Instance Method Details
#get_customization_spec_info_by_name(connection, machine) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/vSphere/util/vim_helpers.rb', line 20 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, :message => I18n.t('vsphere.errors.null_configuration_spec_manager') if manager.nil? spec = manager.GetCustomizationSpec(:name => name) or fail Errors::VSphereError, :message => I18n.t('vsphere.errors.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, :message => I18n.t('vsphere.errors.missing_datacenter') end |
#get_datastore(connection, machine) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/vSphere/util/vim_helpers.rb', line 28 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, :message => I18n.t('vsphere.errors.missing_datastore') end |
#get_resource_pool(connection, machine) ⇒ Object
15 16 17 18 |
# 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, :message => I18n.t('vsphere.errors.missing_compute_resource') cr.resourcePool.find(machine.provider_config.resource_pool_name) or fail Errors::VSphereError, :message => I18n.t('vsphere.errors.missing_resource_pool') 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 |