Sha256: 7234bf475abb096b631ea7f84a7009658646dc9a171b01468cbb905f201e26ed

Contents?: true

Size: 826 Bytes

Versions: 4

Compression:

Stored size: 826 Bytes

Contents

require "log4r"

module VagrantPlugins
  module Shell
    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_shell::action::read_ssh_info")
        end

        def call(env)
          env[:machine_ssh_info] = read_ssh_info(env[:machine])

          @app.call(env)
        end

        def read_ssh_info(machine)
          return nil if machine.id.nil?

          # Read the DNS info
          host,port = `#{machine.provider_config.script} ssh-info #{machine.id}`.split(/\s+/)[0,2]
          return {
            :host => host,
            :port => port
          }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-shell-0.2.6 lib/vagrant-shell/action/read_ssh_info.rb
vagrant-shell-0.2.5 lib/vagrant-shell/action/read_ssh_info.rb
vagrant-shell-0.2.4 lib/vagrant-shell/action/read_ssh_info.rb
vagrant-shell-0.2.3 lib/vagrant-shell/action/read_ssh_info.rb