Module: Chef::Knife::Cloud::VcenterServiceHelpers

Includes:
Helpers
Included in:
VcenterService
Defined in:
lib/chef/knife/cloud/vcenter_service_helpers.rb

Overview

Module that creates the helpers for this gem

Instance Method Summary collapse

Instance Method Details

#check_for_missing_config_values!(*keys) ⇒ Object

rubocop:disable Style/GuardClause Checks for any missing values

Parameters:

  • keys (Object)

    makes sure that the values are all not nil



56
57
58
59
60
61
62
63
# File 'lib/chef/knife/cloud/vcenter_service_helpers.rb', line 56

def check_for_missing_config_values!(*keys)
  missing = keys.select { |x| config[x].nil? }

  unless missing.empty?
    ui.error(format("The following required parameters are missing: %s", missing.join(", ")))
    exit(1)
  end
end

#create_service_instanceObject

Creates the object for vCenterService



33
34
35
36
37
38
# File 'lib/chef/knife/cloud/vcenter_service_helpers.rb', line 33

def create_service_instance
  Chef::Knife::Cloud::VcenterService.new(username: config[:vcenter_username],
                                         password: config[:vcenter_password],
                                         host: config[:vcenter_host],
                                         verify_ssl: verify_ssl?)
end

#validate!Object

Validate the options and fail out if something isn’t there



48
49
50
# File 'lib/chef/knife/cloud/vcenter_service_helpers.rb', line 48

def validate!
  check_for_missing_config_values!(:vcenter_username, :vcenter_password, :vcenter_host)
end

#verify_ssl?Boolean

Do we have valid SSL?

Returns:

  • (Boolean)


42
43
44
# File 'lib/chef/knife/cloud/vcenter_service_helpers.rb', line 42

def verify_ssl?
  !config[:vcenter_disable_ssl_verify]
end