Class: VagrantPlugins::Skytap::Action::InitializeAPIClient

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-skytap/action/initialize_api_client.rb

Overview

This action initializes the API client, verifies the provided credentials, and stores the API client object in env.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ InitializeAPIClient

Returns a new instance of InitializeAPIClient.


10
11
12
13
# File 'lib/vagrant-skytap/action/initialize_api_client.rb', line 10

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new("vagrant_skytap::action::initialize_api_client")
end

Instance Method Details

#call(env) ⇒ Object


15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant-skytap/action/initialize_api_client.rb', line 15

def call(env)
  @logger.info("Connecting to Skytap...")

  client = API::Client.new(env[:machine].provider_config)
  if client.get('/configurations').code == '200'
    env[:api_client] = client
  end

  @app.call(env)
end