Class: VagrantPlugins::MCS::Action::ConnectMCS
- Inherits:
-
Object
- Object
- VagrantPlugins::MCS::Action::ConnectMCS
- Defined in:
- lib/vagrant-mcs/action/connect_mcs.rb
Overview
This action connects to MCS, verifies credentials work, and puts the MCS connection object into the ‘:mcs_compute` key in the environment.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ConnectMCS
constructor
A new instance of ConnectMCS.
Constructor Details
#initialize(app, env) ⇒ ConnectMCS
Returns a new instance of ConnectMCS.
12 13 14 15 |
# File 'lib/vagrant-mcs/action/connect_mcs.rb', line 12 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_mcs::action::connect_mcs") end |
Instance Method Details
#call(env) ⇒ Object
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 |
# File 'lib/vagrant-mcs/action/connect_mcs.rb', line 17 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) # Build the fog config fog_config = { :provider => :mcs, :region => region } if region_config.use_iam_profile fog_config[:use_iam_profile] = true else fog_config[:mcs_access_key_id] = region_config.access_key_id fog_config[:mcs_secret_access_key] = region_config.secret_access_key fog_config[:mcs_secret_url] = region_config.secret_access_url #fog_config[:mcs_session_token] = region_config.session_token end fog_config[:endpoint] = region_config.endpoint if region_config.endpoint fog_config[:version] = region_config.version if region_config.version @logger.info("Connecting to MCS...") #env[:mcs_compute] = Fog::Compute.new(fog_config) env[:mcs_compute] = MosSdk::Client.new(region_config.access_key_id, region_config.secret_access_key, region_config.secret_access_url) # env[:mcs_elb] = Fog::MCS::ELB.new(fog_config.except(:provider, :endpoint)) @app.call(env) end |