Class: VagrantPlugins::Brightbox::Action::ConnectBrightbox
- Inherits:
-
Object
- Object
- VagrantPlugins::Brightbox::Action::ConnectBrightbox
- Defined in:
- lib/vagrant-brightbox/action/connect_brightbox.rb
Overview
This action connects to Brightbox, verifies credentials work, and puts the Brightbox connection object into the ‘:brightbox_compute` key in the environment.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ConnectBrightbox
constructor
A new instance of ConnectBrightbox.
Constructor Details
#initialize(app, env) ⇒ ConnectBrightbox
Returns a new instance of ConnectBrightbox.
11 12 13 14 |
# File 'lib/vagrant-brightbox/action/connect_brightbox.rb', line 11 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_brightbox::action::connect_brightbox") 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 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vagrant-brightbox/action/connect_brightbox.rb', line 16 def call(env) # Get the region we're going to booting up in region = env[:machine].provider_config.region # Get the configs region_config = env[:machine].provider_config.get_region_config(region) client_id = region_config.client_id client_secret = region_config.secret username = region_config.username password = region_config.password account = region_config.account auth_url = region_config.auth_url api_url = region_config.api_url @logger.info("Connecting to Brightbox...") @logger.info("Fog credentials are: #{Fog.credentials.inspect}") ={ :provider => :brightbox, :brightbox_auth_url => auth_url, :brightbox_api_url => api_url, :brightbox_client_id => client_id, :brightbox_secret => client_secret, :brightbox_username => username, :brightbox_password => password, :brightbox_account => account, } .delete_if {|k, v| v.nil? } @logger.info("Fog compute options are: #{.inspect}") env[:brightbox_compute] = Fog::Compute.new() @app.call(env) rescue ArgumentError => e raise Errors::FogError, :message => e. end |