Class: VMware::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/vmware/connection.rb

Overview

A connection encapsulates the SOAP transport to the VMware API server. It does not contain any API specific code.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, username, password, debug = false) ⇒ Connection

Create a new connection to the server.



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/vmware/connection.rb', line 48

def initialize(url, username, password, debug = false)
  @url, @username, @password = url, username, password
  
  @client = VimPortType.new(url) 
  @client.wiredump_dev = STDOUT if debug

  # Certificates tend to be self-signed. Just ignore them.
  @client.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE
  
  # Prepare authentication header.
  headerHandler = VMware::ClientAuthHeaderHandler.new(username, password) 
  @client.headerhandler.add(headerHandler) 
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(methodSymbol, *params) ⇒ Object

Catch any function call and send it over the soap connection.



65
66
67
# File 'lib/vmware/connection.rb', line 65

def method_missing(methodSymbol, *params)
  @client.send(methodSymbol, *params)
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



43
44
45
# File 'lib/vmware/connection.rb', line 43

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



43
44
45
# File 'lib/vmware/connection.rb', line 43

def username
  @username
end