Class: VagrantPlugins::OpenStack::Action::ConnectOpenStack
- Inherits:
-
Object
- Object
- VagrantPlugins::OpenStack::Action::ConnectOpenStack
- Defined in:
- lib/vagrant-openstack-plugin/action/connect_openstack.rb
Overview
This action connects to OpenStack, verifies credentials work, and puts the OpenStack connection object into the ‘:openstack_compute` key in the environment.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ConnectOpenStack
constructor
A new instance of ConnectOpenStack.
Constructor Details
#initialize(app, env) ⇒ ConnectOpenStack
11 12 13 14 |
# File 'lib/vagrant-openstack-plugin/action/connect_openstack.rb', line 11 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_openstack::action::connect_openstack") 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/vagrant-openstack-plugin/action/connect_openstack.rb', line 16 def call(env) # Get the configs config = env[:machine].provider_config api_key = config.api_key endpoint = config.endpoint username = config.username tenant = config.tenant region = config.region # Pass proxy config down into the Fog::Connection object using # the `connection_options` hash. = { :proxy => config.proxy, :ssl_verify_peer => config.ssl_verify_peer } # Prepare connection parameters for use with fog service # initialization (compute, storage, orchestration, ...). env[:fog_openstack_params] = { :provider => :openstack, :connection_options => , :openstack_username => username, :openstack_api_key => api_key, :openstack_auth_url => endpoint, :openstack_tenant => tenant, :openstack_region => region } @logger.info("Connecting to OpenStack...") @logger.debug("API connection params: #{connection_options.inspect}") env[:openstack_compute] = Fog::Compute.new( env[:fog_openstack_params]) if config.network || (config.networks && !config.networks.empty?) env[:openstack_network] = Fog::Network.new({ :provider => :openstack, :connection_options => , :openstack_username => username, :openstack_api_key => api_key, :openstack_auth_url => endpoint, :openstack_tenant => tenant, :openstack_region => region }) end if config.disks && !config.disks.empty? env[:openstack_volume] = Fog::Volume.new({ :provider => :openstack, :connection_options => , :openstack_username => username, :openstack_api_key => api_key, :openstack_auth_url => endpoint, :openstack_tenant => tenant, :openstack_region => region }) end @app.call(env) end |