Sha256: 8be058bc6938c942a29cb4aff170b22b0165588ff6e734c12b3d95275c27105b

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require "fog/profitbricks"
require "log4r"

module VagrantPlugins
  module ProfitBricks
    module Action
      # This action connects to ProfitBricks and verifies that the credentials work
      class ConnectProfitBricks
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_profitbricks::action::connect_profitbricks")
        end

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

          params = {
            :provider => 'ProfitBricks',
            :profitbricks_password => password,
            :profitbricks_username => username
          }

          if config.profitbricks_url
            @logger.info("Connecting to ProfitBricks profitbricks_url...")
            params[:profitbricks_url] = config.profitbricks_url
          end

          env[:profitbricks_compute] = Fog::Compute.new params
          @logger.info("env[:profitbricks_compute]: " + env[:profitbricks_compute].to_s)

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-profitbricks-1.0.0 lib/vagrant-profitbricks/action/connect_profitbricks.rb