Class: RbVmomi::PBM

Inherits:
Connection show all
Defined in:
lib/rbvmomi/pbm.rb

Overview

A connection to one vSphere ProfileBasedManagement endpoint.

See Also:

Constant Summary

Constants inherited from Connection

Connection::NS_XSI

Instance Attribute Summary

Attributes inherited from Connection

#deserializer, #profile, #profile_summary, #profiling, #rev

Attributes inherited from TrivialSoap

#cookie, #debug, #http, #operation_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Connection

add_extension_dir, #call, #emit_request, extension_dirs, #initialize, #instanceUuid, loader, #obj2xml, #parse_response, reload_extensions, #reset_profiling, type, #type

Methods inherited from TrivialSoap

#close, #host, #initialize, on_connect, #request, #restart_http, #soap_envelope

Constructor Details

This class inherits a constructor from RbVmomi::Connection

Class Method Details

.connect(vim, opts = {}) ⇒ Object

Connect to a vSphere ProfileBasedManagement endpoint

Parameters:

  • Connection (VIM)

    to main vSphere API endpoint

  • opts (Hash) (defaults to: {})

    The options hash.

Options Hash (opts):

  • :host (String)

    Host to connect to.

  • :port (Numeric) — default: 443

    Port to connect to.

  • :ssl (Boolean) — default: true

    Whether to use SSL.

  • :insecure (Boolean) — default: false

    If true, ignore SSL certificate errors.

  • :path (String) — default: /pbm/sdk

    SDK endpoint path.

  • :debug (Boolean) — default: false

    If true, print SOAP traffic to stderr.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rbvmomi/pbm.rb', line 21

def self.connect vim, opts = {}
  fail unless opts.is_a? Hash
  opts[:host] = vim.host
  opts[:ssl] = true unless opts.member? :ssl or opts[:"no-ssl"]
  opts[:insecure] ||= false
  opts[:port] ||= (opts[:ssl] ? 443 : 80)
  opts[:path] ||= '/pbm/sdk'
  opts[:ns] ||= 'urn:pbm'
  rev_given = opts[:rev] != nil
  opts[:rev] = '1.0' unless rev_given
  opts[:debug] = (!ENV['RBVMOMI_DEBUG'].empty? rescue false) unless opts.member? :debug

  new(opts).tap do |pbm|
    pbm.vcSessionCookie = vim.cookie.split('"')[1]
  end
end

Instance Method Details

#pretty_print(pp) ⇒ Object



60
61
62
# File 'lib/rbvmomi/pbm.rb', line 60

def pretty_print pp
  pp.text "PBM(#{@opts[:host]})"
end

#rev=(x) ⇒ Object



42
43
44
45
# File 'lib/rbvmomi/pbm.rb', line 42

def rev= x
  super
  @serviceContent = nil
end

#serviceContentObject

Alias to serviceInstance.PbmRetrieveServiceContent



55
56
57
# File 'lib/rbvmomi/pbm.rb', line 55

def serviceContent
  @serviceContent ||= serviceInstance.PbmRetrieveServiceContent
end

#serviceInstanceObject

Return the ServiceInstance

The ServiceInstance is the root of the vSphere inventory.



50
51
52
# File 'lib/rbvmomi/pbm.rb', line 50

def serviceInstance
  @serviceInstance ||= VIM::PbmServiceInstance self, 'ServiceInstance'
end

#vcSessionCookie=(cookie) ⇒ Object



38
39
40
# File 'lib/rbvmomi/pbm.rb', line 38

def vcSessionCookie= cookie
  @vcSessionCookie = cookie
end