Class: VagrantPlugins::Openstack::Action::ConnectOpenstack

Inherits:
AbstractAction
  • Object
show all
Includes:
Catalog, HttpUtils::RequestLogger
Defined in:
lib/vagrant-openstack-illuin-provider/action/connect_openstack.rb

Instance Method Summary collapse

Methods included from HttpUtils::RequestLogger

#log_request, #log_response

Methods inherited from AbstractAction

#call

Constructor Details

#initialize(app, env, catalog_reader = OpenstackCatalog.new) ⇒ ConnectOpenstack

Returns a new instance of ConnectOpenstack.



16
17
18
19
20
21
# File 'lib/vagrant-openstack-illuin-provider/action/connect_openstack.rb', line 16

def initialize(app, env, catalog_reader = OpenstackCatalog.new)
  @app = app
  @logger = Log4r::Logger.new('vagrant_openstack::action::connect_openstack')
  @catalog_reader = catalog_reader
  env[:openstack_client] = VagrantPlugins::Openstack
end

Instance Method Details

#execute(env) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-openstack-illuin-provider/action/connect_openstack.rb', line 23

def execute(env)
  client = env[:openstack_client]
  if client.session.token.nil?
    catalog = client.keystone.authenticate(env)
    @catalog_reader.read(env, catalog)
    override_endpoint_catalog_with_user_config(env)
    check_configuration(env)
    log_endpoint_catalog(env)
  end
  @app.call(env) unless @app.nil?
end