Class: VagrantPlugins::ArubaCloud::Action::ConnectArubaCloud

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-arubacloud/action/connect_arubacloud.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ConnectArubaCloud

Returns a new instance of ConnectArubaCloud.



9
10
11
12
# File 'lib/vagrant-arubacloud/action/connect_arubacloud.rb', line 9

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new('vagrant_arubacloud::action::connect_arubacloud')
end

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  # Set the datacenter
  config = env[:machine].provider_config
  arubacloud_username = config.arubacloud_username
  arubacloud_password = config.arubacloud_password
  arubacloud_dc = config.endpoint

  params = {
      :provider => :arubacloud,
      :arubacloud_username => arubacloud_username,
      :arubacloud_password => arubacloud_password,
  }

  if config.url
    @logger.info("Connecting to Datacenter: #{arubacloud_dc}  url: #{config.url} ")
    params[:url] = config.url
  end

  env[:arubacloud_compute] = Fog::Compute.new params

  @app.call(env)
end