vagrant-skytap 0.1.11 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.byebug_history +242 -19
- data/CHANGELOG.md +9 -0
- data/README.md +30 -8
- data/Vagrantfile.rej +83 -0
- data/_patches-20160112/0 +388 -0
- data/_patches-20160112/1 +82 -0
- data/_patches-20160112/2 +239 -0
- data/_patches-20160112/COMPLETED-ABOVE-THIS-LINE +4 -0
- data/_patches-20160112/COMPLETED-BELOW-THIS-LINE +4 -0
- data/_patches-20160112/CR-ABOVE-THIS-LINE +4 -0
- data/_patches-20160112/CR-BELOW-THIS-LINE +4 -0
- data/_patches-20160112/WIP-ABOVE-THIS-LINE +4 -0
- data/_patches-20160112/WIP-BELOW-THIS-LINE +4 -0
- data/_patches-20160112/acceptance-test-runner +29 -0
- data/_patches-20160112/ansible-1 +92 -0
- data/_patches-20160112/cache-api-client-in-up +40 -0
- data/_patches-20160112/dead-code-in-actions +44 -0
- data/_patches-20160112/debug-changes +42 -0
- data/_patches-20160112/demo-rails-app +1276 -0
- data/_patches-20160112/eng-10166-halt-spec +40 -0
- data/_patches-20160112/eng-10256 +527 -0
- data/_patches-20160112/eng-10256-2 +162 -0
- data/_patches-20160112/eng-10256-ubuntu-testing +88 -0
- data/_patches-20160112/eng-10269-test-stuff +87 -0
- data/_patches-20160112/eng-10269-wtf +119 -0
- data/_patches-20160112/eng-10369 +143 -0
- data/_patches-20160112/eng-10369-tmp +60 -0
- data/_patches-20160112/eng-10919 +56 -0
- data/_patches-20160112/eng-11177-fix-actions-requires +44 -0
- data/_patches-20160112/eng-11442 +4 -0
- data/_patches-20160112/eng-11616 +403 -0
- data/_patches-20160112/eng-11616-2 +67 -0
- data/_patches-20160112/eng-11616-actual +184 -0
- data/_patches-20160112/eng-11625a +4 -0
- data/_patches-20160112/eng-11711 +85 -0
- data/_patches-20160112/eng-12232-command-spec +236 -0
- data/_patches-20160112/eng-12235 +83 -0
- data/_patches-20160112/eng-12235-override-refactor +140 -0
- data/_patches-20160112/eng-12240 +103 -0
- data/_patches-20160112/eng-12249 +40 -0
- data/_patches-20160112/eng-12301 +50 -0
- data/_patches-20160112/eng-12843 +95 -0
- data/_patches-20160112/env-source +112 -0
- data/_patches-20160112/frickin-vagrant-spec +163 -0
- data/_patches-20160112/gem-pre-version +14 -0
- data/_patches-20160112/gems-old +9 -0
- data/_patches-20160112/googles-specs +713 -0
- data/_patches-20160112/local-configs-ignore +61 -0
- data/_patches-20160112/misc +79 -0
- data/_patches-20160112/network-unreachable +31 -0
- data/_patches-20160112/new-boxfile +288 -0
- data/_patches-20160112/parallelization-maybe +198 -0
- data/_patches-20160112/read-state +23 -0
- data/_patches-20160112/refactor-to-use-public_address-cap +25 -0
- data/_patches-20160112/series +60 -0
- data/_patches-20160112/status +12 -0
- data/_patches-20160112/test-move-env-data +231 -0
- data/_patches-20160112/test-vagrantfile-vm1 +167 -0
- data/_patches-20160112/the_version_in_0.1.13.pre1 +598 -0
- data/_patches-20160112/vagrant-spec-mock-api +137 -0
- data/_patches-20160112/vagrant-vmware-plugin +233 -0
- data/_patches-20160112/vagrantfile +403 -0
- data/_patches-20160112/vagrantfile-for-acceptance-tests +29 -0
- data/_patches-20160112/vagrantfile-for-nick +95 -0
- data/_patches-20160112/vagrantfiles-to-forget-what-they-are-for +134 -0
- data/_patches-20160112/vm-vanished +42 -0
- data/_patches-20160112a/01 +148 -0
- data/_patches-20160112a/2 +239 -0
- data/_patches-20160112a/COMPLETED-ABOVE-THIS-LINE +4 -0
- data/_patches-20160112a/COMPLETED-BELOW-THIS-LINE +4 -0
- data/_patches-20160112a/CR-ABOVE-THIS-LINE +4 -0
- data/_patches-20160112a/CR-BELOW-THIS-LINE +4 -0
- data/_patches-20160112a/WIP-ABOVE-THIS-LINE +4 -0
- data/_patches-20160112a/WIP-BELOW-THIS-LINE +4 -0
- data/_patches-20160112a/acceptance-test-runner +29 -0
- data/_patches-20160112a/ansible-1 +92 -0
- data/_patches-20160112a/cache-api-client-in-up +40 -0
- data/_patches-20160112a/dead-code-in-actions +44 -0
- data/_patches-20160112a/debug-changes +42 -0
- data/_patches-20160112a/demo-rails-app +1276 -0
- data/_patches-20160112a/eng-10166-halt-spec +40 -0
- data/_patches-20160112a/eng-10256-ubuntu-testing +88 -0
- data/_patches-20160112a/eng-10269-test-stuff +87 -0
- data/_patches-20160112a/eng-10269-wtf +119 -0
- data/_patches-20160112a/eng-10369 +143 -0
- data/_patches-20160112a/eng-10369-tmp +60 -0
- data/_patches-20160112a/eng-10919 +56 -0
- data/_patches-20160112a/eng-11177-fix-actions-requires +44 -0
- data/_patches-20160112a/eng-11442 +4 -0
- data/_patches-20160112a/eng-11616 +403 -0
- data/_patches-20160112a/eng-11616-2 +67 -0
- data/_patches-20160112a/eng-11616-actual +184 -0
- data/_patches-20160112a/eng-11625a +4 -0
- data/_patches-20160112a/eng-11711 +85 -0
- data/_patches-20160112a/eng-12232-command-spec +236 -0
- data/_patches-20160112a/eng-12235 +83 -0
- data/_patches-20160112a/eng-12235-override-refactor +140 -0
- data/_patches-20160112a/eng-12240 +103 -0
- data/_patches-20160112a/eng-12249 +40 -0
- data/_patches-20160112a/eng-12301 +50 -0
- data/_patches-20160112a/eng-12843 +95 -0
- data/_patches-20160112a/env-source +112 -0
- data/_patches-20160112a/frickin-vagrant-spec +163 -0
- data/_patches-20160112a/gem-pre-version +14 -0
- data/_patches-20160112a/gems-old +9 -0
- data/_patches-20160112a/googles-specs +713 -0
- data/_patches-20160112a/local-configs-ignore +61 -0
- data/_patches-20160112a/misc +79 -0
- data/_patches-20160112a/network-unreachable +31 -0
- data/_patches-20160112a/new-boxfile +288 -0
- data/_patches-20160112a/parallelization-maybe +198 -0
- data/_patches-20160112a/read-state +23 -0
- data/_patches-20160112a/refactor-to-use-public_address-cap +25 -0
- data/_patches-20160112a/series +58 -0
- data/_patches-20160112a/status +14 -0
- data/_patches-20160112a/test-move-env-data +231 -0
- data/_patches-20160112a/test-vagrantfile-vm1 +167 -0
- data/_patches-20160112a/the_version_in_0.1.13.pre1 +612 -0
- data/_patches-20160112a/then-copy-the-newer-files +632 -0
- data/_patches-20160112a/vagrant-spec-mock-api +137 -0
- data/_patches-20160112a/vagrant-vmware-plugin +233 -0
- data/_patches-20160112a/vagrantfile +403 -0
- data/_patches-20160112a/vagrantfile-for-acceptance-tests +29 -0
- data/_patches-20160112a/vagrantfile-for-nick +95 -0
- data/_patches-20160112a/vagrantfiles-to-forget-what-they-are-for +134 -0
- data/_patches-20160112a/vm-vanished +42 -0
- data/_patches-20160113/COMPLETED-ABOVE-THIS-LINE +4 -0
- data/_patches-20160113/COMPLETED-BELOW-THIS-LINE +4 -0
- data/_patches-20160113/CR-ABOVE-THIS-LINE +4 -0
- data/_patches-20160113/CR-BELOW-THIS-LINE +4 -0
- data/_patches-20160113/WIP-ABOVE-THIS-LINE +4 -0
- data/_patches-20160113/WIP-BELOW-THIS-LINE +4 -0
- data/_patches-20160113/acceptance-test-runner +29 -0
- data/_patches-20160113/ansible-1 +92 -0
- data/_patches-20160113/cache-api-client-in-up +40 -0
- data/_patches-20160113/dead-code-in-actions +44 -0
- data/_patches-20160113/debug-changes +55 -0
- data/_patches-20160113/demo-rails-app +1276 -0
- data/_patches-20160113/eng-10166-halt-spec +40 -0
- data/_patches-20160113/eng-10256 +543 -0
- data/_patches-20160113/eng-10256-ubuntu-testing +88 -0
- data/_patches-20160113/eng-10269-test-stuff +87 -0
- data/_patches-20160113/eng-10269-wtf +119 -0
- data/_patches-20160113/eng-10369 +143 -0
- data/_patches-20160113/eng-10369-tmp +60 -0
- data/_patches-20160113/eng-10919 +56 -0
- data/_patches-20160113/eng-11177-fix-actions-requires +44 -0
- data/_patches-20160113/eng-11442 +4 -0
- data/_patches-20160113/eng-11616 +403 -0
- data/_patches-20160113/eng-11616-2 +67 -0
- data/_patches-20160113/eng-11616-actual +184 -0
- data/_patches-20160113/eng-11625a +4 -0
- data/_patches-20160113/eng-11711 +85 -0
- data/_patches-20160113/eng-12232-command-spec +236 -0
- data/_patches-20160113/eng-12235 +83 -0
- data/_patches-20160113/eng-12235-override-refactor +140 -0
- data/_patches-20160113/eng-12240 +103 -0
- data/_patches-20160113/eng-12249 +40 -0
- data/_patches-20160113/eng-12301 +50 -0
- data/_patches-20160113/eng-12720 +47 -0
- data/_patches-20160113/eng-12843 +95 -0
- data/_patches-20160113/env-source +112 -0
- data/_patches-20160113/frickin-vagrant-spec +163 -0
- data/_patches-20160113/gem-pre-version +14 -0
- data/_patches-20160113/gems-old +9 -0
- data/_patches-20160113/googles-specs +713 -0
- data/_patches-20160113/local-configs-ignore +61 -0
- data/_patches-20160113/misc +79 -0
- data/_patches-20160113/network-unreachable +31 -0
- data/_patches-20160113/new-boxfile +288 -0
- data/_patches-20160113/parallelization-maybe +198 -0
- data/_patches-20160113/read-state +23 -0
- data/_patches-20160113/refactor-to-use-public_address-cap +25 -0
- data/_patches-20160113/series +56 -0
- data/_patches-20160113/status +14 -0
- data/_patches-20160113/test-move-env-data +231 -0
- data/_patches-20160113/test-vagrantfile-vm1 +167 -0
- data/_patches-20160113/vagrant-spec-mock-api +137 -0
- data/_patches-20160113/vagrant-vmware-plugin +233 -0
- data/_patches-20160113/vagrantfile +403 -0
- data/_patches-20160113/vagrantfile-for-acceptance-tests +29 -0
- data/_patches-20160113/vagrantfile-for-nick +95 -0
- data/_patches-20160113/vagrantfiles-to-forget-what-they-are-for +134 -0
- data/_patches-20160113/vm-vanished +42 -0
- data/_patches-20160118/COMPLETED-ABOVE-THIS-LINE +4 -0
- data/_patches-20160118/COMPLETED-BELOW-THIS-LINE +4 -0
- data/_patches-20160118/CR-ABOVE-THIS-LINE +4 -0
- data/_patches-20160118/CR-BELOW-THIS-LINE +4 -0
- data/_patches-20160118/WIP-ABOVE-THIS-LINE +4 -0
- data/_patches-20160118/WIP-BELOW-THIS-LINE +4 -0
- data/_patches-20160118/acceptance-test-runner +29 -0
- data/_patches-20160118/ansible-1 +92 -0
- data/_patches-20160118/cache-api-client-in-up +40 -0
- data/_patches-20160118/dead-code-in-actions +44 -0
- data/_patches-20160118/debug-changes +55 -0
- data/_patches-20160118/demo-rails-app +1276 -0
- data/_patches-20160118/eng-10166-halt-spec +40 -0
- data/_patches-20160118/eng-10256 +554 -0
- data/_patches-20160118/eng-10256-cr +314 -0
- data/_patches-20160118/eng-10256-ubuntu-testing +88 -0
- data/_patches-20160118/eng-10269-test-stuff +87 -0
- data/_patches-20160118/eng-10269-wtf +119 -0
- data/_patches-20160118/eng-10369 +143 -0
- data/_patches-20160118/eng-10369-tmp +60 -0
- data/_patches-20160118/eng-10919 +56 -0
- data/_patches-20160118/eng-11177-fix-actions-requires +44 -0
- data/_patches-20160118/eng-11442 +4 -0
- data/_patches-20160118/eng-11616 +403 -0
- data/_patches-20160118/eng-11616-2 +67 -0
- data/_patches-20160118/eng-11616-actual +184 -0
- data/_patches-20160118/eng-11625a +4 -0
- data/_patches-20160118/eng-11711 +85 -0
- data/_patches-20160118/eng-12232-command-spec +236 -0
- data/_patches-20160118/eng-12235 +83 -0
- data/_patches-20160118/eng-12235-override-refactor +140 -0
- data/_patches-20160118/eng-12240 +103 -0
- data/_patches-20160118/eng-12249 +40 -0
- data/_patches-20160118/eng-12301 +50 -0
- data/_patches-20160118/eng-12720 +74 -0
- data/_patches-20160118/eng-12843 +95 -0
- data/_patches-20160118/eng-13040 +291 -0
- data/_patches-20160118/env-source +112 -0
- data/_patches-20160118/frickin-vagrant-spec +163 -0
- data/_patches-20160118/gem-pre-version +14 -0
- data/_patches-20160118/gems-old +9 -0
- data/_patches-20160118/googles-specs +713 -0
- data/_patches-20160118/local-configs-ignore +61 -0
- data/_patches-20160118/misc +79 -0
- data/_patches-20160118/network-unreachable +31 -0
- data/_patches-20160118/new-boxfile +288 -0
- data/_patches-20160118/parallelization-maybe +198 -0
- data/_patches-20160118/port-forwarding-processes +87 -0
- data/_patches-20160118/read-state +23 -0
- data/_patches-20160118/refactor-to-use-public_address-cap +25 -0
- data/_patches-20160118/series +59 -0
- data/_patches-20160118/status +13 -0
- data/_patches-20160118/test-move-env-data +231 -0
- data/_patches-20160118/test-vagrantfile-vm1 +167 -0
- data/_patches-20160118/vagrant-spec-mock-api +137 -0
- data/_patches-20160118/vagrant-vmware-plugin +233 -0
- data/_patches-20160118/vagrantfile +403 -0
- data/_patches-20160118/vagrantfile-for-acceptance-tests +29 -0
- data/_patches-20160118/vagrantfile-for-nick +95 -0
- data/_patches-20160118/vagrantfiles-to-forget-what-they-are-for +134 -0
- data/_patches-20160118/vm-vanished +42 -0
- data/_patches-20160118a/COMPLETED-ABOVE-THIS-LINE +4 -0
- data/_patches-20160118a/COMPLETED-BELOW-THIS-LINE +4 -0
- data/_patches-20160118a/CR-ABOVE-THIS-LINE +4 -0
- data/_patches-20160118a/CR-BELOW-THIS-LINE +4 -0
- data/_patches-20160118a/WIP-ABOVE-THIS-LINE +4 -0
- data/_patches-20160118a/WIP-BELOW-THIS-LINE +4 -0
- data/_patches-20160118a/acceptance-test-runner +29 -0
- data/_patches-20160118a/ansible-1 +92 -0
- data/_patches-20160118a/bar +189 -0
- data/_patches-20160118a/cache-api-client-in-up +40 -0
- data/_patches-20160118a/dead-code-in-actions +44 -0
- data/_patches-20160118a/debug-changes +55 -0
- data/_patches-20160118a/demo-rails-app +1276 -0
- data/_patches-20160118a/eng-10166-halt-spec +40 -0
- data/_patches-20160118a/eng-10256 +554 -0
- data/_patches-20160118a/eng-10256-cr +314 -0
- data/_patches-20160118a/eng-10256-ubuntu-testing +88 -0
- data/_patches-20160118a/eng-10269-test-stuff +87 -0
- data/_patches-20160118a/eng-10269-wtf +119 -0
- data/_patches-20160118a/eng-10369 +143 -0
- data/_patches-20160118a/eng-10369-tmp +60 -0
- data/_patches-20160118a/eng-10919 +56 -0
- data/_patches-20160118a/eng-11177-fix-actions-requires +44 -0
- data/_patches-20160118a/eng-11442 +4 -0
- data/_patches-20160118a/eng-11616 +403 -0
- data/_patches-20160118a/eng-11616-2 +67 -0
- data/_patches-20160118a/eng-11616-actual +184 -0
- data/_patches-20160118a/eng-11625a +4 -0
- data/_patches-20160118a/eng-11711 +85 -0
- data/_patches-20160118a/eng-12232-command-spec +236 -0
- data/_patches-20160118a/eng-12235 +83 -0
- data/_patches-20160118a/eng-12235-override-refactor +140 -0
- data/_patches-20160118a/eng-12240 +103 -0
- data/_patches-20160118a/eng-12249 +40 -0
- data/_patches-20160118a/eng-12301 +50 -0
- data/_patches-20160118a/eng-12720 +74 -0
- data/_patches-20160118a/eng-12843 +95 -0
- data/_patches-20160118a/eng-13040 +291 -0
- data/_patches-20160118a/env-source +112 -0
- data/_patches-20160118a/foo +169 -0
- data/_patches-20160118a/frickin-vagrant-spec +163 -0
- data/_patches-20160118a/gem-pre-version +14 -0
- data/_patches-20160118a/gems-old +9 -0
- data/_patches-20160118a/googles-specs +713 -0
- data/_patches-20160118a/guestport-madness +59 -0
- data/_patches-20160118a/local-configs-ignore +61 -0
- data/_patches-20160118a/misc +79 -0
- data/_patches-20160118a/network-unreachable +31 -0
- data/_patches-20160118a/new-boxfile +288 -0
- data/_patches-20160118a/parallelization-maybe +198 -0
- data/_patches-20160118a/port-forwarding-processes +87 -0
- data/_patches-20160118a/read-state +23 -0
- data/_patches-20160118a/refactor-to-use-public_address-cap +25 -0
- data/_patches-20160118a/series +62 -0
- data/_patches-20160118a/status +14 -0
- data/_patches-20160118a/test-move-env-data +231 -0
- data/_patches-20160118a/test-vagrantfile-vm1 +167 -0
- data/_patches-20160118a/vagrant-spec-mock-api +137 -0
- data/_patches-20160118a/vagrant-vmware-plugin +233 -0
- data/_patches-20160118a/vagrantfile +403 -0
- data/_patches-20160118a/vagrantfile-for-acceptance-tests +29 -0
- data/_patches-20160118a/vagrantfile-for-nick +95 -0
- data/_patches-20160118a/vagrantfiles-to-forget-what-they-are-for +134 -0
- data/_patches-20160118a/vm-vanished +42 -0
- data/lib/vagrant-skytap/action/clear_forwarded_ports.rb +19 -0
- data/lib/vagrant-skytap/action/forward_ports.rb +42 -0
- data/lib/vagrant-skytap/action/prepare_forwarded_port_collision_params.rb +37 -0
- data/lib/vagrant-skytap/action.rb +18 -0
- data/lib/vagrant-skytap/api/environment.rb +19 -4
- data/lib/vagrant-skytap/api/vm.rb +10 -6
- data/lib/vagrant-skytap/command/up.rb +7 -1
- data/lib/vagrant-skytap/errors.rb +4 -0
- data/lib/vagrant-skytap/hosts/bsd/cap/ssh_tunnel.rb +15 -0
- data/lib/vagrant-skytap/hosts/common/cap/ssh_tunnel.rb +183 -0
- data/lib/vagrant-skytap/hosts/linux/cap/ssh_tunnel.rb +15 -0
- data/lib/vagrant-skytap/hosts/windows/cap/ssh_tunnel.rb +27 -0
- data/lib/vagrant-skytap/model/forwarded_port.rb +78 -0
- data/lib/vagrant-skytap/plugin.rb +15 -0
- data/lib/vagrant-skytap/util/compile_forwarded_ports.rb +35 -0
- data/lib/vagrant-skytap/version.rb +1 -1
- data/locales/en.yml +3 -0
- data/spec/unit/environment_spec.rb +14 -2
- data/spec/unit/forwarded_port_spec.rb +45 -0
- data/spec/unit/hosts/common/cap/ssh_tunnel_spec.rb +180 -0
- data/spec/unit/prepare_collision_params_spec.rb +57 -0
- data/spec/unit/support/forwarded_ports/machines/vm1/skytap/id +1 -0
- data/spec/unit/support/forwarded_ports/machines/vm1/skytap/private_key +4 -0
- data/spec/unit/support/forwarded_ports/machines/vm1/skytap/tcp9000_tcp_9000_80.pid +1 -0
- data/spec/unit/support/forwarded_ports/machines/vm1/skytap/tcp9001_tcp_9001_81.pid +1 -0
- data/spec/unit/support/forwarded_ports/machines/vm1/virtualbox/id +1 -0
- data/spec/unit/support/forwarded_ports/machines/vm2/skytap/id +1 -0
- data/spec/unit/support/forwarded_ports/machines/vm2/skytap/tcp8080_tcp_8080_80.pid +1 -0
- data/spec/unit/support/forwarded_ports/machines/vm3/virtualbox/id +1 -0
- data/spec/unit/support/forwarded_ports/machines/vm4/skytap/id +1 -0
- data/spec/unit/support/forwarded_ports/machines/vm4/skytap/tcp8888_tcp_8888_80.pid +1 -0
- metadata +330 -2
@@ -0,0 +1,40 @@
|
|
1
|
+
# HG changeset patch
|
2
|
+
# Parent 55c178c0f5096eedd87b19b31f647a9f3b37bec9
|
3
|
+
diff -r 55c178c0f509 -r 1d887cdba67b spec/acceptance/provider/halt_spec.rb
|
4
|
+
--- a/spec/acceptance/provider/halt_spec.rb Mon Oct 12 11:22:04 2015 -0700
|
5
|
+
+++ b/spec/acceptance/provider/halt_spec.rb Mon Oct 12 11:22:13 2015 -0700
|
6
|
+
@@ -1,3 +1,34 @@
|
7
|
+
+# This tests that an instance can be halted correctly
|
8
|
+
shared_examples 'provider/halt' do |provider, options|
|
9
|
+
+ if !options[:box]
|
10
|
+
+ raise ArgumentError,
|
11
|
+
+ "box option must be specified for provider: #{provider}"
|
12
|
+
+ end
|
13
|
+
|
14
|
+
+ include_context 'acceptance'
|
15
|
+
+
|
16
|
+
+ before do
|
17
|
+
+ environment.skeleton('generic')
|
18
|
+
+ assert_execute('vagrant', 'box', 'add', 'basic', options[:box])
|
19
|
+
+ assert_execute('vagrant', 'up', "--provider=#{provider}")
|
20
|
+
+ end
|
21
|
+
+
|
22
|
+
+ after do
|
23
|
+
+ assert_execute('vagrant', 'destroy', '--force')
|
24
|
+
+ end
|
25
|
+
+
|
26
|
+
+ it 'should halt the machine and bring it back up' do
|
27
|
+
+ status("Test: machine can be halted")
|
28
|
+
+ halt_result = execute("vagrant", "halt")
|
29
|
+
+ expect(halt_result).to exit_with(0)
|
30
|
+
+
|
31
|
+
+ status("Test: machine can be brought up after halt")
|
32
|
+
+ up_result = execute("vagrant", "up")
|
33
|
+
+ expect(up_result).to exit_with(0)
|
34
|
+
+
|
35
|
+
+ status("Test: machine is running after up")
|
36
|
+
+ echo_result = execute("vagrant", "ssh", "-c", "echo foo")
|
37
|
+
+ expect(echo_result).to exit_with(0)
|
38
|
+
+ expect(echo_result.stdout).to match(/foo\n$/)
|
39
|
+
+ end
|
40
|
+
end
|
@@ -0,0 +1,554 @@
|
|
1
|
+
# HG changeset patch
|
2
|
+
# Parent b669f28f24c6872c9a436d1673eea9be62f1f6b4
|
3
|
+
# Parent b669f28f24c6872c9a436d1673eea9be62f1f6b4
|
4
|
+
ENG-10256 port forwarding
|
5
|
+
|
6
|
+
diff -r b669f28f24c6 lib/vagrant-skytap/action.rb
|
7
|
+
--- a/lib/vagrant-skytap/action.rb Wed Jan 13 17:07:26 2016 -0800
|
8
|
+
+++ b/lib/vagrant-skytap/action.rb Mon Jan 18 13:57:03 2016 -0800
|
9
|
+
@@ -15,6 +15,7 @@
|
10
|
+
when :missing_environment, :missing_vm, :no_vms
|
11
|
+
b1.use MessageNotCreated
|
12
|
+
else
|
13
|
+
+ b1.use ClearForwardedPorts
|
14
|
+
b1.use StopVm
|
15
|
+
end
|
16
|
+
end
|
17
|
+
@@ -30,6 +31,7 @@
|
18
|
+
when :missing_environment, :missing_vm, :no_vms
|
19
|
+
b1.use MessageNotCreated
|
20
|
+
else
|
21
|
+
+ b1.use ClearForwardedPorts
|
22
|
+
b1.use SuspendVm
|
23
|
+
end
|
24
|
+
end
|
25
|
+
@@ -65,6 +67,7 @@
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
+ b.use ClearForwardedPorts
|
30
|
+
b.use PrepareNFSValidIds
|
31
|
+
b.use SyncedFolderCleanup
|
32
|
+
end
|
33
|
+
@@ -251,6 +254,7 @@
|
34
|
+
end
|
35
|
+
end
|
36
|
+
b.use WaitForCommunicator
|
37
|
+
+ b.use action_forward_ports
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
@@ -281,15 +285,25 @@
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
+ def self.action_forward_ports
|
46
|
+
+ Vagrant::Action::Builder.new.tap do |b|
|
47
|
+
+ b.use ClearForwardedPorts
|
48
|
+
+ b.use ReadSSHInfo
|
49
|
+
+ b.use ForwardPorts
|
50
|
+
+ end
|
51
|
+
+ end
|
52
|
+
+
|
53
|
+
# The autoload farm
|
54
|
+
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
55
|
+
autoload :StoreExtraData, action_root.join("store_extra_data")
|
56
|
+
autoload :AddVmToEnvironment, action_root.join("add_vm_to_environment")
|
57
|
+
+ autoload :ClearForwardedPorts, action_root.join("clear_forwarded_ports")
|
58
|
+
autoload :CreateEnvironment, action_root.join("create_environment")
|
59
|
+
autoload :DeleteEnvironment, action_root.join("delete_environment")
|
60
|
+
autoload :DeleteVm, action_root.join("delete_vm")
|
61
|
+
autoload :ExistenceCheck, action_root.join("existence_check")
|
62
|
+
autoload :FetchEnvironment, action_root.join("fetch_environment")
|
63
|
+
+ autoload :ForwardPorts, action_root.join("forward_ports")
|
64
|
+
autoload :InitializeAPIClient, action_root.join("initialize_api_client")
|
65
|
+
autoload :InitialState, action_root.join("initial_state")
|
66
|
+
autoload :IsParallelized, action_root.join("is_parallelized")
|
67
|
+
diff -r b669f28f24c6 lib/vagrant-skytap/action/clear_forwarded_ports.rb
|
68
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
69
|
+
+++ b/lib/vagrant-skytap/action/clear_forwarded_ports.rb Mon Jan 18 13:57:03 2016 -0800
|
70
|
+
@@ -0,0 +1,18 @@
|
71
|
+
+module VagrantPlugins
|
72
|
+
+ module Skytap
|
73
|
+
+ module Action
|
74
|
+
+ class ClearForwardedPorts
|
75
|
+
+ def initialize(app, env)
|
76
|
+
+ @app = app
|
77
|
+
+ end
|
78
|
+
+
|
79
|
+
+ def call(env)
|
80
|
+
+ env[:ui].info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
|
81
|
+
+ env[:host].capability(:clear_forwarded_ports, env)
|
82
|
+
+
|
83
|
+
+ @app.call(env)
|
84
|
+
+ end
|
85
|
+
+ end
|
86
|
+
+ end
|
87
|
+
+ end
|
88
|
+
+end
|
89
|
+
diff -r b669f28f24c6 lib/vagrant-skytap/action/forward_ports.rb
|
90
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
91
|
+
+++ b/lib/vagrant-skytap/action/forward_ports.rb Mon Jan 18 13:57:03 2016 -0800
|
92
|
+
@@ -0,0 +1,50 @@
|
93
|
+
+require 'vagrant-skytap/util/compile_forwarded_ports'
|
94
|
+
+
|
95
|
+
+module VagrantPlugins
|
96
|
+
+ module Skytap
|
97
|
+
+ module Action
|
98
|
+
+ class ForwardPorts
|
99
|
+
+ include Util::CompileForwardedPorts
|
100
|
+
+
|
101
|
+
+ def initialize(app, env)
|
102
|
+
+ @app = app
|
103
|
+
+ end
|
104
|
+
+
|
105
|
+
+ #--------------------------------------------------------------
|
106
|
+
+ # Execution
|
107
|
+
+ #--------------------------------------------------------------
|
108
|
+
+ def call(env)
|
109
|
+
+ @env = env
|
110
|
+
+
|
111
|
+
+ # Get the ports we're forwarding
|
112
|
+
+ env[:forwarded_ports] ||= compile_forwarded_ports(env[:machine].config)
|
113
|
+
+
|
114
|
+
+ # Warn if we're port forwarding to any privileged ports...
|
115
|
+
+ env[:forwarded_ports].each do |fp|
|
116
|
+
+ if fp.host_port <= 1024
|
117
|
+
+ env[:ui].warn I18n.t("vagrant.actions.vm.forward_ports.privileged_ports")
|
118
|
+
+ break
|
119
|
+
+ end
|
120
|
+
+ end
|
121
|
+
+
|
122
|
+
+ env[:ui].output(I18n.t("vagrant.actions.vm.forward_ports.forwarding"))
|
123
|
+
+ forward_ports
|
124
|
+
+
|
125
|
+
+ @app.call(env)
|
126
|
+
+ end
|
127
|
+
+
|
128
|
+
+ def forward_ports
|
129
|
+
+ @env[:forwarded_ports].each do |fp|
|
130
|
+
+ unless fp.guest_port == 22 && fp.host_port == 2222
|
131
|
+
+ @env[:ui].detail(I18n.t("vagrant.actions.vm.forward_ports.forwarding_entry",
|
132
|
+
+ adapter: fp.adapter,
|
133
|
+
+ guest_port: fp.guest_port,
|
134
|
+
+ host_port: fp.host_port))
|
135
|
+
+ @env[:host].capability(:start_ssh_tunnel, fp, @env)
|
136
|
+
+ end
|
137
|
+
+ end
|
138
|
+
+ end
|
139
|
+
+ end
|
140
|
+
+ end
|
141
|
+
+ end
|
142
|
+
+end
|
143
|
+
diff -r b669f28f24c6 lib/vagrant-skytap/hosts/bsd/cap/ssh_tunnel.rb
|
144
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
145
|
+
+++ b/lib/vagrant-skytap/hosts/bsd/cap/ssh_tunnel.rb Mon Jan 18 13:57:03 2016 -0800
|
146
|
+
@@ -0,0 +1,15 @@
|
147
|
+
+require "vagrant-skytap/hosts/common/cap/ssh_tunnel"
|
148
|
+
+
|
149
|
+
+module VagrantPlugins
|
150
|
+
+ module Skytap
|
151
|
+
+ module HostBSD
|
152
|
+
+ module Cap
|
153
|
+
+ class SSHTunnel < VagrantPlugins::Skytap::HostCommon::Cap::SSHTunnel
|
154
|
+
+ def self.create_logger
|
155
|
+
+ Log4r::Logger.new("vagrant::hosts::bsd")
|
156
|
+
+ end
|
157
|
+
+ end
|
158
|
+
+ end
|
159
|
+
+ end
|
160
|
+
+ end
|
161
|
+
+end
|
162
|
+
diff -r b669f28f24c6 lib/vagrant-skytap/hosts/common/cap/ssh_tunnel.rb
|
163
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
164
|
+
+++ b/lib/vagrant-skytap/hosts/common/cap/ssh_tunnel.rb Mon Jan 18 13:57:03 2016 -0800
|
165
|
+
@@ -0,0 +1,118 @@
|
166
|
+
+require "pathname"
|
167
|
+
+require "tmpdir"
|
168
|
+
+require 'childprocess'
|
169
|
+
+require "vagrant/util/subprocess"
|
170
|
+
+require 'log4r'
|
171
|
+
+require "vagrant/util/safe_chdir"
|
172
|
+
+
|
173
|
+
+module VagrantPlugins
|
174
|
+
+ module Skytap
|
175
|
+
+ module HostCommon
|
176
|
+
+ module Cap
|
177
|
+
+ class SSHTunnel
|
178
|
+
+ class << self
|
179
|
+
+ def create_logger
|
180
|
+
+ raise NotImplementedError
|
181
|
+
+ end
|
182
|
+
+
|
183
|
+
+ def start_ssh_tunnel(env, fp, env_hash)
|
184
|
+
+ logger = create_logger
|
185
|
+
+ machine = env_hash[:machine]
|
186
|
+
+ pidfile = pidfile_name(fp)
|
187
|
+
+ pid = read_pid(machine.data_dir.join(pidfile))
|
188
|
+
+
|
189
|
+
+ if pid && autossh_pid?(pid)
|
190
|
+
+ logger.info("An autossh process already exists with pid #{pid}.")
|
191
|
+
+ else
|
192
|
+
+ args = ssh_args(fp, env_hash)
|
193
|
+
+ vars = autossh_environment_variables(pidfile, env_hash)
|
194
|
+
+ args << {env: vars}
|
195
|
+
+ Vagrant::Util::Subprocess.execute("autossh", "-f", *args)
|
196
|
+
+ end
|
197
|
+
+ end
|
198
|
+
+
|
199
|
+
+ def clear_forwarded_ports(env, env_hash)
|
200
|
+
+ get_pidfiles_for_machine(env_hash[:machine]).each do |pidfile|
|
201
|
+
+ kill_ssh_tunnel(env, pidfile, env_hash)
|
202
|
+
+ end
|
203
|
+
+ end
|
204
|
+
+
|
205
|
+
+ def kill_ssh_tunnel(env, pidfile, env_hash)
|
206
|
+
+ logger = create_logger
|
207
|
+
+ machine = env_hash[:machine]
|
208
|
+
+ pid = read_pid(machine.data_dir.join(pidfile))
|
209
|
+
+ if pid && autossh_pid?(pid)
|
210
|
+
+ Vagrant::Util::Subprocess.execute("kill", pid.to_s)
|
211
|
+
+ else
|
212
|
+
+ logger.info("Cleaning up stale autossh pidfile #{pidfile}.")
|
213
|
+
+ Vagrant::Util::Subprocess.execute("rm", pidfile)
|
214
|
+
+ end
|
215
|
+
+ end
|
216
|
+
+
|
217
|
+
+
|
218
|
+
+ def pidfile_name(fp)
|
219
|
+
+ "#{fp.protocol}#{fp.host_port}.pid"
|
220
|
+
+ end
|
221
|
+
+
|
222
|
+
+ def read_pid(pidfile_path)
|
223
|
+
+ File.read(pidfile_path).presence.try(:to_i) if File.exist?(pidfile_path)
|
224
|
+
+ end
|
225
|
+
+
|
226
|
+
+ def get_pidfiles_for_machine(machine)
|
227
|
+
+ pidfiles = []
|
228
|
+
+ Vagrant::Util::SafeChdir.safe_chdir(machine.data_dir) do
|
229
|
+
+ pidfiles = Dir.glob("*.pid")
|
230
|
+
+ end
|
231
|
+
+ pidfiles
|
232
|
+
+ end
|
233
|
+
+
|
234
|
+
+ # Checks that the pid is actually an autossh process (and not
|
235
|
+
+ # something else using a recycled pid).
|
236
|
+
+ def autossh_pid?(pid)
|
237
|
+
+ # get_comm_for_pid(pid) == 'autossh'
|
238
|
+
+ true
|
239
|
+
+ end
|
240
|
+
+
|
241
|
+
+ # Get the command, minus any arguments, for the given
|
242
|
+
+ # pid. This probably needs to be overridden per host cap
|
243
|
+
+ def get_comm_for_pid(pid)
|
244
|
+
+ result = Vagrant::Util::Subprocess.execute("ps", "-p", pid.to_s, "-o", "comm")
|
245
|
+
+ result.stdout.split("\n").last
|
246
|
+
+ end
|
247
|
+
+
|
248
|
+
+ # these args seem to work on MacOS and Ubuntu ...
|
249
|
+
+ # untested on other implementations
|
250
|
+
+ def ssh_args(fp, env_hash)
|
251
|
+
+ machine = env_hash[:machine]
|
252
|
+
+ ssh_info = env_hash[:machine_ssh_info]
|
253
|
+
+ ssh_options = {
|
254
|
+
+ "ServerAliveInterval" => 10,
|
255
|
+
+ "ServerAliveCountMax" => 3,
|
256
|
+
+ "StrictHostKeyChecking" => "no",
|
257
|
+
+ }
|
258
|
+
+
|
259
|
+
+ args = []
|
260
|
+
+ args << "-q" # quiet
|
261
|
+
+ args << "-N" # no remote command
|
262
|
+
+ args << "-i" << machine.data_dir.join("private_key").to_s
|
263
|
+
+ args << "-L" << "#{fp.host_port}:localhost:#{fp.guest_port}"
|
264
|
+
+ ssh_options.each do |k, v|
|
265
|
+
+ # options in ssh config file format
|
266
|
+
+ args << "-o" << "#{k}=#{v}"
|
267
|
+
+ end
|
268
|
+
+ args << "#{ssh_info[:username]}@#{ssh_info[:host]}"
|
269
|
+
+ end
|
270
|
+
+
|
271
|
+
+ def autossh_environment_variables(pidfile, env_hash, monitoring_port = 0)
|
272
|
+
+ machine = env_hash[:machine]
|
273
|
+
+ {
|
274
|
+
+ "AUTOSSH_PIDFILE" => machine.data_dir.join(pidfile).to_s,
|
275
|
+
+ "AUTOSSH_PORT" => monitoring_port,
|
276
|
+
+ }
|
277
|
+
+ end
|
278
|
+
+ end
|
279
|
+
+ end
|
280
|
+
+ end
|
281
|
+
+ end
|
282
|
+
+ end
|
283
|
+
+end
|
284
|
+
diff -r b669f28f24c6 lib/vagrant-skytap/hosts/linux/cap/ssh_tunnel.rb
|
285
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
286
|
+
+++ b/lib/vagrant-skytap/hosts/linux/cap/ssh_tunnel.rb Mon Jan 18 13:57:03 2016 -0800
|
287
|
+
@@ -0,0 +1,15 @@
|
288
|
+
+require "vagrant-skytap/hosts/common/cap/ssh_tunnel"
|
289
|
+
+
|
290
|
+
+module VagrantPlugins
|
291
|
+
+ module Skytap
|
292
|
+
+ module HostLinux
|
293
|
+
+ module Cap
|
294
|
+
+ class SSHTunnel < VagrantPlugins::Skytap::HostCommon::Cap::SSHTunnel
|
295
|
+
+ def self.create_logger
|
296
|
+
+ Log4r::Logger.new("vagrant::hosts::linux")
|
297
|
+
+ end
|
298
|
+
+ end
|
299
|
+
+ end
|
300
|
+
+ end
|
301
|
+
+ end
|
302
|
+
+end
|
303
|
+
diff -r b669f28f24c6 lib/vagrant-skytap/hosts/windows/cap/ssh_tunnel.rb
|
304
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
305
|
+
+++ b/lib/vagrant-skytap/hosts/windows/cap/ssh_tunnel.rb Mon Jan 18 13:57:03 2016 -0800
|
306
|
+
@@ -0,0 +1,23 @@
|
307
|
+
+require "vagrant-skytap/hosts/common/cap/ssh_tunnel"
|
308
|
+
+
|
309
|
+
+module VagrantPlugins
|
310
|
+
+ module Skytap
|
311
|
+
+ module HostWindows
|
312
|
+
+ module Cap
|
313
|
+
+ class SSHTunnel < VagrantPlugins::Skytap::HostCommon::Cap::SSHTunnel
|
314
|
+
+ def self.create_logger
|
315
|
+
+ Log4r::Logger.new("vagrant::hosts::windows")
|
316
|
+
+ end
|
317
|
+
+
|
318
|
+
+ def self.start_ssh_tunnel(env, fp, env_hash)
|
319
|
+
+ env[:ui].info I18n.t("Port forwarding is currently not supported on Windows. Skipping...")
|
320
|
+
+ end
|
321
|
+
+
|
322
|
+
+ def self.kill_ssh_tunnel(env, pidfile, env_hash)
|
323
|
+
+ env[:ui].info I18n.t("Port forwarding is currently not supported on Windows. Skipping...")
|
324
|
+
+ end
|
325
|
+
+ end
|
326
|
+
+ end
|
327
|
+
+ end
|
328
|
+
+ end
|
329
|
+
+end
|
330
|
+
diff -r b669f28f24c6 lib/vagrant-skytap/model/forwarded_port.rb
|
331
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
332
|
+
+++ b/lib/vagrant-skytap/model/forwarded_port.rb Mon Jan 18 13:57:03 2016 -0800
|
333
|
+
@@ -0,0 +1,70 @@
|
334
|
+
+module VagrantPlugins
|
335
|
+
+ module Skytap
|
336
|
+
+ module Model
|
337
|
+
+ # Represents a single forwarded port for VirtualBox. This has various
|
338
|
+
+ # helpers and defaults for a forwarded port.
|
339
|
+
+ class ForwardedPort
|
340
|
+
+ # The NAT adapter on which to attach the forwarded port.
|
341
|
+
+ #
|
342
|
+
+ # @return [Integer]
|
343
|
+
+ attr_reader :adapter
|
344
|
+
+
|
345
|
+
+ # If true, this port should be auto-corrected.
|
346
|
+
+ #
|
347
|
+
+ # @return [Boolean]
|
348
|
+
+ attr_reader :auto_correct
|
349
|
+
+
|
350
|
+
+ # The unique ID for the forwarded port.
|
351
|
+
+ #
|
352
|
+
+ # @return [String]
|
353
|
+
+ attr_reader :id
|
354
|
+
+
|
355
|
+
+ # The protocol to forward.
|
356
|
+
+ #
|
357
|
+
+ # @return [String]
|
358
|
+
+ attr_reader :protocol
|
359
|
+
+
|
360
|
+
+ # The IP that the forwarded port will connect to on the guest machine.
|
361
|
+
+ #
|
362
|
+
+ # @return [String]
|
363
|
+
+ attr_reader :guest_ip
|
364
|
+
+
|
365
|
+
+ # The port on the guest to be exposed on the host.
|
366
|
+
+ #
|
367
|
+
+ # @return [Integer]
|
368
|
+
+ attr_reader :guest_port
|
369
|
+
+
|
370
|
+
+ # The IP that the forwarded port will bind to on the host machine.
|
371
|
+
+ #
|
372
|
+
+ # @return [String]
|
373
|
+
+ attr_reader :host_ip
|
374
|
+
+
|
375
|
+
+ # The port on the host used to access the port on the guest.
|
376
|
+
+ #
|
377
|
+
+ # @return [Integer]
|
378
|
+
+ attr_reader :host_port
|
379
|
+
+
|
380
|
+
+ def initialize(id, host_port, guest_port, options)
|
381
|
+
+ @id = id
|
382
|
+
+ @guest_port = guest_port
|
383
|
+
+ @host_port = host_port
|
384
|
+
+
|
385
|
+
+ options ||= {}
|
386
|
+
+ @auto_correct = false
|
387
|
+
+ @auto_correct = options[:auto_correct] if options.key?(:auto_correct)
|
388
|
+
+ @adapter = (options[:adapter] || 1).to_i
|
389
|
+
+ @guest_ip = options[:guest_ip] || nil
|
390
|
+
+ @host_ip = options[:host_ip] || nil
|
391
|
+
+ @protocol = options[:protocol] || "tcp"
|
392
|
+
+ end
|
393
|
+
+
|
394
|
+
+ # This corrects the host port and changes it to the given new port.
|
395
|
+
+ #
|
396
|
+
+ # @param [Integer] new_port The new port
|
397
|
+
+ def correct_host_port(new_port)
|
398
|
+
+ @host_port = new_port
|
399
|
+
+ end
|
400
|
+
+ end
|
401
|
+
+ end
|
402
|
+
+ end
|
403
|
+
+end
|
404
|
+
diff -r b669f28f24c6 lib/vagrant-skytap/plugin.rb
|
405
|
+
--- a/lib/vagrant-skytap/plugin.rb Wed Jan 13 17:07:26 2016 -0800
|
406
|
+
+++ b/lib/vagrant-skytap/plugin.rb Mon Jan 18 13:57:03 2016 -0800
|
407
|
+
@@ -49,6 +49,21 @@
|
408
|
+
Cap::PublicAddress
|
409
|
+
end
|
410
|
+
|
411
|
+
+ %w[start_ssh_tunnel kill_ssh_tunnel clear_forwarded_ports].each do |cap|
|
412
|
+
+ host_capability("bsd", cap) do
|
413
|
+
+ require_relative "hosts/bsd/cap/ssh_tunnel"
|
414
|
+
+ HostBSD::Cap::SSHTunnel
|
415
|
+
+ end
|
416
|
+
+ host_capability("linux", cap) do
|
417
|
+
+ require_relative "hosts/linux/cap/ssh_tunnel"
|
418
|
+
+ HostLinux::Cap::SSHTunnel
|
419
|
+
+ end
|
420
|
+
+ host_capability("windows", cap) do
|
421
|
+
+ require_relative "hosts/windows/cap/ssh_tunnel"
|
422
|
+
+ HostWindows::Cap::SSHTunnel
|
423
|
+
+ end
|
424
|
+
+ end
|
425
|
+
+
|
426
|
+
# This initializes the internationalization strings.
|
427
|
+
def self.setup_i18n
|
428
|
+
I18n.load_path << File.expand_path("locales/en.yml", Skytap.source_root)
|
429
|
+
diff -r b669f28f24c6 lib/vagrant-skytap/util/compile_forwarded_ports.rb
|
430
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
431
|
+
+++ b/lib/vagrant-skytap/util/compile_forwarded_ports.rb Mon Jan 18 13:57:03 2016 -0800
|
432
|
+
@@ -0,0 +1,34 @@
|
433
|
+
+require "vagrant/util/scoped_hash_override"
|
434
|
+
+require 'vagrant-skytap/model/forwarded_port'
|
435
|
+
+module VagrantPlugins
|
436
|
+
+ module Skytap
|
437
|
+
+ module Util
|
438
|
+
+ module CompileForwardedPorts
|
439
|
+
+ include Vagrant::Util::ScopedHashOverride
|
440
|
+
+
|
441
|
+
+ # This method compiles the forwarded ports into {ForwardedPort}
|
442
|
+
+ # models.
|
443
|
+
+ def compile_forwarded_ports(config)
|
444
|
+
+ mappings = {}
|
445
|
+
+
|
446
|
+
+ config.vm.networks.each do |type, options|
|
447
|
+
+ if type == :forwarded_port
|
448
|
+
+ guest_port = options[:guest]
|
449
|
+
+ host_port = options[:host]
|
450
|
+
+ protocol = options[:protocol] || "tcp"
|
451
|
+
+ options = scoped_hash_override(options, :skytap)
|
452
|
+
+ id = options[:id]
|
453
|
+
+
|
454
|
+
+ # If the forwarded port was marked as disabled, ignore.
|
455
|
+
+ next if options[:disabled]
|
456
|
+
+ mappings[host_port.to_s + protocol.to_s] =
|
457
|
+
+ Model::ForwardedPort.new(id, host_port, guest_port, options)
|
458
|
+
+ end
|
459
|
+
+ end
|
460
|
+
+
|
461
|
+
+ mappings.values
|
462
|
+
+ end
|
463
|
+
+ end
|
464
|
+
+ end
|
465
|
+
+ end
|
466
|
+
+end
|
467
|
+
diff -r b669f28f24c6 spec/unit/hosts/common/cap/ssh_tunnel_spec.rb
|
468
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
469
|
+
+++ b/spec/unit/hosts/common/cap/ssh_tunnel_spec.rb Mon Jan 18 13:57:03 2016 -0800
|
470
|
+
@@ -0,0 +1,61 @@
|
471
|
+
+require File.expand_path("../../../../base", __FILE__)
|
472
|
+
+require "vagrant-skytap/model/forwarded_port"
|
473
|
+
+
|
474
|
+
+describe "VagrantPlugins::Skytap::HostCommon::Cap::SSHTunnel" do
|
475
|
+
+ let(:described_class) do
|
476
|
+
+ VagrantPlugins::Skytap::Plugin.components.host_capabilities[:bsd].get(:start_ssh_tunnel)
|
477
|
+
+ end
|
478
|
+
+
|
479
|
+
+ let(:machine) { double("machine") }
|
480
|
+
+ let(:forwarded_port) { VagrantPlugins::Skytap::Model::ForwardedPort.new('tcp9000', 9000, 80, {}) }
|
481
|
+
+ let(:ssh_info) { {username: 'user', host: '10.0.0.1'} }
|
482
|
+
+ let(:env_path) { Pathname.new(File.expand_path("../../../../support/forwarded_ports", __FILE__)) }
|
483
|
+
+
|
484
|
+
+ before do
|
485
|
+
+ allow(machine).to receive(:data_dir).and_return(env_path.join("machines/vm1/skytap"))
|
486
|
+
+ end
|
487
|
+
+
|
488
|
+
+ describe "clear_forwarded_ports" do
|
489
|
+
+ it "calls kill_ssh_tunnel for each pidfile found" do
|
490
|
+
+ expect(described_class).to receive(:kill_ssh_tunnel).with(nil, "tcp9000.pid", {machine: machine})
|
491
|
+
+ expect(described_class).to receive(:kill_ssh_tunnel).with(nil, "tcp9001.pid", {machine: machine})
|
492
|
+
+ described_class.clear_forwarded_ports(nil, {machine: machine})
|
493
|
+
+ end
|
494
|
+
+ end
|
495
|
+
+
|
496
|
+
+ describe "read_pid" do
|
497
|
+
+ it "reads the pid" do
|
498
|
+
+ pid = described_class.read_pid(env_path.join("machines/vm1/skytap/tcp9000.pid"))
|
499
|
+
+ expect(pid).to eq(99999)
|
500
|
+
+ end
|
501
|
+
+
|
502
|
+
+ it "returns nil if pidfile missing" do
|
503
|
+
+ pid = described_class.read_pid(env_path.join("machines/vm1/skytap/tcp12345.pid"))
|
504
|
+
+ expect(pid).to be(nil)
|
505
|
+
+ end
|
506
|
+
+ end
|
507
|
+
+
|
508
|
+
+ describe "ssh_args" do
|
509
|
+
+ it "returns expected args" do
|
510
|
+
+ args = described_class.ssh_args(forwarded_port, {machine: machine, machine_ssh_info: ssh_info})
|
511
|
+
+ expect(args).to eq(["-q", "-N",
|
512
|
+
+ "-i", env_path.join("machines/vm1/skytap/private_key").to_s,
|
513
|
+
+ "-L", "9000:localhost:80",
|
514
|
+
+ "-o", "ServerAliveInterval=10",
|
515
|
+
+ "-o", "ServerAliveCountMax=3",
|
516
|
+
+ "-o", "StrictHostKeyChecking=no",
|
517
|
+
+ "user@10.0.0.1"
|
518
|
+
+ ])
|
519
|
+
+ end
|
520
|
+
+ end
|
521
|
+
+
|
522
|
+
+ describe "autossh_environment_variables" do
|
523
|
+
+ it "defaults monitoring port to 0" do
|
524
|
+
+ vars = described_class.autossh_environment_variables('tcp9000.pid', {machine: machine})
|
525
|
+
+ expect(vars).to eq({
|
526
|
+
+ "AUTOSSH_PIDFILE" => env_path.join("machines/vm1/skytap/tcp9000.pid").to_s,
|
527
|
+
+ "AUTOSSH_PORT" => 0,
|
528
|
+
+ })
|
529
|
+
+ end
|
530
|
+
+ end
|
531
|
+
+end
|
532
|
+
diff -r b669f28f24c6 spec/unit/support/forwarded_ports/machines/vm1/skytap/id
|
533
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
534
|
+
+++ b/spec/unit/support/forwarded_ports/machines/vm1/skytap/id Mon Jan 18 13:57:03 2016 -0800
|
535
|
+
@@ -0,0 +1,1 @@
|
536
|
+
+1
|
537
|
+
diff -r b669f28f24c6 spec/unit/support/forwarded_ports/machines/vm1/skytap/private_key
|
538
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
539
|
+
+++ b/spec/unit/support/forwarded_ports/machines/vm1/skytap/private_key Mon Jan 18 13:57:03 2016 -0800
|
540
|
+
@@ -0,0 +1,4 @@
|
541
|
+
+-----BEGIN RSA PRIVATE KEY-----
|
542
|
+
+BOO!
|
543
|
+
+-----END RSA PRIVATE KEY-----
|
544
|
+
+
|
545
|
+
diff -r b669f28f24c6 spec/unit/support/forwarded_ports/machines/vm1/skytap/tcp9000.pid
|
546
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
547
|
+
+++ b/spec/unit/support/forwarded_ports/machines/vm1/skytap/tcp9000.pid Mon Jan 18 13:57:03 2016 -0800
|
548
|
+
@@ -0,0 +1,1 @@
|
549
|
+
+99999
|
550
|
+
diff -r b669f28f24c6 spec/unit/support/forwarded_ports/machines/vm1/skytap/tcp9001.pid
|
551
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
552
|
+
+++ b/spec/unit/support/forwarded_ports/machines/vm1/skytap/tcp9001.pid Mon Jan 18 13:57:03 2016 -0800
|
553
|
+
@@ -0,0 +1,1 @@
|
554
|
+
+90210
|