Class: PuppetX::Puppetlabs::Transport::Vsphere

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/puppetlabs/transport/vsphere.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Vsphere

Returns a new instance of Vsphere.



9
10
11
12
13
14
15
16
17
# File 'lib/puppet_x/puppetlabs/transport/vsphere.rb', line 9

def initialize(opts)
  @name    = opts[:name]
  options  = opts[:options] || {}
  @options = options.inject({}){|h, (k, v)| h[k.to_sym] = v; h}
  @options[:host]     = opts[:server]
  @options[:user]     = opts[:username]
  @options[:password] = opts[:password]
  Puppet.debug("#{self.class} initializing connection to: #{@options[:host]}")
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/puppet_x/puppetlabs/transport/vsphere.rb', line 7

def name
  @name
end

#vimObject

Returns the value of attribute vim.



6
7
8
# File 'lib/puppet_x/puppetlabs/transport/vsphere.rb', line 6

def vim
  @vim
end

Instance Method Details

#closeObject



23
24
25
26
# File 'lib/puppet_x/puppetlabs/transport/vsphere.rb', line 23

def close
  Puppet.debug("#{self.class} closing connection to: #{@options[:host]}")
  @vim.close if @vim
end

#connectObject



19
20
21
# File 'lib/puppet_x/puppetlabs/transport/vsphere.rb', line 19

def connect
  @vim ||= RbVmomi::VIM.connect(@options)
end