Sha256: ea826b07bf1bc9ce50d7ab92d2d6ffe75fc6f275e9e19fc03c05d8ebc9c40c75

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require "fog"
require "log4r"

module VagrantPlugins
  module Rackspace
    module Action
      # This action connects to Rackspace, verifies credentials work, and
      # puts the Rackspace connection object into the `:rackspace_compute` key
      # in the environment.
      class ConnectRackspace
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_rackspace::action::connect_rackspace")
        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 Rackspace...")
          env[:rackspace_compute] = Fog::Compute.new({
            :provider => :rackspace,
            :version  => :v2,
            :rackspace_api_key => api_key,
            :rackspace_endpoint => endpoint,
            :rackspace_username => username
          })

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-rackspace-0.1.1 lib/vagrant-rackspace/action/connect_rackspace.rb
vagrant-rackspace-0.1.0 lib/vagrant-rackspace/action/connect_rackspace.rb