Class: VagrantPlugins::Scaleway::Action::ConnectScaleway

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-scaleway/action/connect_scaleway.rb

Overview

This action connects to Scaleway, verifies credentials work, and puts the Scaleway connection object into the ‘:scaleway_compute` key in the environment.

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ ConnectScaleway

Returns a new instance of ConnectScaleway.



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

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

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vagrant-scaleway/action/connect_scaleway.rb', line 15

def call(env)
  # Get the configs
  provider_config = env[:machine].provider_config

  # Build the fog config
  fog_config = {
    provider:              :scaleway,
    scaleway_organization: provider_config.organization,
    scaleway_token:        provider_config.token,
    scaleway_region:       provider_config.region
  }

  @logger.info('Connecting to Scaleway...')
  env[:scaleway_compute] = Fog::Compute.new(fog_config)

  @app.call(env)
end