Sha256: 140e24baa296252ab9d7bc3d11c4777449f5af7b66de136591ee0e734d505d74

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

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)
          cfg = env[:machine].provider_config

          # Avoid recreating a new session each time.
          unless cfg.vcenter_cnx
            @logger.info('Connecting to vCenter...')

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

            # FIXME: fix the insecure flag, catch the exception
            cfg.vcenter_cnx = RbVmomi::VIM.connect(
              host: cfg.hostname,
              user: cfg.username,
              password: cfg.password,
              insecure: true
            )

          end
          @app.call env
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-vcenter-0.3.3 lib/vagrant-vcenter/action/connect_vcenter.rb