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,42 @@
|
|
1
|
+
# HG changeset patch
|
2
|
+
# Parent 1b8860f8b5129c2ab846c4464378c7a582ac0a90
|
3
|
+
raise error on vm reload if it's gone?
|
4
|
+
|
5
|
+
diff -r 1b8860f8b512 lib/vagrant-skytap/api/vm.rb
|
6
|
+
--- a/lib/vagrant-skytap/api/vm.rb Mon Nov 09 20:51:32 2015 -0800
|
7
|
+
+++ b/lib/vagrant-skytap/api/vm.rb Mon Nov 09 20:52:02 2015 -0800
|
8
|
+
@@ -35,6 +35,7 @@
|
9
|
+
end
|
10
|
+
|
11
|
+
def refresh_from_environment
|
12
|
+
+ raise VmVanished, name: machine.name unless vm = environment.get_vm_by_id(id)
|
13
|
+
refresh(vm.attrs)
|
14
|
+
end
|
15
|
+
|
16
|
+
diff -r 1b8860f8b512 lib/vagrant-skytap/errors.rb
|
17
|
+
--- a/lib/vagrant-skytap/errors.rb Mon Nov 09 20:51:32 2015 -0800
|
18
|
+
+++ b/lib/vagrant-skytap/errors.rb Mon Nov 09 20:52:02 2015 -0800
|
19
|
+
@@ -27,6 +27,10 @@
|
20
|
+
error_key(:does_not_exist)
|
21
|
+
end
|
22
|
+
|
23
|
+
+ class VmVanished < VagrantSkytapError
|
24
|
+
+ error_key(:vm_vanished)
|
25
|
+
+ end
|
26
|
+
+
|
27
|
+
class BadVmUrl < VagrantSkytapError
|
28
|
+
error_key(:bad_vm_url)
|
29
|
+
end
|
30
|
+
diff -r 1b8860f8b512 locales/en.yml
|
31
|
+
--- a/locales/en.yml Mon Nov 09 20:51:32 2015 -0800
|
32
|
+
+++ b/locales/en.yml Mon Nov 09 20:52:02 2015 -0800
|
33
|
+
@@ -76,6 +76,9 @@
|
34
|
+
does_not_exist: |-
|
35
|
+
%{object_name} was not found.
|
36
|
+
|
37
|
+
+ vm_vanished: |-
|
38
|
+
+ The VM '%{name}' no longer exists on Skytap.
|
39
|
+
+
|
40
|
+
operation_failed: |-
|
41
|
+
The operation failed: %{err}
|
42
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Skytap
|
3
|
+
module Action
|
4
|
+
# This is based on code from the VirtualBox provider.
|
5
|
+
class ClearForwardedPorts
|
6
|
+
def initialize(app, env)
|
7
|
+
@app = app
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
env[:ui].info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
|
12
|
+
env[:host].capability(:clear_forwarded_ports, env[:machine])
|
13
|
+
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'vagrant-skytap/util/compile_forwarded_ports'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Skytap
|
5
|
+
module Action
|
6
|
+
# This is based on code from the VirtualBox provider.
|
7
|
+
class ForwardPorts
|
8
|
+
include Util::CompileForwardedPorts
|
9
|
+
|
10
|
+
def initialize(app, env)
|
11
|
+
@app = app
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(env)
|
15
|
+
@env = env
|
16
|
+
env[:forwarded_ports] ||= compile_forwarded_ports(env[:machine].config)
|
17
|
+
|
18
|
+
if env[:forwarded_ports].any?(&:privileged_host_port?)
|
19
|
+
env[:ui].warn I18n.t("vagrant.actions.vm.forward_ports.privileged_ports")
|
20
|
+
end
|
21
|
+
|
22
|
+
env[:ui].output(I18n.t("vagrant.actions.vm.forward_ports.forwarding"))
|
23
|
+
forward_ports
|
24
|
+
|
25
|
+
@app.call(env)
|
26
|
+
end
|
27
|
+
|
28
|
+
def forward_ports
|
29
|
+
@env[:forwarded_ports].each do |fp|
|
30
|
+
unless fp.internal_ssh_port?
|
31
|
+
@env[:ui].detail(I18n.t("vagrant.actions.vm.forward_ports.forwarding_entry",
|
32
|
+
adapter: fp.adapter,
|
33
|
+
guest_port: fp.guest_port,
|
34
|
+
host_port: fp.host_port))
|
35
|
+
@env[:host].capability(:start_ssh_tunnel, fp, @env[:machine])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Skytap
|
3
|
+
module Action
|
4
|
+
# This is based on code from the VirtualBox provider.
|
5
|
+
class PrepareForwardedPortCollisionParams
|
6
|
+
def initialize(app, env)
|
7
|
+
@app = app
|
8
|
+
end
|
9
|
+
|
10
|
+
# This logic is based on the VirtualBox provider
|
11
|
+
def call(env)
|
12
|
+
# Get the forwarded ports used by other virtual machines and
|
13
|
+
# consider those in use as well.
|
14
|
+
env[:port_collision_extra_in_use] = env[:host].capability(:read_used_ports, env[:machine])
|
15
|
+
|
16
|
+
# Build the remap for any existing collision detections
|
17
|
+
remap = {}
|
18
|
+
env[:port_collision_remap] = remap
|
19
|
+
env[:host].capability(:read_forwarded_ports, env[:machine]).each do |fp|
|
20
|
+
env[:machine].config.vm.networks.each do |type, options|
|
21
|
+
next if type != :forwarded_port
|
22
|
+
|
23
|
+
# If the ID matches the name of the forwarded port, then
|
24
|
+
# remap.
|
25
|
+
if options[:id] == fp.id
|
26
|
+
remap[options[:host]] = fp.host_port
|
27
|
+
break
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
@app.call(env)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -15,6 +15,7 @@ module VagrantPlugins
|
|
15
15
|
when :missing_environment, :missing_vm, :no_vms
|
16
16
|
b1.use MessageNotCreated
|
17
17
|
else
|
18
|
+
b1.use ClearForwardedPorts
|
18
19
|
b1.use StopVm
|
19
20
|
end
|
20
21
|
end
|
@@ -30,6 +31,7 @@ module VagrantPlugins
|
|
30
31
|
when :missing_environment, :missing_vm, :no_vms
|
31
32
|
b1.use MessageNotCreated
|
32
33
|
else
|
34
|
+
b1.use ClearForwardedPorts
|
33
35
|
b1.use SuspendVm
|
34
36
|
end
|
35
37
|
end
|
@@ -65,6 +67,7 @@ module VagrantPlugins
|
|
65
67
|
end
|
66
68
|
end
|
67
69
|
end
|
70
|
+
b.use ClearForwardedPorts
|
68
71
|
b.use PrepareNFSValidIds
|
69
72
|
b.use SyncedFolderCleanup
|
70
73
|
end
|
@@ -175,6 +178,7 @@ module VagrantPlugins
|
|
175
178
|
b1.use MessageResuming
|
176
179
|
b1.use RunVm
|
177
180
|
b1.use WaitForCommunicator
|
181
|
+
b1.use action_forward_ports
|
178
182
|
end
|
179
183
|
end
|
180
184
|
end
|
@@ -251,6 +255,7 @@ module VagrantPlugins
|
|
251
255
|
end
|
252
256
|
end
|
253
257
|
b.use WaitForCommunicator
|
258
|
+
b.use action_forward_ports
|
254
259
|
end
|
255
260
|
end
|
256
261
|
|
@@ -281,15 +286,27 @@ module VagrantPlugins
|
|
281
286
|
end
|
282
287
|
end
|
283
288
|
|
289
|
+
def self.action_forward_ports
|
290
|
+
Vagrant::Action::Builder.new.tap do |b|
|
291
|
+
b.use ClearForwardedPorts
|
292
|
+
b.use EnvSet, port_collision_repair: true
|
293
|
+
b.use PrepareForwardedPortCollisionParams
|
294
|
+
b.use HandleForwardedPortCollisions
|
295
|
+
b.use ForwardPorts
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
284
299
|
# The autoload farm
|
285
300
|
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
286
301
|
autoload :StoreExtraData, action_root.join("store_extra_data")
|
287
302
|
autoload :AddVmToEnvironment, action_root.join("add_vm_to_environment")
|
303
|
+
autoload :ClearForwardedPorts, action_root.join("clear_forwarded_ports")
|
288
304
|
autoload :CreateEnvironment, action_root.join("create_environment")
|
289
305
|
autoload :DeleteEnvironment, action_root.join("delete_environment")
|
290
306
|
autoload :DeleteVm, action_root.join("delete_vm")
|
291
307
|
autoload :ExistenceCheck, action_root.join("existence_check")
|
292
308
|
autoload :FetchEnvironment, action_root.join("fetch_environment")
|
309
|
+
autoload :ForwardPorts, action_root.join("forward_ports")
|
293
310
|
autoload :InitializeAPIClient, action_root.join("initialize_api_client")
|
294
311
|
autoload :InitialState, action_root.join("initial_state")
|
295
312
|
autoload :IsParallelized, action_root.join("is_parallelized")
|
@@ -302,6 +319,7 @@ module VagrantPlugins
|
|
302
319
|
autoload :MessageEnvironmentUrl, action_root.join("message_environment_url")
|
303
320
|
autoload :MessageResuming, action_root.join("message_resuming")
|
304
321
|
autoload :MessageWillNotDestroy, action_root.join("message_will_not_destroy")
|
322
|
+
autoload :PrepareForwardedPortCollisionParams, action_root.join("prepare_forwarded_port_collision_params")
|
305
323
|
autoload :PrepareNFSSettings, action_root.join("prepare_nfs_settings")
|
306
324
|
autoload :PrepareNFSValidIds, action_root.join("prepare_nfs_valid_ids")
|
307
325
|
autoload :ReadSSHInfo, action_root.join("read_ssh_info")
|
@@ -20,8 +20,16 @@ module VagrantPlugins
|
|
20
20
|
vm = Vm.fetch(env, vm_url)
|
21
21
|
check_vm_before_adding(env, vm)
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
args = {vm_ids: [vm.id]}.tap do |ret|
|
24
|
+
if vm.from_template?
|
25
|
+
ret[:template_id] = vm.template_id
|
26
|
+
else
|
27
|
+
ret[:configuration_id] = vm.configuration_id
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
resp = env[:api_client].post(RESOURCE_ROOT, JSON.dump(args))
|
32
|
+
new(JSON.load(resp.body), env)
|
25
33
|
end
|
26
34
|
|
27
35
|
def fetch(env, url)
|
@@ -34,7 +42,6 @@ module VagrantPlugins
|
|
34
42
|
end
|
35
43
|
|
36
44
|
def check_vm_before_adding(env, vm)
|
37
|
-
raise Errors::NotTemplateVm, url: vm.url unless vm.from_template?
|
38
45
|
raise Errors::SourceVmNotStopped, name: env[:machine].name, url: vm.url unless vm.stopped?
|
39
46
|
end
|
40
47
|
end
|
@@ -107,7 +114,15 @@ module VagrantPlugins
|
|
107
114
|
check_vm_before_adding(env, vm)
|
108
115
|
vm_ids = vms.collect(&:id)
|
109
116
|
|
110
|
-
|
117
|
+
args = {vm_ids: [vm.id]}.tap do |ret|
|
118
|
+
if vm.from_template?
|
119
|
+
ret[:template_id] = vm.template_id
|
120
|
+
else
|
121
|
+
ret[:merge_configuration] = vm.configuration_id
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
update_with_retry(args)
|
111
126
|
new_vm_ids = vms.collect(&:id) - vm_ids
|
112
127
|
get_vm_by_id(new_vm_ids.last)
|
113
128
|
end
|
@@ -12,7 +12,7 @@ module VagrantPlugins
|
|
12
12
|
attr_reader :provider_config
|
13
13
|
attr_reader :environment
|
14
14
|
|
15
|
-
reads :id, :interfaces, :credentials, :name
|
15
|
+
reads :id, :interfaces, :credentials, :name, :configuration_url, :template_url
|
16
16
|
|
17
17
|
class << self
|
18
18
|
def fetch(env, url)
|
@@ -57,19 +57,23 @@ module VagrantPlugins
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def from_template?
|
60
|
-
!!
|
60
|
+
!!template_url
|
61
61
|
end
|
62
62
|
|
63
63
|
def template_id
|
64
|
-
|
64
|
+
template_url =~ /templates\/(\d+)/
|
65
|
+
$1
|
66
|
+
end
|
67
|
+
|
68
|
+
def configuration_id
|
69
|
+
configuration_url =~ /configurations\/(\d+)/
|
65
70
|
$1
|
66
71
|
end
|
67
72
|
|
68
73
|
def region
|
69
74
|
return @region if @region
|
70
|
-
resp = env[:api_client].get(
|
71
|
-
|
72
|
-
@region = template_attrs['region']
|
75
|
+
resp = env[:api_client].get(template_url || configuration_url)
|
76
|
+
@region = JSON.load(resp.body)['region']
|
73
77
|
end
|
74
78
|
|
75
79
|
def delete
|
@@ -54,7 +54,13 @@ module VagrantPlugins
|
|
54
54
|
return if !argv
|
55
55
|
|
56
56
|
# Validate the provisioners
|
57
|
-
validate_provisioner_flags!
|
57
|
+
if method(:validate_provisioner_flags!).arity == 1
|
58
|
+
validate_provisioner_flags!(options)
|
59
|
+
else
|
60
|
+
# Second argument was added in Vagrant 1.8.0
|
61
|
+
# https://github.com/mitchellh/vagrant/pull/5981
|
62
|
+
validate_provisioner_flags!(options, argv)
|
63
|
+
end
|
58
64
|
|
59
65
|
# Go over each VM and bring it up
|
60
66
|
@logger.debug("'Up' each target VM...")
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "vagrant-skytap/hosts/common/cap/ssh_tunnel"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Skytap
|
5
|
+
module HostBSD
|
6
|
+
module Cap
|
7
|
+
class SSHTunnel < VagrantPlugins::Skytap::HostCommon::Cap::SSHTunnel
|
8
|
+
def self.create_logger
|
9
|
+
Log4r::Logger.new("vagrant::hosts::bsd")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,183 @@
|
|
1
|
+
require "vagrant/util/subprocess"
|
2
|
+
require "vagrant/util/safe_chdir"
|
3
|
+
require "vagrant-skytap/model/forwarded_port"
|
4
|
+
require 'log4r'
|
5
|
+
|
6
|
+
# Port forwarding for the Skytap provider is implemented
|
7
|
+
# using the autossh utility, which starts, monitors, and
|
8
|
+
# restarts SSH tunnels, and optionally creates pidfiles.
|
9
|
+
# We specify pidfile names which correspond to the
|
10
|
+
# forwarded port fields.
|
11
|
+
|
12
|
+
# Methods such as #ssh_args, which may need to return a
|
13
|
+
# different value for a particular OS, can be overridden
|
14
|
+
# by subclassing this capability file and registering
|
15
|
+
# the new host capability in the provider plugin.
|
16
|
+
|
17
|
+
module VagrantPlugins
|
18
|
+
module Skytap
|
19
|
+
module HostCommon
|
20
|
+
module Cap
|
21
|
+
class SSHTunnel
|
22
|
+
class << self
|
23
|
+
def create_logger
|
24
|
+
raise NotImplementedError
|
25
|
+
end
|
26
|
+
|
27
|
+
# Start an autossh process for the given [Model::ForwardedPort]
|
28
|
+
# on the given [Vagrant::Machine]. If autossh is not
|
29
|
+
# available on the host, an appropriate error message
|
30
|
+
# will be shown, asking the user to install it.
|
31
|
+
#
|
32
|
+
# @return [Vagrant::Util::Subprocess::Result]
|
33
|
+
def start_ssh_tunnel(env, fp, machine)
|
34
|
+
kill_ssh_tunnel(env, fp, machine)
|
35
|
+
args = ssh_args(fp, machine)
|
36
|
+
args << {env: autossh_environment_variables(fp, machine)}
|
37
|
+
Vagrant::Util::Subprocess.execute("autossh", "-f", *args)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Kill the autossh process for the given [Model::ForwardedPort]
|
41
|
+
# on the given [Vagrant::Machine]. autossh will kill the ssh
|
42
|
+
# child process before terminating.
|
43
|
+
#
|
44
|
+
# @return [Vagrant::Util::Subprocess::Result]
|
45
|
+
def kill_ssh_tunnel(env, fp, machine)
|
46
|
+
if pid = read_pid(pidfile_path(fp, machine))
|
47
|
+
Vagrant::Util::Subprocess.execute("kill", pid.to_s)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Convenience method which kills all autossh processes for
|
52
|
+
# the given [Vagrant::Machine].
|
53
|
+
#
|
54
|
+
# @return [Array] of [Model::ForwardedPort] objects
|
55
|
+
def clear_forwarded_ports(env, machine)
|
56
|
+
get_fp_from_directory(machine.data_dir).each do |fp|
|
57
|
+
kill_ssh_tunnel(env, fp, machine)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# The currently forwarded ports for this [Vagrant::Machine].
|
62
|
+
#
|
63
|
+
# @return [Array] of [Model::ForwardedPort] objects
|
64
|
+
def read_forwarded_ports(env, machine)
|
65
|
+
get_fp_from_directory(machine.data_dir)
|
66
|
+
end
|
67
|
+
|
68
|
+
# The currently forwarded ports for all *other*
|
69
|
+
# [Vagrant::Machine]s in this project.
|
70
|
+
#
|
71
|
+
# @return [Array] of [Model::ForwardedPort] objects
|
72
|
+
def read_used_ports(env, machine)
|
73
|
+
search_paths = machine_data_dirs(env).reject!{|k,v| k == machine.name.to_s}.values
|
74
|
+
search_paths.collect{|path| get_fp_from_directory(path)}.flatten
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
# Reads the process id (pid) from the given pidfile.
|
80
|
+
#
|
81
|
+
# @return [Integer], or nil if not found.
|
82
|
+
def read_pid(pidfile_path)
|
83
|
+
File.read(pidfile_path).presence.try(:to_i) if File.exist?(pidfile_path)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Gets forwarded ports by reading pidfiles in the given
|
87
|
+
# directory.
|
88
|
+
#
|
89
|
+
# @return [Array] of [Model::ForwardedPort] objects
|
90
|
+
def get_fp_from_directory(dir)
|
91
|
+
pidfiles = []
|
92
|
+
Vagrant::Util::SafeChdir.safe_chdir(dir) do
|
93
|
+
pidfiles = Dir.glob("*.pid")
|
94
|
+
end
|
95
|
+
pidfiles.collect{|pidfile| pidfile_to_fp(pidfile)}
|
96
|
+
end
|
97
|
+
|
98
|
+
# Returns a mapping of machine names to their data_dirs
|
99
|
+
# (full paths).
|
100
|
+
#
|
101
|
+
# @return [Hash]
|
102
|
+
def machine_data_dirs(env)
|
103
|
+
h = {}
|
104
|
+
env_path = env.local_data_path
|
105
|
+
Vagrant::Util::SafeChdir.safe_chdir(env.local_data_path) do
|
106
|
+
Dir.foreach("machines") do |machine_name|
|
107
|
+
data_dir = "machines/#{machine_name}/skytap"
|
108
|
+
if Dir.exist?(data_dir)
|
109
|
+
h[machine_name] = env_path.join(data_dir)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
h
|
114
|
+
end
|
115
|
+
|
116
|
+
# Gets the full path to the pidfile for the given
|
117
|
+
# [Model::ForwardedPort] and [Vagrant::Machine].
|
118
|
+
#
|
119
|
+
# @return [Model::ForwardedPort]
|
120
|
+
def pidfile_path(fp, machine)
|
121
|
+
machine.data_dir.join(fp_to_pidfile(fp)).to_s
|
122
|
+
end
|
123
|
+
|
124
|
+
# Generate a pidfile name which encodes enough information
|
125
|
+
# to reconstruct the given [Model::ForwardedPort].
|
126
|
+
#
|
127
|
+
# @return [String]
|
128
|
+
def fp_to_pidfile(fp)
|
129
|
+
"#{fp.id}_#{fp.protocol}_#{fp.host_port}_#{fp.guest_port}.pid"
|
130
|
+
end
|
131
|
+
|
132
|
+
# Create a [Model::ForwardedPort] from a parsed pidfile name.
|
133
|
+
#
|
134
|
+
# @return [Model::ForwardedPort]
|
135
|
+
def pidfile_to_fp(pidfile)
|
136
|
+
pidfile =~ /(\w*)_(\w*)_(\w*)_(\w*)\.pid/
|
137
|
+
id, protocol, host_port, guest_port = $1, $2, $3, $4
|
138
|
+
Model::ForwardedPort.new(id, host_port.to_i, guest_port.to_i, protocol: protocol)
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
# Gets the arguments to be passed to ssh for the given
|
144
|
+
# [Model::ForwardedPort] on the given [Vagrant::Machine].
|
145
|
+
#
|
146
|
+
# @return [Array] of [String]
|
147
|
+
def ssh_args(fp, machine)
|
148
|
+
ssh_info = machine.ssh_info
|
149
|
+
# TODO: tune these settings
|
150
|
+
ssh_options = {
|
151
|
+
"ServerAliveInterval" => 10,
|
152
|
+
"ServerAliveCountMax" => 3,
|
153
|
+
"StrictHostKeyChecking" => "no",
|
154
|
+
}
|
155
|
+
|
156
|
+
args = []
|
157
|
+
args << "-q" # quiet
|
158
|
+
args << "-N" # no remote command
|
159
|
+
args << "-i" << machine.data_dir.join("private_key").to_s
|
160
|
+
args << "-L" << "#{fp.host_port}:localhost:#{fp.guest_port}"
|
161
|
+
ssh_options.each do |k, v|
|
162
|
+
# options in ssh config file format
|
163
|
+
args << "-o" << "#{k}=#{v}"
|
164
|
+
end
|
165
|
+
args << "#{ssh_info[:username]}@#{ssh_info[:host]}"
|
166
|
+
end
|
167
|
+
|
168
|
+
# Gets the environment variables to be set when calling
|
169
|
+
# autossh.
|
170
|
+
#
|
171
|
+
# @return [Hash]
|
172
|
+
def autossh_environment_variables(fp, machine, monitoring_port = 0)
|
173
|
+
{
|
174
|
+
"AUTOSSH_PIDFILE" => pidfile_path(fp, machine),
|
175
|
+
"AUTOSSH_PORT" => monitoring_port,
|
176
|
+
}
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "vagrant-skytap/hosts/common/cap/ssh_tunnel"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Skytap
|
5
|
+
module HostLinux
|
6
|
+
module Cap
|
7
|
+
class SSHTunnel < VagrantPlugins::Skytap::HostCommon::Cap::SSHTunnel
|
8
|
+
def self.create_logger
|
9
|
+
Log4r::Logger.new("vagrant::hosts::linux")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "vagrant-skytap/hosts/common/cap/ssh_tunnel"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Skytap
|
5
|
+
module HostWindows
|
6
|
+
module Cap
|
7
|
+
class SSHTunnel < VagrantPlugins::Skytap::HostCommon::Cap::SSHTunnel
|
8
|
+
def self.create_logger
|
9
|
+
Log4r::Logger.new("vagrant::hosts::windows")
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.start_ssh_tunnel(env, fp, env_hash)
|
13
|
+
raise Errors::FeatureNotSupportedForHostOs, feature_name: "port forwarding"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.kill_ssh_tunnel(env, pidfile, env_hash)
|
17
|
+
raise Errors::FeatureNotSupportedForHostOs, feature_name: "port forwarding"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.kill_ssh_tunnel(env, machine)
|
21
|
+
raise Errors::FeatureNotSupportedForHostOs, feature_name: "port forwarding"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Skytap
|
3
|
+
module Model
|
4
|
+
# This is based on code from the VirtualBox provider.
|
5
|
+
class ForwardedPort
|
6
|
+
# If true, this port should be auto-corrected.
|
7
|
+
#
|
8
|
+
# @return [Boolean]
|
9
|
+
attr_reader :auto_correct
|
10
|
+
|
11
|
+
# The unique ID for the forwarded port.
|
12
|
+
#
|
13
|
+
# @return [String]
|
14
|
+
attr_reader :id
|
15
|
+
|
16
|
+
# The protocol to forward.
|
17
|
+
#
|
18
|
+
# @return [String]
|
19
|
+
attr_reader :protocol
|
20
|
+
|
21
|
+
# The IP that the forwarded port will connect to on the guest machine.
|
22
|
+
#
|
23
|
+
# @return [String]
|
24
|
+
attr_reader :guest_ip
|
25
|
+
|
26
|
+
# The port on the guest to be exposed on the host.
|
27
|
+
#
|
28
|
+
# @return [Integer]
|
29
|
+
attr_reader :guest_port
|
30
|
+
|
31
|
+
# The IP that the forwarded port will bind to on the host machine.
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
attr_reader :host_ip
|
35
|
+
|
36
|
+
# The port on the host used to access the port on the guest.
|
37
|
+
#
|
38
|
+
# @return [Integer]
|
39
|
+
attr_reader :host_port
|
40
|
+
|
41
|
+
def initialize(id, host_port, guest_port, options)
|
42
|
+
@id = id
|
43
|
+
@guest_port = guest_port
|
44
|
+
@host_port = host_port
|
45
|
+
|
46
|
+
options ||= {}
|
47
|
+
@auto_correct = false
|
48
|
+
@auto_correct = options[:auto_correct] if options.key?(:auto_correct)
|
49
|
+
@guest_ip = options[:guest_ip] || nil
|
50
|
+
@host_ip = options[:host_ip] || nil
|
51
|
+
@protocol = options[:protocol] || "tcp"
|
52
|
+
end
|
53
|
+
|
54
|
+
# This corrects the host port and changes it to the given new port.
|
55
|
+
#
|
56
|
+
# @param [Integer] new_port The new port
|
57
|
+
def correct_host_port(new_port)
|
58
|
+
@host_port = new_port
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns true if the host port is privileged.
|
62
|
+
#
|
63
|
+
# @param [Boolean]
|
64
|
+
def privileged_host_port?
|
65
|
+
host_port <= 1024
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns true if this is the SSH port used internally
|
69
|
+
# by Vagrant.
|
70
|
+
#
|
71
|
+
# @param [Boolean]
|
72
|
+
def internal_ssh_port?
|
73
|
+
(guest_port == 22 && host_port == 2222) || id == "ssh"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -49,6 +49,21 @@ module VagrantPlugins
|
|
49
49
|
Cap::PublicAddress
|
50
50
|
end
|
51
51
|
|
52
|
+
%w[start_ssh_tunnel kill_ssh_tunnel clear_forwarded_ports read_forwarded_ports read_used_ports].each do |cap|
|
53
|
+
host_capability("bsd", cap) do
|
54
|
+
require_relative "hosts/bsd/cap/ssh_tunnel"
|
55
|
+
HostBSD::Cap::SSHTunnel
|
56
|
+
end
|
57
|
+
host_capability("linux", cap) do
|
58
|
+
require_relative "hosts/linux/cap/ssh_tunnel"
|
59
|
+
HostLinux::Cap::SSHTunnel
|
60
|
+
end
|
61
|
+
host_capability("windows", cap) do
|
62
|
+
require_relative "hosts/windows/cap/ssh_tunnel"
|
63
|
+
HostWindows::Cap::SSHTunnel
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
52
67
|
# This initializes the internationalization strings.
|
53
68
|
def self.setup_i18n
|
54
69
|
I18n.load_path << File.expand_path("locales/en.yml", Skytap.source_root)
|