Sha256: db4f202bbaed36ecc38908f2a08f3546da3ce058773155fc5173d518f8ed7da8

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

require 'rbvmomi'
require 'log4r'

module VagrantPlugins
  module VCenter
    module Action
      # This class connects the vagrant-vcenter provider to vCenter.
      class ConnectvCenter
        def initialize(app, env)
          @app = app
          @logger = Log4r::Logger.new(
                      'vagrant_vcenter::action::connect_vCenter')
        end

        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
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vagrant-vcenter-0.3.2 lib/vagrant-vcenter/action/connect_vcenter.rb
vagrant-vcenter-0.3.1 lib/vagrant-vcenter/action/connect_vcenter.rb
vagrant-vcenter-0.3.0 lib/vagrant-vcenter/action/connect_vcenter.rb
vagrant-vcenter-0.2.1 lib/vagrant-vcenter/action/connect_vcenter.rb
vagrant-vcenter-0.2.0 lib/vagrant-vcenter/action/connect_vcenter.rb
vagrant-vcenter-0.1.1 lib/vagrant-vcenter/action/connect_vcenter.rb