Sha256: a8296680b1ada7fdc2863b96c4cfdf6cbf3cd2629aac92b040c2ee2db783539c

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require "fog"
require "log4r"

module VagrantPlugins
  module OpenStack
    module Action
      # This action connects to OpenStack, verifies credentials work, and
      # puts the OpenStack connection object into the `:openstack_compute` key
      # in the environment.
      class ConnectOpenStack
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_openstack::action::connect_openstack")
        end

        def call(env)
          # Get the configs
          config   = env[:machine].provider_config
          api_key  = config.api_key
          endpoint = config.endpoint
          username = config.username

          @logger.info("Connecting to OpenStack...")
          env[:openstack_compute] = Fog::Compute.new({
            :provider => :openstack,
            :openstack_username => username,
            :openstack_api_key => api_key,
            :openstack_auth_url => endpoint
          })

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-openstack-plugin-0.1.2 lib/vagrant-openstack-plugin/action/connect_openstack.rb
vagrant-openstack-plugin-0.1.1 lib/vagrant-openstack/action/connect_openstack.rb