Sha256: 260cb50a245df09481970b4c4324803488b3b89f5dac0ed038fd3091bcb4b0b7

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

#require 'net/ssh/multi'

module Veewee
  module Builder
    module Core
      module BuilderCommand


      def ssh_tunnel_start(forwardings)
        #ssh_options={ :keys => [ vm.private_key ], :paranoid => false, :keys_only => true}

        ssh_options={ :paranoid => false}
        host=@connection.uri.host
        user=@connection.uri.user

        env.ui.info "Enabling tunneling"
        @forward_threads=Array.new
        @forward_threads<< Thread.new {
          Net::SSH.start(host, user, ssh_options) do |ssh_session|
          forwardings.each do |forwarding|
            begin
              env.ui.info "Forwarding remote port #{forwarding[:remote_port]} from #{box_name} to local port #{forwarding[:local_port]}"
              env.ui.info host
              env.ui.info user
              env.ui.info ""
              ssh_session.forward.local(forwarding[:local_port], "127.0.0.1",forwarding[:remote_port])
            rescue Errno::EACCES
              env.ui.info "  Error - Access denied to forward remote port #{forwarding[:remote_port]} from #{name} to local port #{forwarding[:local_port]}"
            end
          end
          ssh_session.loop {true}
          end
        }
        env.ui.info @forward_threads.first.status
        @forward_threads.first.run
        env.ui.info @forward_threads.first.status

      end

      def ssh_tunnel_stop
        Thread.kill(@forward_threads.first)
      end
    end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veewee-0.3.0.alpha4 lib/veewee/builder/core/builder/tunnel.rb
veewee-0.3.0.alpha3 lib/veewee/builder/core/builder/tunnel.rb
veewee-0.3.0.alpha2 lib/veewee/builder/core/builder/tunnel.rb
veewee-0.3.0.alpha1 lib/veewee/builder/core/builder/tunnel.rb