vagrantup 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
class Action
|
3
5
|
module Box
|
@@ -8,7 +10,7 @@ module Vagrant
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def call(env)
|
11
|
-
env.
|
13
|
+
env.ui.info I18n.t("vagrant.actions.box.destroy.destroying", :name => env["box"].name)
|
12
14
|
FileUtils.rm_rf(env["box"].directory)
|
13
15
|
|
14
16
|
@app.call(env)
|
@@ -13,31 +13,27 @@ module Vagrant
|
|
13
13
|
@env = env
|
14
14
|
@env["download.classes"] ||= []
|
15
15
|
@env["download.classes"] += [Downloaders::HTTP, Downloaders::File]
|
16
|
+
@downloader = nil
|
16
17
|
end
|
17
18
|
|
18
19
|
def call(env)
|
19
20
|
@env = env
|
20
21
|
|
21
22
|
download if instantiate_downloader
|
22
|
-
return if env.error?
|
23
|
-
|
24
23
|
@app.call(@env)
|
25
24
|
|
26
|
-
cleanup
|
25
|
+
recover(env) # called in both cases to cleanup workspace
|
27
26
|
end
|
28
27
|
|
29
28
|
def instantiate_downloader
|
30
29
|
@env["download.classes"].each do |klass|
|
31
30
|
if klass.match?(@env["box"].uri)
|
32
|
-
@env.
|
31
|
+
@env.ui.info I18n.t("vagrant.actions.box.download.with", :class => klass.to_s)
|
33
32
|
@downloader = klass.new(@env)
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
|
-
if !@downloader
|
38
|
-
@env.error!(:box_download_unknown_type)
|
39
|
-
return false
|
40
|
-
end
|
36
|
+
raise Errors::BoxDownloadUnknownType.new if !@downloader
|
41
37
|
|
42
38
|
@downloader.prepare(@env["box"].uri)
|
43
39
|
true
|
@@ -50,26 +46,25 @@ module Vagrant
|
|
50
46
|
end
|
51
47
|
end
|
52
48
|
|
53
|
-
def
|
49
|
+
def recover(env)
|
54
50
|
if temp_path && File.exist?(temp_path)
|
55
|
-
|
51
|
+
env.ui.info I18n.t("vagrant.actions.box.download.cleaning")
|
56
52
|
File.unlink(temp_path)
|
57
53
|
end
|
58
54
|
end
|
59
55
|
|
60
56
|
def with_tempfile
|
61
|
-
@env.logger.info "Creating tempfile for storing box file..."
|
62
57
|
File.open(box_temp_path, Platform.tar_file_options) do |tempfile|
|
63
58
|
yield tempfile
|
64
59
|
end
|
65
60
|
end
|
66
61
|
|
67
62
|
def box_temp_path
|
68
|
-
|
63
|
+
@env.env.tmp_path.join(BASENAME + Time.now.to_i.to_s)
|
69
64
|
end
|
70
65
|
|
71
66
|
def download_to(f)
|
72
|
-
@env.
|
67
|
+
@env.ui.info I18n.t("vagrant.actions.box.download.copying")
|
73
68
|
@downloader.download!(@env["box"].uri, f)
|
74
69
|
end
|
75
70
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'archive/tar/minitar'
|
3
|
+
|
1
4
|
module Vagrant
|
2
5
|
class Action
|
3
6
|
module Box
|
@@ -21,35 +24,29 @@ module Vagrant
|
|
21
24
|
def call(env)
|
22
25
|
@env = env
|
23
26
|
|
24
|
-
|
27
|
+
setup_box_directory
|
25
28
|
decompress
|
26
29
|
|
27
30
|
@app.call(@env)
|
28
|
-
|
29
|
-
cleanup if @env.error?
|
30
31
|
end
|
31
32
|
|
32
|
-
def
|
33
|
+
def recover(env)
|
33
34
|
if File.directory?(box_directory)
|
34
35
|
FileUtils.rm_rf(box_directory)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
39
|
def setup_box_directory
|
39
|
-
if File.directory?(@env["box"].directory)
|
40
|
-
@env.error!(:box_already_exists, :box_name => @env["box"].name)
|
41
|
-
return false
|
42
|
-
end
|
40
|
+
raise Errors::BoxAlreadyExists.new(:name => @env["box"].name) if File.directory?(@env["box"].directory)
|
43
41
|
|
44
42
|
FileUtils.mkdir_p(@env["box"].directory)
|
45
43
|
@box_directory = @env["box"].directory
|
46
|
-
true
|
47
44
|
end
|
48
45
|
|
49
46
|
def decompress
|
50
47
|
Dir.chdir(@env["box"].directory) do
|
51
|
-
@env.
|
52
|
-
Archive::Tar::Minitar.unpack(@env["download.temp_path"], @env["box"].directory)
|
48
|
+
@env.ui.info I18n.t("vagrant.actions.box.unpackage.extracting")
|
49
|
+
Archive::Tar::Minitar.unpack(@env["download.temp_path"], @env["box"].directory.to_s)
|
53
50
|
end
|
54
51
|
end
|
55
52
|
end
|
@@ -9,10 +9,10 @@ module Vagrant
|
|
9
9
|
|
10
10
|
def call(env)
|
11
11
|
begin
|
12
|
-
env.
|
13
|
-
VirtualBox::Appliance.new(env["box"].ovf_file)
|
12
|
+
env.ui.info I18n.t("vagrant.actions.box.verify.verifying")
|
13
|
+
VirtualBox::Appliance.new(env["box"].ovf_file.to_s)
|
14
14
|
rescue Exception
|
15
|
-
|
15
|
+
raise Errors::BoxVerificationFailed.new
|
16
16
|
end
|
17
17
|
|
18
18
|
@app.call(env)
|
@@ -110,36 +110,9 @@ module Vagrant
|
|
110
110
|
# @param [Vagrant::Action::Environment] env The action environment
|
111
111
|
# @return [Object] A callable object
|
112
112
|
def to_app(env)
|
113
|
-
#
|
114
|
-
#
|
115
|
-
|
116
|
-
|
117
|
-
# Convert each middleware into a lambda which takes the next
|
118
|
-
# middleware.
|
119
|
-
items = items.collect do |item|
|
120
|
-
klass, args, block = item
|
121
|
-
|
122
|
-
lambda do |app|
|
123
|
-
if klass.is_a?(Class)
|
124
|
-
# A middleware klass which is to be instantiated with the
|
125
|
-
# app, env, and any arguments given
|
126
|
-
klass.new(app, env, *args, &block)
|
127
|
-
elsif klass.respond_to?(:call)
|
128
|
-
# Make it a lambda which calls the item then forwards
|
129
|
-
# up the chain
|
130
|
-
lambda do |e|
|
131
|
-
klass.call(e)
|
132
|
-
app.call(e)
|
133
|
-
end
|
134
|
-
else
|
135
|
-
raise "Invalid middleware: #{item.inspect}"
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
# Append the final step and convert into flattened call chain.
|
141
|
-
items << lambda { |env| }
|
142
|
-
items[0...-1].reverse.inject(items.last) { |a,e| e.call(a) }
|
113
|
+
# Wrap the middleware stack with the Warden to provide a consistent
|
114
|
+
# and predictable behavior upon exceptions.
|
115
|
+
Warden.new(stack.dup, env)
|
143
116
|
end
|
144
117
|
|
145
118
|
# Runs the builder stack with the given environment.
|
@@ -65,7 +65,6 @@ module Vagrant
|
|
65
65
|
up = Builder.new do
|
66
66
|
use VM::CheckBox
|
67
67
|
use VM::Import
|
68
|
-
use VM::Persist
|
69
68
|
use VM::MatchMACAddress
|
70
69
|
use VM::CheckGuestAdditions
|
71
70
|
use Action[:start]
|
@@ -118,6 +117,12 @@ module Vagrant
|
|
118
117
|
end
|
119
118
|
|
120
119
|
register :box_repackage, box_repackage
|
120
|
+
|
121
|
+
# post_load - Called after environment is loaded
|
122
|
+
environment_load = Builder.new do
|
123
|
+
end
|
124
|
+
|
125
|
+
register :environment_load, environment_load
|
121
126
|
end
|
122
127
|
end
|
123
128
|
end
|
@@ -4,15 +4,11 @@ module Vagrant
|
|
4
4
|
# to the `call` method of each action. This environment contains
|
5
5
|
# some helper methods for accessing the environment as well
|
6
6
|
# as being a hash, to store any additional options.
|
7
|
-
class Environment <
|
7
|
+
class Environment < Util::HashWithIndifferentAccess
|
8
8
|
# The {Vagrant::Environment} object represented by this
|
9
9
|
# action environment.
|
10
10
|
attr_reader :env
|
11
11
|
|
12
|
-
# If nonnil, the error associated with this environment. Set
|
13
|
-
# using {#error!}
|
14
|
-
attr_reader :error
|
15
|
-
|
16
12
|
def initialize(env)
|
17
13
|
super() do |h,k|
|
18
14
|
# By default, try to find the key as a method on the
|
@@ -26,72 +22,28 @@ module Vagrant
|
|
26
22
|
end
|
27
23
|
|
28
24
|
@env = env
|
29
|
-
@
|
30
|
-
end
|
31
|
-
|
32
|
-
# Returns a logger associated with the environment.
|
33
|
-
def logger
|
34
|
-
env.logger
|
25
|
+
@interrupted = false
|
35
26
|
end
|
36
27
|
|
37
|
-
#
|
38
|
-
|
39
|
-
|
40
|
-
# @param [Symbol] key Key to translation to display error message.
|
41
|
-
# @param [Hash] options Variables to pass to the translation
|
42
|
-
def error!(key, options=nil)
|
43
|
-
@error = [key, (options || {})]
|
28
|
+
# Returns a UI object from the environment
|
29
|
+
def ui
|
30
|
+
env.ui
|
44
31
|
end
|
45
32
|
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
|
50
|
-
|
33
|
+
# Marks an environment as interrupted (by an outside signal or
|
34
|
+
# anything). This will trigger any middleware sequences using this
|
35
|
+
# environment to halt. This is automatically set by {Action} when
|
36
|
+
# a SIGINT is captured.
|
37
|
+
def interrupt!
|
38
|
+
@interrupted = true
|
51
39
|
end
|
52
40
|
|
53
41
|
# Returns a boolean denoting if environment has been interrupted
|
54
42
|
# with a SIGINT.
|
43
|
+
#
|
44
|
+
# @return [Bool]
|
55
45
|
def interrupted?
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
#-----------------------------------------------------------------
|
60
|
-
# Hash with indifferent access
|
61
|
-
#-----------------------------------------------------------------
|
62
|
-
def [](key)
|
63
|
-
super(convert_key(key))
|
64
|
-
end
|
65
|
-
|
66
|
-
def []=(key, value)
|
67
|
-
super(convert_key(key), value)
|
68
|
-
end
|
69
|
-
|
70
|
-
def delete(key)
|
71
|
-
super(convert_key(key))
|
72
|
-
end
|
73
|
-
|
74
|
-
def values_at(*indices)
|
75
|
-
indices.collect { |key| self[convert_key(key)] }
|
76
|
-
end
|
77
|
-
|
78
|
-
def merge(other)
|
79
|
-
dup.merge!(other)
|
80
|
-
end
|
81
|
-
|
82
|
-
def merge!(other)
|
83
|
-
other.each do |key, value|
|
84
|
-
self[convert_key(key)] = value
|
85
|
-
end
|
86
|
-
self
|
87
|
-
end
|
88
|
-
|
89
|
-
def has_key?(key)
|
90
|
-
super(convert_key(key))
|
91
|
-
end
|
92
|
-
|
93
|
-
def convert_key(key)
|
94
|
-
key.is_a?(Symbol) ? key.to_s : key
|
46
|
+
!!@interrupted
|
95
47
|
end
|
96
48
|
end
|
97
49
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'archive/tar/minitar'
|
3
|
+
|
1
4
|
module Vagrant
|
2
5
|
class Action
|
3
6
|
module General
|
@@ -19,55 +22,59 @@ module Vagrant
|
|
19
22
|
@env = env
|
20
23
|
@env["package.output"] ||= env["config"].package.name
|
21
24
|
@env["package.include"] ||= []
|
25
|
+
@env["package.vagrantfile"] ||= nil
|
22
26
|
end
|
23
27
|
|
24
28
|
def call(env)
|
25
29
|
@env = env
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
raise Errors::PackageOutputExists.new if File.exist?(tar_path)
|
32
|
+
raise Errors::PackageRequiresDirectory.new if !@env["package.directory"] || !File.directory?(@env["package.directory"])
|
33
|
+
|
34
|
+
verify_files_to_copy
|
30
35
|
compress
|
31
36
|
|
32
37
|
@app.call(env)
|
33
|
-
|
34
|
-
cleanup if env.error?
|
35
38
|
end
|
36
39
|
|
37
|
-
def
|
40
|
+
def recover(env)
|
38
41
|
# Cleanup any packaged files if the packaging failed at some point.
|
39
42
|
File.delete(tar_path) if File.exist?(tar_path)
|
40
43
|
end
|
41
44
|
|
42
|
-
def
|
43
|
-
@env["package.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
def files_to_copy
|
46
|
+
package_dir = Pathname.new(@env["package.directory"]).join("include")
|
47
|
+
|
48
|
+
files = @env["package.include"].inject({}) do |acc, file|
|
49
|
+
source = Pathname.new(file)
|
50
|
+
acc[file] = source.relative? ? package_dir.join(source) : package_dir.join(source.basename)
|
51
|
+
acc
|
48
52
|
end
|
49
53
|
|
50
|
-
|
54
|
+
files[@env["package.vagrantfile"]] = package_dir.join("_Vagrantfile") if @env["package.vagrantfile"]
|
55
|
+
files
|
56
|
+
end
|
57
|
+
|
58
|
+
def verify_files_to_copy
|
59
|
+
files_to_copy.each do |file, _|
|
60
|
+
raise Errors::PackageIncludeMissing.new(:file => file) if !File.exist?(file)
|
61
|
+
end
|
51
62
|
end
|
52
63
|
|
53
64
|
# This method copies the include files (passed in via command line)
|
54
65
|
# to the temporary directory so they are included in a sub-folder within
|
55
66
|
# the actual box
|
56
67
|
def copy_include_files
|
57
|
-
|
58
|
-
|
59
|
-
FileUtils.mkdir_p(
|
60
|
-
|
61
|
-
@env["package.include"].each do |f|
|
62
|
-
@env.logger.info "Packaging additional file: #{f}"
|
63
|
-
FileUtils.cp(f, include_dir)
|
64
|
-
end
|
68
|
+
files_to_copy.each do |from, to|
|
69
|
+
@env.ui.info I18n.t("vagrant.actions.general.package.packaging", :file => from)
|
70
|
+
FileUtils.mkdir_p(to.parent)
|
71
|
+
FileUtils.cp(from, to)
|
65
72
|
end
|
66
73
|
end
|
67
74
|
|
68
75
|
# Compress the exported file into a package
|
69
76
|
def compress
|
70
|
-
@env.
|
77
|
+
@env.ui.info I18n.t("vagrant.actions.general.package.compressing", :tar_path => tar_path)
|
71
78
|
File.open(tar_path, Platform.tar_file_options) do |tar|
|
72
79
|
Archive::Tar::Minitar::Output.open(tar) do |output|
|
73
80
|
begin
|
@@ -8,32 +8,25 @@ module Vagrant
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(env)
|
11
|
-
# Do nothing if the environment is erroneous
|
12
|
-
return if env.error?
|
13
|
-
|
14
11
|
@env = env
|
15
12
|
|
16
13
|
# Start up the VM and wait for it to boot.
|
17
14
|
boot
|
18
|
-
|
19
|
-
return if env.error?
|
20
|
-
|
15
|
+
raise Errors::VMFailedToBoot.new if !wait_for_boot
|
21
16
|
@app.call(env)
|
22
17
|
end
|
23
18
|
|
24
19
|
def boot
|
25
|
-
@env.
|
20
|
+
@env.ui.info I18n.t("vagrant.actions.vm.boot.booting")
|
26
21
|
@env["vm"].vm.start(@env.env.config.vm.boot_mode)
|
27
22
|
end
|
28
23
|
|
29
24
|
def wait_for_boot
|
30
|
-
@env.
|
25
|
+
@env.ui.info I18n.t("vagrant.actions.vm.boot.waiting")
|
31
26
|
|
32
27
|
@env.env.config.ssh.max_tries.to_i.times do |i|
|
33
|
-
@env.logger.info "Trying to connect (attempt ##{i+1} of #{@env.env.config[:ssh][:max_tries]})..."
|
34
|
-
|
35
28
|
if @env["vm"].ssh.up?
|
36
|
-
@env.
|
29
|
+
@env.ui.info I18n.t("vagrant.actions.vm.boot.ready")
|
37
30
|
return true
|
38
31
|
end
|
39
32
|
|
@@ -44,7 +37,7 @@ module Vagrant
|
|
44
37
|
sleep 5 if !@env["vagrant.test"]
|
45
38
|
end
|
46
39
|
|
47
|
-
@env.
|
40
|
+
@env.ui.error I18n.t("vagrant.actions.vm.boot.failed")
|
48
41
|
false
|
49
42
|
end
|
50
43
|
end
|
@@ -8,13 +8,13 @@ module Vagrant
|
|
8
8
|
|
9
9
|
def call(env)
|
10
10
|
box_name = env["config"].vm.box
|
11
|
-
|
11
|
+
raise Errors::BoxNotSpecified.new if !box_name
|
12
12
|
|
13
|
-
if !
|
13
|
+
if !env.env.boxes.find(box_name)
|
14
14
|
box_url = env["config"].vm.box_url
|
15
|
-
|
15
|
+
raise Errors::BoxSpecifiedDoesntExist.new(:name => box_name) if !box_url
|
16
16
|
|
17
|
-
env.
|
17
|
+
env.ui.info I18n.t("vagrant.actions.vm.check_box.not_found", :name => box_name)
|
18
18
|
Vagrant::Box.add(env.env, box_name, box_url)
|
19
19
|
env.env.load_box!
|
20
20
|
end
|