Sha256: 8f3521d7e79612841ea8f2a70c4ba2d02162fd9b2b37e3c2d6db0ac777c0cf6d

Contents?: true

Size: 1.39 KB

Versions: 29

Compression:

Stored size: 1.39 KB

Contents

#require 'net/ssh/multi'

module Veewee
  module Provider
    module Core
      module ProviderCommand


      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

        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
              ui.info "Forwarding remote port #{forwarding[:remote_port]} from #{box_name} to local port #{forwarding[:local_port]}"
              ui.info host
              ui.info user
              ui.info ""
              ssh_session.forward.local(forwarding[:local_port], "127.0.0.1",forwarding[:remote_port])
            rescue Errno::EACCES
              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
        }
        ui.info @forward_threads.first.status
        @forward_threads.first.run
        ui.info @forward_threads.first.status

      end

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

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
veewee-0.5.0.alpha4 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.5.0.alpha3 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.5.0.alpha2 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.5.0.alpha1 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.4.5.1 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.4.5 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.4.5.pre1 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.4.4 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.4.3 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.4.2 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.4.1 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.4.0 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.3.12 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.3.11 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.3.10 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.3.9 lib/veewee/provider/core/provider/tunnel.rb
veewee-atlassian-0.3.11 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.3.7 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.3.6 lib/veewee/provider/core/provider/tunnel.rb
veewee-0.3.5 lib/veewee/provider/core/provider/tunnel.rb