Sha256: f4f363cf7a31642d14c7e079646e0d3738114b8ae59c28ef495ee3db6902a3b2

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

require "log4r"
require "vagrant-skytap/api/client"

module VagrantPlugins
  module Skytap
    module Action
      # This action initializes the API client, verifies the provided
      # credentials, and stores the API client object in env[:api_client].
      class InitializeAPIClient
        def initialize(app, env)
          @app = app
          @logger = Log4r::Logger.new("vagrant_skytap::action::initialize_api_client")
        end

        def call(env)
          unless env[:api_client]
            @logger.info("Connecting to Skytap...")
            client = API::Client.new(env[:machine].provider_config)
            if client.get('/configurations').code == '200'
              env[:api_client] = client
            end
          end

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-skytap-0.2.3 lib/vagrant-skytap/action/initialize_api_client.rb