vagrantup 0.5.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +56 -0
- data/Gemfile +14 -3
- data/Gemfile.lock +38 -11
- data/README.md +1 -1
- data/bin/vagrant +20 -5
- data/config/default.rb +6 -8
- data/lib/vagrant.rb +40 -13
- data/lib/vagrant/action.rb +56 -16
- data/lib/vagrant/action/box/destroy.rb +3 -1
- data/lib/vagrant/action/box/download.rb +8 -13
- data/lib/vagrant/action/box/unpackage.rb +8 -11
- data/lib/vagrant/action/box/verify.rb +3 -3
- data/lib/vagrant/action/builder.rb +3 -30
- data/lib/vagrant/action/builtin.rb +6 -1
- data/lib/vagrant/action/environment.rb +14 -62
- data/lib/vagrant/action/general/package.rb +29 -22
- data/lib/vagrant/action/vm/boot.rb +5 -12
- data/lib/vagrant/action/vm/check_box.rb +4 -4
- data/lib/vagrant/action/vm/check_guest_additions.rb +4 -6
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +2 -2
- data/lib/vagrant/action/vm/clear_nfs_exports.rb +1 -1
- data/lib/vagrant/action/vm/clear_shared_folders.rb +1 -1
- data/lib/vagrant/action/vm/customize.rb +1 -1
- data/lib/vagrant/action/vm/destroy.rb +1 -2
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +1 -1
- data/lib/vagrant/action/vm/disable_networks.rb +11 -9
- data/lib/vagrant/action/vm/discard_state.rb +2 -2
- data/lib/vagrant/action/vm/export.rb +10 -11
- data/lib/vagrant/action/vm/forward_ports.rb +21 -9
- data/lib/vagrant/action/vm/halt.rb +3 -8
- data/lib/vagrant/action/vm/import.rb +16 -14
- data/lib/vagrant/action/vm/match_mac_address.rb +1 -1
- data/lib/vagrant/action/vm/network.rb +9 -16
- data/lib/vagrant/action/vm/nfs.rb +14 -18
- data/lib/vagrant/action/vm/provision.rb +5 -5
- data/lib/vagrant/action/vm/resume.rb +1 -1
- data/lib/vagrant/action/vm/share_folders.rb +6 -44
- data/lib/vagrant/action/vm/suspend.rb +1 -1
- data/lib/vagrant/action/warden.rb +74 -0
- data/lib/vagrant/box.rb +18 -82
- data/lib/vagrant/box_collection.rb +47 -0
- data/lib/vagrant/cli.rb +55 -0
- data/lib/vagrant/command/base.rb +106 -0
- data/lib/vagrant/command/box.rb +33 -0
- data/lib/vagrant/command/destroy.rb +17 -0
- data/lib/vagrant/command/group_base.rb +99 -0
- data/lib/vagrant/command/halt.rb +18 -0
- data/lib/vagrant/command/helpers.rb +33 -0
- data/lib/vagrant/command/init.rb +14 -0
- data/lib/vagrant/command/named_base.rb +14 -0
- data/lib/vagrant/command/package.rb +41 -0
- data/lib/vagrant/command/provision.rb +17 -0
- data/lib/vagrant/command/reload.rb +17 -0
- data/lib/vagrant/command/resume.rb +17 -0
- data/lib/vagrant/command/ssh.rb +41 -0
- data/lib/vagrant/command/ssh_config.rb +21 -0
- data/lib/vagrant/command/status.rb +23 -0
- data/lib/vagrant/command/suspend.rb +17 -0
- data/lib/vagrant/command/up.rb +20 -0
- data/lib/vagrant/command/upgrade_to_060.rb +45 -0
- data/lib/vagrant/command/version.rb +13 -0
- data/lib/vagrant/config.rb +107 -189
- data/lib/vagrant/config/base.rb +67 -0
- data/lib/vagrant/config/error_recorder.rb +19 -0
- data/lib/vagrant/config/nfs.rb +10 -0
- data/lib/vagrant/config/package.rb +9 -0
- data/lib/vagrant/config/ssh.rb +28 -0
- data/lib/vagrant/config/vagrant.rb +21 -0
- data/lib/vagrant/config/vm.rb +111 -0
- data/lib/vagrant/data_store.rb +68 -0
- data/lib/vagrant/downloaders/file.rb +3 -3
- data/lib/vagrant/downloaders/http.rb +5 -5
- data/lib/vagrant/environment.rb +246 -243
- data/lib/vagrant/errors.rb +306 -0
- data/lib/vagrant/hosts/base.rb +1 -1
- data/lib/vagrant/hosts/bsd.rb +3 -9
- data/lib/vagrant/hosts/linux.rb +3 -9
- data/lib/vagrant/plugin.rb +50 -0
- data/lib/vagrant/provisioners/base.rb +0 -6
- data/lib/vagrant/provisioners/chef.rb +63 -58
- data/lib/vagrant/provisioners/chef_server.rb +9 -11
- data/lib/vagrant/provisioners/chef_solo.rb +2 -2
- data/lib/vagrant/ssh.rb +34 -37
- data/lib/vagrant/systems/base.rb +0 -13
- data/lib/vagrant/systems/linux.rb +10 -33
- data/lib/vagrant/systems/solaris.rb +59 -0
- data/lib/vagrant/test_helpers.rb +109 -0
- data/lib/vagrant/ui.rb +65 -0
- data/lib/vagrant/util.rb +9 -19
- data/lib/vagrant/util/glob_loader.rb +19 -17
- data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
- data/lib/vagrant/util/plain_logger.rb +2 -0
- data/lib/vagrant/util/platform.rb +2 -0
- data/lib/vagrant/util/resource_logger.rb +5 -70
- data/lib/vagrant/util/retryable.rb +25 -0
- data/lib/vagrant/util/template_renderer.rb +1 -1
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +27 -13
- data/templates/commands/init/Vagrantfile.erb +13 -0
- data/templates/config/validation_failed.erb +7 -0
- data/templates/locales/en.yml +402 -0
- data/templates/package_Vagrantfile.erb +1 -1
- data/test/locales/en.yml +8 -0
- data/test/test_helper.rb +19 -103
- data/test/vagrant/action/box/destroy_test.rb +7 -19
- data/test/vagrant/action/box/download_test.rb +9 -25
- data/test/vagrant/action/box/package_test.rb +2 -2
- data/test/vagrant/action/box/unpackage_test.rb +8 -34
- data/test/vagrant/action/box/verify_test.rb +10 -19
- data/test/vagrant/action/builder_test.rb +0 -15
- data/test/vagrant/action/env/set_test.rb +1 -1
- data/test/vagrant/action/environment_test.rb +8 -26
- data/test/vagrant/action/general/package_test.rb +53 -53
- data/test/vagrant/action/vm/boot_test.rb +5 -22
- data/test/vagrant/action/vm/check_box_test.rb +35 -25
- data/test/vagrant/action/vm/clean_machine_folder_test.rb +1 -1
- data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +1 -1
- data/test/vagrant/action/vm/clear_nfs_exports_test.rb +1 -1
- data/test/vagrant/action/vm/clear_shared_folders_test.rb +1 -1
- data/test/vagrant/action/vm/customize_test.rb +2 -1
- data/test/vagrant/action/vm/destroy_test.rb +1 -2
- data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +1 -1
- data/test/vagrant/action/vm/disable_networks_test.rb +10 -1
- data/test/vagrant/action/vm/discard_state_test.rb +10 -1
- data/test/vagrant/action/vm/export_test.rb +9 -37
- data/test/vagrant/action/vm/forward_ports_helpers_test.rb +2 -2
- data/test/vagrant/action/vm/forward_ports_test.rb +19 -16
- data/test/vagrant/action/vm/halt_test.rb +11 -1
- data/test/vagrant/action/vm/import_test.rb +37 -21
- data/test/vagrant/action/vm/match_mac_address_test.rb +1 -1
- data/test/vagrant/action/vm/network_test.rb +8 -7
- data/test/vagrant/action/vm/nfs_helpers_test.rb +6 -3
- data/test/vagrant/action/vm/nfs_test.rb +20 -45
- data/test/vagrant/action/vm/package_test.rb +1 -1
- data/test/vagrant/action/vm/package_vagrantfile_test.rb +1 -1
- data/test/vagrant/action/vm/provision_test.rb +10 -17
- data/test/vagrant/action/vm/resume_test.rb +1 -1
- data/test/vagrant/action/vm/share_folders_test.rb +25 -106
- data/test/vagrant/action/vm/suspend_test.rb +1 -1
- data/test/vagrant/action/warden_test.rb +105 -0
- data/test/vagrant/action_test.rb +5 -27
- data/test/vagrant/box_collection_test.rb +44 -0
- data/test/vagrant/box_test.rb +5 -105
- data/test/vagrant/cli_test.rb +35 -0
- data/test/vagrant/command/base_test.rb +23 -0
- data/test/vagrant/command/group_base_test.rb +15 -0
- data/test/vagrant/command/helpers_test.rb +88 -0
- data/test/vagrant/config/base_test.rb +52 -0
- data/test/vagrant/config/error_recorder_test.rb +18 -0
- data/test/vagrant/config/ssh_test.rb +12 -0
- data/test/vagrant/config/vagrant_test.rb +11 -0
- data/test/vagrant/config/vm_test.rb +70 -0
- data/test/vagrant/config_test.rb +113 -206
- data/test/vagrant/data_store_test.rb +68 -0
- data/test/vagrant/downloaders/base_test.rb +1 -1
- data/test/vagrant/downloaders/file_test.rb +4 -3
- data/test/vagrant/downloaders/http_test.rb +14 -4
- data/test/vagrant/environment_test.rb +290 -590
- data/test/vagrant/errors_test.rb +42 -0
- data/test/vagrant/hosts/base_test.rb +1 -1
- data/test/vagrant/hosts/bsd_test.rb +3 -6
- data/test/vagrant/hosts/linux_test.rb +3 -5
- data/test/vagrant/plugin_test.rb +9 -0
- data/test/vagrant/provisioners/base_test.rb +1 -1
- data/test/vagrant/provisioners/chef_server_test.rb +31 -35
- data/test/vagrant/provisioners/chef_solo_test.rb +1 -1
- data/test/vagrant/provisioners/chef_test.rb +7 -7
- data/test/vagrant/ssh_session_test.rb +3 -10
- data/test/vagrant/ssh_test.rb +25 -33
- data/test/vagrant/systems/linux_test.rb +6 -71
- data/test/vagrant/ui_test.rb +29 -0
- data/test/vagrant/util/hash_with_indifferent_access_test.rb +39 -0
- data/test/vagrant/util/resource_logger_test.rb +14 -81
- data/test/vagrant/util/retryable_test.rb +38 -0
- data/test/vagrant/util/template_renderer_test.rb +4 -4
- data/test/vagrant/vm_test.rb +47 -26
- data/vagrant.gemspec +14 -12
- metadata +121 -89
- data/bin/.gitignore +0 -0
- data/lib/vagrant/action/action_exception.rb +0 -16
- data/lib/vagrant/action/env/error_halt.rb +0 -16
- data/lib/vagrant/action/exception_catcher.rb +0 -14
- data/lib/vagrant/action/vm/persist.rb +0 -22
- data/lib/vagrant/active_list.rb +0 -83
- data/lib/vagrant/command.rb +0 -27
- data/lib/vagrant/commands/base.rb +0 -181
- data/lib/vagrant/commands/box.rb +0 -16
- data/lib/vagrant/commands/box/add.rb +0 -30
- data/lib/vagrant/commands/box/list.rb +0 -30
- data/lib/vagrant/commands/box/remove.rb +0 -30
- data/lib/vagrant/commands/box/repackage.rb +0 -35
- data/lib/vagrant/commands/destroy.rb +0 -37
- data/lib/vagrant/commands/halt.rb +0 -43
- data/lib/vagrant/commands/init.rb +0 -36
- data/lib/vagrant/commands/package.rb +0 -81
- data/lib/vagrant/commands/provision.rb +0 -31
- data/lib/vagrant/commands/reload.rb +0 -36
- data/lib/vagrant/commands/resume.rb +0 -35
- data/lib/vagrant/commands/ssh.rb +0 -78
- data/lib/vagrant/commands/ssh_config.rb +0 -45
- data/lib/vagrant/commands/status.rb +0 -125
- data/lib/vagrant/commands/suspend.rb +0 -36
- data/lib/vagrant/commands/up.rb +0 -44
- data/lib/vagrant/exceptions/uncallable_action.rb +0 -17
- data/lib/vagrant/util/translator.rb +0 -35
- data/templates/strings.yml +0 -341
- data/templates/unison/crontab_entry.erb +0 -1
- data/templates/unison/script.erb +0 -71
- data/test/vagrant/action/env/error_halt_test.rb +0 -21
- data/test/vagrant/action/exception_catcher_test.rb +0 -30
- data/test/vagrant/action/vm/persist_test.rb +0 -50
- data/test/vagrant/active_list_test.rb +0 -173
- data/test/vagrant/command_test.rb +0 -53
- data/test/vagrant/commands/base_test.rb +0 -139
- data/test/vagrant/commands/box/add_test.rb +0 -34
- data/test/vagrant/commands/box/list_test.rb +0 -32
- data/test/vagrant/commands/box/remove_test.rb +0 -41
- data/test/vagrant/commands/box/repackage_test.rb +0 -52
- data/test/vagrant/commands/destroy_test.rb +0 -44
- data/test/vagrant/commands/halt_test.rb +0 -50
- data/test/vagrant/commands/init_test.rb +0 -71
- data/test/vagrant/commands/package_test.rb +0 -97
- data/test/vagrant/commands/provision_test.rb +0 -60
- data/test/vagrant/commands/reload_test.rb +0 -47
- data/test/vagrant/commands/resume_test.rb +0 -44
- data/test/vagrant/commands/ssh_config_test.rb +0 -77
- data/test/vagrant/commands/ssh_test.rb +0 -129
- data/test/vagrant/commands/status_test.rb +0 -40
- data/test/vagrant/commands/suspend_test.rb +0 -44
- data/test/vagrant/commands/up_test.rb +0 -49
- data/test/vagrant/util/translator_test.rb +0 -61
- data/test/vagrant/util_test.rb +0 -27
|
@@ -5,8 +5,6 @@ module Vagrant
|
|
|
5
5
|
# installed and prints a warning if they're not detected or if the
|
|
6
6
|
# version does not match the installed VirtualBox version.
|
|
7
7
|
class CheckGuestAdditions
|
|
8
|
-
include Util
|
|
9
|
-
|
|
10
8
|
def initialize(app, env)
|
|
11
9
|
@app = app
|
|
12
10
|
end
|
|
@@ -16,11 +14,11 @@ module Vagrant
|
|
|
16
14
|
# doesn't support guest properties (due to cross platform issues)
|
|
17
15
|
version = env["vm"].vm.interface.get_guest_property_value("/VirtualBox/GuestAdd/Version")
|
|
18
16
|
if version.empty?
|
|
19
|
-
env.
|
|
17
|
+
env.ui.warn I18n.t("vagrant.actions.vm.check_guest_additions.not_detected")
|
|
20
18
|
elsif version != VirtualBox.version
|
|
21
|
-
env.
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
env.ui.warn(I18n.t("vagrant.actions.vm.check_guest_additions.version_mismatch",
|
|
20
|
+
:guest_version => version,
|
|
21
|
+
:virtualbox_version => VirtualBox.version))
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
# Continue
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require File.
|
|
1
|
+
require File.expand_path("../forward_ports_helpers", __FILE__)
|
|
2
2
|
|
|
3
3
|
module Vagrant
|
|
4
4
|
class Action
|
|
@@ -19,7 +19,7 @@ module Vagrant
|
|
|
19
19
|
|
|
20
20
|
def clear
|
|
21
21
|
if used_ports.length > 0
|
|
22
|
-
@env.
|
|
22
|
+
@env.ui.info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
|
|
23
23
|
clear_ports
|
|
24
24
|
@env["vm"].reload!
|
|
25
25
|
end
|
|
@@ -16,7 +16,7 @@ module Vagrant
|
|
|
16
16
|
|
|
17
17
|
def clear_shared_folders
|
|
18
18
|
if @env["vm"].vm.shared_folders.length > 0
|
|
19
|
-
@env.
|
|
19
|
+
@env.ui.info I18n.t("vagrant.actions.vm.clear_shared_folders.deleting")
|
|
20
20
|
|
|
21
21
|
folders = @env["vm"].vm.shared_folders.dup
|
|
22
22
|
folders.each do |shared_folder|
|
|
@@ -8,7 +8,7 @@ module Vagrant
|
|
|
8
8
|
|
|
9
9
|
def call(env)
|
|
10
10
|
if !env.env.config.vm.proc_stack.empty?
|
|
11
|
-
env.
|
|
11
|
+
env.ui.info I18n.t("vagrant.actions.vm.customize.running")
|
|
12
12
|
env.env.config.vm.run_procs!(env["vm"].vm)
|
|
13
13
|
env["vm"].vm.save
|
|
14
14
|
end
|
|
@@ -7,10 +7,9 @@ module Vagrant
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def call(env)
|
|
10
|
-
env.
|
|
10
|
+
env.ui.info I18n.t("vagrant.actions.vm.destroy.destroying")
|
|
11
11
|
env["vm"].vm.destroy(:destroy_medium => :delete)
|
|
12
12
|
env["vm"].vm = nil
|
|
13
|
-
env.env.update_dotfile
|
|
14
13
|
|
|
15
14
|
@app.call(env)
|
|
16
15
|
end
|
|
@@ -21,7 +21,7 @@ module Vagrant
|
|
|
21
21
|
# Destroy the network interface if there is only one
|
|
22
22
|
# attached VM (which must be this VM)
|
|
23
23
|
if interface.attached_vms.length == 1
|
|
24
|
-
env.
|
|
24
|
+
env.ui.info I18n.t("vagrant.actions.vm.destroy_network.destroying")
|
|
25
25
|
interface.destroy
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -10,18 +10,20 @@ module Vagrant
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def call(env)
|
|
13
|
-
|
|
13
|
+
if env["vm"].created?
|
|
14
|
+
logged = false
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
env["vm"].vm.network_adapters.each do |adapter|
|
|
17
|
+
next if adapter.attachment_type != :host_only
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if !logged
|
|
20
|
+
env.ui.info I18n.t("vagrant.actions.vm.disable_networks.disabling")
|
|
21
|
+
logged = true
|
|
22
|
+
end
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
adapter.enabled = false
|
|
25
|
+
adapter.save
|
|
26
|
+
end
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
@app.call(env)
|
|
@@ -9,8 +9,8 @@ module Vagrant
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def call(env)
|
|
12
|
-
if env["vm"].vm.saved?
|
|
13
|
-
env.
|
|
12
|
+
if env["vm"].created? && env["vm"].vm.saved?
|
|
13
|
+
env.ui.info I18n.t("vagrant.actions.vm.discard_state.discarding")
|
|
14
14
|
env["vm"].vm.discard_state
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
1
3
|
module Vagrant
|
|
2
4
|
class Action
|
|
3
5
|
module VM
|
|
@@ -12,36 +14,33 @@ module Vagrant
|
|
|
12
14
|
def call(env)
|
|
13
15
|
@env = env
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
return if env.error?
|
|
17
|
+
raise Errors::VMPowerOffToPackage.new if !@env["vm"].vm.powered_off?
|
|
17
18
|
|
|
18
19
|
setup_temp_dir
|
|
19
20
|
export
|
|
20
21
|
|
|
21
|
-
@app.call(env)
|
|
22
|
+
@app.call(env)
|
|
22
23
|
|
|
23
|
-
cleanup
|
|
24
|
+
recover(env) # called to cleanup temp directory
|
|
24
25
|
end
|
|
25
26
|
|
|
26
|
-
def
|
|
27
|
+
def recover(env)
|
|
27
28
|
if temp_dir && File.exist?(temp_dir)
|
|
28
29
|
FileUtils.rm_rf(temp_dir)
|
|
29
30
|
end
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def setup_temp_dir
|
|
33
|
-
@env.
|
|
34
|
-
@temp_dir = @env["export.temp_dir"] =
|
|
34
|
+
@env.ui.info I18n.t("vagrant.actions.vm.export.create_dir")
|
|
35
|
+
@temp_dir = @env["export.temp_dir"] = @env.env.tmp_path.join(Time.now.to_i.to_s)
|
|
35
36
|
FileUtils.mkpath(@env["export.temp_dir"])
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
def export
|
|
39
|
-
@env.
|
|
40
|
+
@env.ui.info I18n.t("vagrant.actions.vm.export.exporting")
|
|
40
41
|
@env["vm"].vm.export(ovf_path) do |progress|
|
|
41
|
-
@env.
|
|
42
|
+
@env.ui.report_progress(progress.percent, 100, false)
|
|
42
43
|
end
|
|
43
|
-
ensure
|
|
44
|
-
@env.logger.clear_progress
|
|
45
44
|
end
|
|
46
45
|
|
|
47
46
|
def ovf_path
|
|
@@ -11,7 +11,7 @@ module Vagrant
|
|
|
11
11
|
@env = env
|
|
12
12
|
|
|
13
13
|
threshold_check
|
|
14
|
-
external_collision_check
|
|
14
|
+
external_collision_check
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
#--------------------------------------------------------------
|
|
@@ -23,7 +23,7 @@ module Vagrant
|
|
|
23
23
|
# 1024, which causes the forwarded ports to fail.
|
|
24
24
|
def threshold_check
|
|
25
25
|
@env.env.config.vm.forwarded_ports.each do |name, options|
|
|
26
|
-
|
|
26
|
+
raise Errors::ForwardPortBelowThreshold.new if options[:hostport] <= 1024
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -47,7 +47,9 @@ module Vagrant
|
|
|
47
47
|
if !options[:auto]
|
|
48
48
|
# Auto fixing is disabled for this port forward, so we
|
|
49
49
|
# must throw an error so the user can fix it.
|
|
50
|
-
|
|
50
|
+
raise Errors::ForwardPortCollision.new(:name => name,
|
|
51
|
+
:host_port => options[:hostport].to_s,
|
|
52
|
+
:guest_port => options[:guestport].to_s)
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
# Get the auto port range and get rid of the used ports and
|
|
@@ -58,7 +60,10 @@ module Vagrant
|
|
|
58
60
|
range -= existing_ports
|
|
59
61
|
|
|
60
62
|
if range.empty?
|
|
61
|
-
|
|
63
|
+
raise Errors::ForwardPortAutolistEmpty.new(:vm_name => @env["vm"].name,
|
|
64
|
+
:name => name,
|
|
65
|
+
:host_port => options[:hostport].to_s,
|
|
66
|
+
:guest_port => options[:guestport].to_s)
|
|
62
67
|
end
|
|
63
68
|
|
|
64
69
|
# Set the port up to be the first one and add that port to
|
|
@@ -67,7 +72,9 @@ module Vagrant
|
|
|
67
72
|
existing_ports << options[:hostport]
|
|
68
73
|
|
|
69
74
|
# Notify the user
|
|
70
|
-
@env.
|
|
75
|
+
@env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.fixed_collision",
|
|
76
|
+
:name => name,
|
|
77
|
+
:new_port => options[:hostport]))
|
|
71
78
|
end
|
|
72
79
|
|
|
73
80
|
#--------------------------------------------------------------
|
|
@@ -82,20 +89,25 @@ module Vagrant
|
|
|
82
89
|
end
|
|
83
90
|
|
|
84
91
|
def forward_ports
|
|
85
|
-
@env.
|
|
92
|
+
@env.ui.info I18n.t("vagrant.actions.vm.forward_ports.forwarding")
|
|
86
93
|
|
|
87
94
|
@env.env.config.vm.forwarded_ports.each do |name, options|
|
|
88
95
|
adapter = options[:adapter]
|
|
96
|
+
message_attributes = {
|
|
97
|
+
:name => name,
|
|
98
|
+
:guest_port => options[:guestport],
|
|
99
|
+
:host_port => options[:hostport],
|
|
100
|
+
:adapter => adapter + 1
|
|
101
|
+
}
|
|
89
102
|
|
|
90
103
|
# Assuming the only reason to establish port forwarding is because the VM is using Virtualbox NAT networking.
|
|
91
104
|
# Host-only or Bridged networking don't require port-forwarding and establishing forwarded ports on these
|
|
92
105
|
# attachment types has uncertain behaviour.
|
|
93
106
|
if @env["vm"].vm.network_adapters[adapter].attachment_type == :nat
|
|
94
|
-
@env.
|
|
107
|
+
@env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.forwarding_entry", message_attributes))
|
|
95
108
|
forward_port(name, options)
|
|
96
109
|
else
|
|
97
|
-
@env.
|
|
98
|
-
@env.logger.info "Skipped port forwarding \"#{name}\": #{options[:guestport]} on adapter\##{adapter+1} => #{options[:hostport]}"
|
|
110
|
+
@env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.non_nat", message_attributes))
|
|
99
111
|
end
|
|
100
112
|
end
|
|
101
113
|
|
|
@@ -2,22 +2,17 @@ module Vagrant
|
|
|
2
2
|
class Action
|
|
3
3
|
module VM
|
|
4
4
|
class Halt
|
|
5
|
-
include ExceptionCatcher
|
|
6
|
-
|
|
7
5
|
def initialize(app, env, options=nil)
|
|
8
6
|
@app = app
|
|
9
7
|
env.merge!(options || {})
|
|
10
8
|
end
|
|
11
9
|
|
|
12
10
|
def call(env)
|
|
13
|
-
if env["vm"].vm.running?
|
|
14
|
-
if !env["force"]
|
|
15
|
-
catch_action_exception(env) { env["vm"].system.halt }
|
|
16
|
-
return if env.error?
|
|
17
|
-
end
|
|
11
|
+
if env["vm"].created? && env["vm"].vm.running?
|
|
12
|
+
env["vm"].system.halt if !env["force"]
|
|
18
13
|
|
|
19
14
|
if env["vm"].vm.state(true) != :powered_off
|
|
20
|
-
env.
|
|
15
|
+
env.ui.info I18n.t("vagrant.actions.vm.halt.force")
|
|
21
16
|
env["vm"].vm.stop
|
|
22
17
|
end
|
|
23
18
|
|
|
@@ -7,25 +7,27 @@ module Vagrant
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def call(env)
|
|
10
|
-
env.
|
|
10
|
+
env.ui.info I18n.t("vagrant.actions.vm.import.importing", :name => env.env.box.name)
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
env.
|
|
15
|
-
env.logger.report_progress(progress.percent, 100, false)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Flag as erroneous and return if import failed
|
|
19
|
-
return env.error!(:virtualbox_import_failure) if !env['vm'].vm
|
|
20
|
-
ensure
|
|
21
|
-
env.logger.clear_progress
|
|
12
|
+
# Import the virtual machine
|
|
13
|
+
env.env.vm.vm = VirtualBox::VM.import(env.env.box.ovf_file.to_s) do |progress|
|
|
14
|
+
env.ui.report_progress(progress.percent, 100, false)
|
|
22
15
|
end
|
|
23
16
|
|
|
17
|
+
# Flag as erroneous and return if import failed
|
|
18
|
+
raise Errors::VMImportFailure.new if !env["vm"].vm
|
|
19
|
+
|
|
24
20
|
# Import completed successfully. Continue the chain
|
|
25
|
-
@app.call(env)
|
|
21
|
+
@app.call(env)
|
|
22
|
+
end
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
env["
|
|
24
|
+
def recover(env)
|
|
25
|
+
if env["vm"].created?
|
|
26
|
+
return if env["vagrant.error"].is_a?(Errors::VagrantError)
|
|
27
|
+
|
|
28
|
+
# Interrupted, destroy the VM
|
|
29
|
+
env["actions"].run(:destroy)
|
|
30
|
+
end
|
|
29
31
|
end
|
|
30
32
|
end
|
|
31
33
|
end
|
|
@@ -4,17 +4,12 @@ module Vagrant
|
|
|
4
4
|
# Networking middleware for Vagrant. This enables host only
|
|
5
5
|
# networking on VMs if configured as such.
|
|
6
6
|
class Network
|
|
7
|
-
include ExceptionCatcher
|
|
8
|
-
|
|
9
7
|
def initialize(app, env)
|
|
10
8
|
@app = app
|
|
11
9
|
@env = env
|
|
12
10
|
|
|
13
11
|
env["config"].vm.network_options.compact.each do |network_options|
|
|
14
|
-
if !verify_no_bridge_collision(network_options)
|
|
15
|
-
env.error!(:network_collides)
|
|
16
|
-
return
|
|
17
|
-
end
|
|
12
|
+
raise Errors::NetworkCollision.new if !verify_no_bridge_collision(network_options)
|
|
18
13
|
end
|
|
19
14
|
end
|
|
20
15
|
|
|
@@ -24,13 +19,11 @@ module Vagrant
|
|
|
24
19
|
|
|
25
20
|
@app.call(env)
|
|
26
21
|
|
|
27
|
-
if
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
@env
|
|
32
|
-
@env["vm"].system.enable_host_only_network(network_options)
|
|
33
|
-
end
|
|
22
|
+
if enable_network?
|
|
23
|
+
@env.ui.info I18n.t("vagrant.actions.vm.network.enabling")
|
|
24
|
+
@env["vm"].system.prepare_host_only_network
|
|
25
|
+
@env.env.config.vm.network_options.compact.each do |network_options|
|
|
26
|
+
@env["vm"].system.enable_host_only_network(network_options)
|
|
34
27
|
end
|
|
35
28
|
end
|
|
36
29
|
end
|
|
@@ -61,7 +54,7 @@ module Vagrant
|
|
|
61
54
|
# Enables and assigns the host only network to the proper
|
|
62
55
|
# adapter on the VM, and saves the adapter.
|
|
63
56
|
def assign_network
|
|
64
|
-
@env.
|
|
57
|
+
@env.ui.info I18n.t("vagrant.actions.vm.network.preparing")
|
|
65
58
|
|
|
66
59
|
@env.env.config.vm.network_options.compact.each do |network_options|
|
|
67
60
|
adapter = @env["vm"].vm.network_adapters[network_options[:adapter]]
|
|
@@ -90,10 +83,10 @@ module Vagrant
|
|
|
90
83
|
end
|
|
91
84
|
end
|
|
92
85
|
|
|
93
|
-
|
|
86
|
+
raise Errors::NetworkNotFound.new(:name => net_options[:name]) if net_options[:name]
|
|
94
87
|
|
|
95
88
|
# One doesn't exist, create it.
|
|
96
|
-
@env.
|
|
89
|
+
@env.ui.info I18n.t("vagrant.actions.vm.network.creating")
|
|
97
90
|
|
|
98
91
|
ni = interfaces.create
|
|
99
92
|
ni.enable_static(network_ip(net_options[:ip], net_options[:netmask]),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require File.
|
|
1
|
+
require File.expand_path("../nfs_helpers", __FILE__)
|
|
2
2
|
|
|
3
3
|
module Vagrant
|
|
4
4
|
class Action
|
|
@@ -16,7 +16,6 @@ module Vagrant
|
|
|
16
16
|
# folder.
|
|
17
17
|
#
|
|
18
18
|
class NFS
|
|
19
|
-
include ExceptionCatcher
|
|
20
19
|
include NFSHelpers
|
|
21
20
|
|
|
22
21
|
def initialize(app,env)
|
|
@@ -37,12 +36,13 @@ module Vagrant
|
|
|
37
36
|
export_folders
|
|
38
37
|
end
|
|
39
38
|
|
|
40
|
-
return if env.error?
|
|
41
|
-
|
|
42
39
|
@app.call(env)
|
|
43
40
|
|
|
44
|
-
mount_folders if !folders.empty?
|
|
45
|
-
|
|
41
|
+
mount_folders if !folders.empty?
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def recover(env)
|
|
45
|
+
clear_nfs_exports(env)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
# Returns the folders which are to be synced via NFS.
|
|
@@ -91,7 +91,7 @@ module Vagrant
|
|
|
91
91
|
|
|
92
92
|
# The options on the hash get priority, then the default
|
|
93
93
|
# values
|
|
94
|
-
value = opts[key]
|
|
94
|
+
value = opts.has_key?(key) ? opts[key] : @env["config"].nfs.send(key)
|
|
95
95
|
return value if value != :auto
|
|
96
96
|
|
|
97
97
|
# Get UID/GID from folder if we've made it this far
|
|
@@ -104,20 +104,16 @@ module Vagrant
|
|
|
104
104
|
# involves adding a line to `/etc/exports` for this VM, but it is
|
|
105
105
|
# up to the host class to define the specific behavior.
|
|
106
106
|
def export_folders
|
|
107
|
-
@env.
|
|
107
|
+
@env.ui.info I18n.t("vagrant.actions.vm.nfs.exporting")
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
@env["host"].nfs_export(guest_ip, folders)
|
|
111
|
-
end
|
|
109
|
+
@env["host"].nfs_export(guest_ip, folders)
|
|
112
110
|
end
|
|
113
111
|
|
|
114
112
|
# Uses the system class to mount the NFS folders.
|
|
115
113
|
def mount_folders
|
|
116
|
-
@env.
|
|
114
|
+
@env.ui.info I18n.t("vagrant.actions.vm.nfs.mounting")
|
|
117
115
|
|
|
118
|
-
|
|
119
|
-
@env["vm"].system.mount_nfs(host_ip, folders)
|
|
120
|
-
end
|
|
116
|
+
@env["vm"].system.mount_nfs(host_ip, folders)
|
|
121
117
|
end
|
|
122
118
|
|
|
123
119
|
# Returns the IP address of the first host only network adapter
|
|
@@ -151,9 +147,9 @@ module Vagrant
|
|
|
151
147
|
|
|
152
148
|
# Verifies that the host is set and supports NFS.
|
|
153
149
|
def verify_settings
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
raise Errors::NFSHostRequired.new if @env["host"].nil?
|
|
151
|
+
raise Errors::NFSNotSupported.new if !@env["host"].nfs?
|
|
152
|
+
raise Errors::NFSNoHostNetwork.new if @env["config"].vm.network_options.empty?
|
|
157
153
|
end
|
|
158
154
|
end
|
|
159
155
|
end
|