Class: URI::VsphereUrl

Inherits:
Generic
  • Object
show all
Defined in:
lib/chef/provisioning/vsphere_driver/vsphere_url.rb

Overview

Creates the vSphereURL, extended by the Generic Class

Constant Summary collapse

DEFAULT_PORT =

Default port for connecting to the vSphere cluster Webserver

443
DEFAULT_PATH =

Default path for connecting to the vSphere cluster URL

"/sdk".freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_config(options) ⇒ Object

Creates the URL from options that are decided



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/chef/provisioning/vsphere_driver/vsphere_url.rb', line 16

def self.from_config(options)
  parts = []
  parts << "vsphere://"
  parts << options[:host]
  parts << ":"
  parts << (options[:port] || DEFAULT_PORT)
  parts << (options[:path] || DEFAULT_PATH)
  parts << "?use_ssl="
  parts << (options[:use_ssl] == false ? false : true)
  parts << "&insecure="
  parts << (options[:insecure] || false)
  URI parts.join
end

Instance Method Details

#insecureObject

Converts URL to insecure if needed



45
46
47
48
49
50
51
52
53
54
# File 'lib/chef/provisioning/vsphere_driver/vsphere_url.rb', line 45

def insecure
  if query
    insecure_query = query.split("&").each.select do |q|
      q.start_with?("insecure=")
    end.first
    insecure_query == "insecure=true"
  else
    false
  end
end

#use_sslObject

Converts URL to SSL if needed



32
33
34
35
36
37
38
39
40
41
# File 'lib/chef/provisioning/vsphere_driver/vsphere_url.rb', line 32

def use_ssl
  if query
    ssl_query = query.split("&").each.select do |q|
      q.start_with?("use_ssl=")
    end.first
    ssl_query == "use_ssl=true"
  else
    true
  end
end