Sha256: 9ac7a40753f9947de42ce0ba3423a0c44e1be49e0a07ab842ca7dad33042993a

Contents?: true

Size: 924 Bytes

Versions: 4

Compression:

Stored size: 924 Bytes

Contents

require "log4r"
require 'vagrant-xhyve/util/vagrant-xhyve'

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

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

          @app.call(env)
        end

        def read_ssh_info(env)
          return nil if env[:machine].id.nil?

          machine_info_path = File.join(env[:machine].data_dir, "xhyve.json")
          machine_json = File.read(machine_info_path)
          machine_options = JSON.parse(machine_json, :symbolize_names => true)

          return { :host => machine_options[:ip], :port => 22 }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-xhyve-0.2.0 lib/vagrant-xhyve/action/read_ssh_info.rb
vagrant-xhyve-0.1.1 lib/vagrant-xhyve/action/read_ssh_info.rb
vagrant-xhyve-0.1.1.pre lib/vagrant-xhyve/action/read_ssh_info.rb
vagrant-xhyve-0.1.0.pre lib/vagrant-xhyve/action/read_ssh_info.rb