Class: VagrantPlugins::Google::Action::ConnectGoogle
- Inherits:
-
Object
- Object
- VagrantPlugins::Google::Action::ConnectGoogle
- Defined in:
- lib/vagrant-google/action/connect_google.rb
Overview
This action connects to Google, verifies credentials work, and puts the Google connection object into the ‘:google_compute` key in the environment.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ConnectGoogle
constructor
A new instance of ConnectGoogle.
Constructor Details
#initialize(app, env) ⇒ ConnectGoogle
Returns a new instance of ConnectGoogle.
24 25 26 27 |
# File 'lib/vagrant-google/action/connect_google.rb', line 24 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_google::action::connect_google") end |
Instance Method Details
#call(env) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vagrant-google/action/connect_google.rb', line 29 def call(env) provider_config = env[:machine].provider_config # Build the fog config fog_config = { :provider => :google, :google_project => provider_config.google_project_id, :google_client_email => provider_config.google_client_email, :google_key_location => provider_config.google_key_location } @logger.info("Connecting to Google...") env[:google_compute] = Fog::Compute.new(fog_config) @app.call(env) @logger.info("...Connected!") end |