Sha256: d1a6a8f469d50648c1248bcd6d2807f08b38bbbce25386a4f6e10d432d399c94

Contents?: true

Size: 1.07 KB

Versions: 10

Compression:

Stored size: 1.07 KB

Contents

require "log4r"

module VagrantPlugins
  module G5K
    module Action
      # This action reads the SSH info for the machine and puts it into the
      # `:machine_ssh_info` key in the environment.
      class ReadSSHInfo
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_g5k::action::read_ssh_info")
        end

        def call(env)
          conn = env[:g5k_connection]
          ssh_info = conn.vm_ssh_info(env[:machine].id)
          username = env[:machine].provider_config.username
          gateway = env[:machine].provider_config.gateway
          if !env[:machine].provider_config.gateway.nil?
            ssh_info[:proxy_command] = "ssh #{username}@#{gateway} #{ssh_key(env)} nc %h %p"
          end
          env[:machine_ssh_info] = ssh_info

          @app.call(env)
        end

        def ssh_key(env)
          private_key = env[:machine].provider_config.private_key
          if private_key.nil?
            ""
          else
             "-i #{private_key}"
          end
        end
      
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
vagrant-g5k-0.9.9 lib/vagrant-g5k/action/read_ssh_info.rb
vagrant-g5k-0.9.8 lib/vagrant-g5k/action/read_ssh_info.rb
vagrant-g5k-0.9.7 lib/vagrant-g5k/action/read_ssh_info.rb
vagrant-g5k-0.9.6 lib/vagrant-g5k/action/read_ssh_info.rb
vagrant-g5k-0.9.5 lib/vagrant-g5k/action/read_ssh_info.rb
vagrant-g5k-0.9.4 lib/vagrant-g5k/action/read_ssh_info.rb
vagrant-g5k-0.9.3 lib/vagrant-g5k/action/read_ssh_info.rb
vagrant-g5k-0.9.2 lib/vagrant-g5k/action/read_ssh_info.rb
vagrant-g5k-0.9.1 lib/vagrant-g5k/action/read_ssh_info.rb
vagrant-g5k-0.9.0 lib/vagrant-g5k/action/read_ssh_info.rb