Class: VagrantPlugins::ProfitBricks::Action::ConnectProfitBricks

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-profitbricks/action/connect_profitbricks.rb

Overview

This action connects to ProfitBricks and verifies that the credentials work

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ ConnectProfitBricks

Returns a new instance of ConnectProfitBricks.



11
12
13
14
# File 'lib/vagrant-profitbricks/action/connect_profitbricks.rb', line 11

def initialize(app, _env)
  @app    = app
  @logger = Log4r::Logger.new('vagrant_profitbricks::action::connect_profitbricks')
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vagrant-profitbricks/action/connect_profitbricks.rb', line 16

def call(env)
  # Get the configs
  config = env[:machine].provider_config
  password = config.password
  username = config.username
  params = {
    provider: 'ProfitBricks',
    profitbricks_password: password,
    profitbricks_username: username,
    profitbricks_user_agent: I18n.t('vagrant_profitbricks.version')
  }

  if config.profitbricks_url
    @logger.info('Connecting to ProfitBricks Cloud API...')
    params[:profitbricks_url] = config.profitbricks_url
  end

  env[:profitbricks_compute] = Fog::Compute.new params
  @logger.info('env[:profitbricks_compute]: ' + env[:profitbricks_compute].to_s)

  @app.call(env)
end