Sha256: 6c3091d11a0b2b839ab16ebc1cf73885e8306b597b35130526ade7fadc1e84b9

Contents?: true

Size: 1.97 KB

Versions: 14

Compression:

Stored size: 1.97 KB

Contents

# Copyright (c) 2012 VMware, Inc.  All Rights Reserved.
require 'rbvmomi'

module RbVmomi

# A connection to one vSphere ProfileBasedManagement endpoint.
# @see #serviceInstance
class PBM < Connection
  # Connect to a vSphere ProfileBasedManagement endpoint
  #
  # @param [VIM] Connection to main vSphere API endpoint
  # @param [Hash] opts The options hash.
  # @option opts [String]  :host Host to connect to.
  # @option opts [Numeric] :port (443) Port to connect to.
  # @option opts [Boolean] :ssl (true) Whether to use SSL.
  # @option opts [Boolean] :insecure (false) If true, ignore SSL certificate errors.
  # @option opts [String]  :path (/pbm/sdk) SDK endpoint path.
  # @option opts [Boolean] :debug (false) If true, print SOAP traffic to stderr.
  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
  
  def vcSessionCookie= cookie
    @vcSessionCookie = cookie
  end

  def rev= x
    super
    @serviceContent = nil
  end

  # Return the ServiceInstance
  #
  # The ServiceInstance is the root of the vSphere inventory.
  def serviceInstance
    @serviceInstance ||= VIM::PbmServiceInstance self, 'ServiceInstance'
  end

  # Alias to serviceInstance.PbmRetrieveServiceContent
  def serviceContent
    @serviceContent ||= serviceInstance.PbmRetrieveServiceContent
  end

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

  add_extension_dir File.join(File.dirname(__FILE__), "pbm")
  load_vmodl(ENV['VMODL'] || File.join(File.dirname(__FILE__), "../../vmodl.db"))
end

end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
rbvmomi-1.8.5 lib/rbvmomi/pbm.rb
rbvmomi-1.8.4 lib/rbvmomi/pbm.rb
rbvmomi-1.8.3 lib/rbvmomi/pbm.rb
rbvmomi-1.9.4 lib/rbvmomi/pbm.rb
rbvmomi-1.9.3 lib/rbvmomi/pbm.rb
rbvmomi-1.9.2 lib/rbvmomi/pbm.rb
rbvmomi-1.9.1 lib/rbvmomi/pbm.rb
rbvmomi-1.9.0 lib/rbvmomi/pbm.rb
rbvmomi-1.8.2 lib/rbvmomi/pbm.rb
rbvmomi-1.8.2.pre lib/rbvmomi/pbm.rb
mkuzmin-rbvmomi-1.8.2.1 lib/rbvmomi/pbm.rb
vagrant-rbvmomi-1.8.1 lib/rbvmomi/pbm.rb
rbvmomi-1.8.1 lib/rbvmomi/pbm.rb
rbvmomi-1.8.0 lib/rbvmomi/pbm.rb