Class: VagrantPlugins::VCenter::Action::ConnectvCenter

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-vcenter/action/connect_vcenter.rb

Overview

This class connects the vagrant-vcenter provider to vCenter.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ConnectvCenter

Returns a new instance of ConnectvCenter.



9
10
11
12
13
# File 'lib/vagrant-vcenter/action/connect_vcenter.rb', line 9

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new(
              'vagrant_vcenter::action::connect_vCenter')
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-vcenter/action/connect_vcenter.rb', line 15

def call(env)
  config = env[:machine].provider_config
  # Avoid recreating a new session each time.
  unless config.vcenter_cnx
    @logger.info('Connecting to vCenter...')

    @logger.debug("config.hostname: #{config.hostname}")
    @logger.debug("config.username: #{config.username}")
    @logger.debug('config.password: <hidden>')

    # FIXME: fix the insecure flag, catch the exception
    config.vcenter_cnx = RbVmomi::VIM.connect(
                          host: config.hostname,
                          user: config.username,
                          password: config.password,
                          insecure: true)
  end
  @app.call env
end