Class: VagrantPlugins::HP::Action::ConnectHP
- Inherits:
-
Object
- Object
- VagrantPlugins::HP::Action::ConnectHP
- Defined in:
- lib/vagrant-hp/action/connect_hp.rb
Overview
This action connects to HP, verifies credentials work, and puts the HP connection object into the ‘:hp_compute` key in the environment.
Instance Method Summary collapse
- #availability_zone(availability_zone) ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ConnectHP
constructor
A new instance of ConnectHP.
Constructor Details
#initialize(app, env) ⇒ ConnectHP
Returns a new instance of ConnectHP.
16 17 18 19 |
# File 'lib/vagrant-hp/action/connect_hp.rb', line 16 def initialize(app, env) @app = app @logger = Log4r::Logger.new('vagrant_hp::action::connect_hp') end |
Instance Method Details
#availability_zone(availability_zone) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/vagrant-hp/action/connect_hp.rb', line 42 def availability_zone(availability_zone) case availability_zone when 'us-east' return 'region-b.geo-1' else return 'region-a.geo-1' end end |
#call(env) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vagrant-hp/action/connect_hp.rb', line 21 def call(env) # Get the configs config = env[:machine].provider_config access_key = config.access_key secret_key = config.secret_key tenant_id = config.tenant_id availability_zone = availability_zone(config.availability_zone) @logger.info('Connecting to HP...') env[:hp_compute] = Fog::Compute.new( provider: 'HP', version: 'v2', hp_access_key: access_key, hp_secret_key: secret_key, hp_tenant_id: tenant_id, hp_avl_zone: availability_zone, ) @app.call(env) end |