vagrantup 0.4.3.dev → 0.5.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/README.md +1 -0
- data/config/default.rb +6 -6
- data/lib/vagrant.rb +6 -3
- data/lib/vagrant/action.rb +77 -0
- data/lib/vagrant/action/action_exception.rb +16 -0
- data/lib/vagrant/action/box/destroy.rb +19 -0
- data/lib/vagrant/action/box/download.rb +78 -0
- data/lib/vagrant/action/box/unpackage.rb +58 -0
- data/lib/vagrant/action/box/verify.rb +23 -0
- data/lib/vagrant/action/builder.rb +151 -0
- data/lib/vagrant/action/builtin.rb +114 -0
- data/lib/vagrant/action/env/error_halt.rb +16 -0
- data/lib/vagrant/action/env/set.rb +18 -0
- data/lib/vagrant/action/environment.rb +98 -0
- data/lib/vagrant/action/exception_catcher.rb +14 -0
- data/lib/vagrant/action/vm/boot.rb +54 -0
- data/lib/vagrant/action/vm/check_box.rb +27 -0
- data/lib/vagrant/action/vm/check_guest_additions.rb +32 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +39 -0
- data/lib/vagrant/action/vm/clear_nfs_exports.rb +20 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +32 -0
- data/lib/vagrant/action/vm/customize.rb +21 -0
- data/lib/vagrant/action/vm/destroy.rb +20 -0
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +35 -0
- data/lib/vagrant/action/vm/disable_networks.rb +26 -0
- data/lib/vagrant/action/vm/export.rb +53 -0
- data/lib/vagrant/action/vm/forward_ports.rb +121 -0
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +28 -0
- data/lib/vagrant/action/vm/halt.rb +34 -0
- data/lib/vagrant/action/vm/import.rb +33 -0
- data/lib/vagrant/action/vm/match_mac_address.rb +19 -0
- data/lib/vagrant/{actions → action}/vm/network.rb +47 -55
- data/lib/vagrant/action/vm/nfs.rb +161 -0
- data/lib/vagrant/action/vm/nfs_helpers.rb +11 -0
- data/lib/vagrant/action/vm/package.rb +99 -0
- data/lib/vagrant/action/vm/persist.rb +22 -0
- data/lib/vagrant/action/vm/provision.rb +50 -0
- data/lib/vagrant/action/vm/resume.rb +20 -0
- data/lib/vagrant/{actions/vm/shared_folders.rb → action/vm/share_folders.rb} +48 -45
- data/lib/vagrant/action/vm/suspend.rb +20 -0
- data/lib/vagrant/box.rb +3 -7
- data/lib/vagrant/commands/base.rb +1 -3
- data/lib/vagrant/commands/package.rb +4 -9
- data/lib/vagrant/commands/up.rb +0 -2
- data/lib/vagrant/config.rb +15 -1
- data/lib/vagrant/downloaders/file.rb +1 -1
- data/lib/vagrant/downloaders/http.rb +2 -1
- data/lib/vagrant/environment.rb +18 -14
- data/lib/vagrant/hosts/base.rb +77 -0
- data/lib/vagrant/hosts/bsd.rb +53 -0
- data/lib/vagrant/hosts/linux.rb +52 -0
- data/lib/vagrant/provisioners/base.rb +17 -9
- data/lib/vagrant/provisioners/chef.rb +1 -1
- data/lib/vagrant/provisioners/chef_server.rb +4 -8
- data/lib/vagrant/provisioners/chef_solo.rb +1 -2
- data/lib/vagrant/ssh.rb +12 -4
- data/lib/vagrant/systems/base.rb +4 -0
- data/lib/vagrant/systems/linux.rb +12 -1
- data/lib/vagrant/util.rb +16 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/plain_logger.rb +11 -0
- data/lib/vagrant/util/platform.rb +18 -0
- data/lib/vagrant/util/resource_logger.rb +128 -0
- data/lib/vagrant/version.rb +6 -0
- data/lib/vagrant/vm.rb +10 -12
- data/templates/chef_solo_solo.erb +2 -1
- data/templates/nfs/exports.erb +3 -0
- data/templates/nfs/exports_linux.erb +3 -0
- data/templates/strings.yml +23 -3
- metadata +121 -196
- data/.gitignore +0 -11
- data/Gemfile +0 -18
- data/Rakefile +0 -41
- data/VERSION +0 -1
- data/bin/.gitignore +0 -0
- data/lib/vagrant/actions/base.rb +0 -130
- data/lib/vagrant/actions/box/add.rb +0 -23
- data/lib/vagrant/actions/box/destroy.rb +0 -14
- data/lib/vagrant/actions/box/download.rb +0 -67
- data/lib/vagrant/actions/box/unpackage.rb +0 -42
- data/lib/vagrant/actions/box/verify.rb +0 -32
- data/lib/vagrant/actions/collection.rb +0 -36
- data/lib/vagrant/actions/runner.rb +0 -131
- data/lib/vagrant/actions/vm/boot.rb +0 -43
- data/lib/vagrant/actions/vm/customize.rb +0 -19
- data/lib/vagrant/actions/vm/destroy.rb +0 -24
- data/lib/vagrant/actions/vm/down.rb +0 -22
- data/lib/vagrant/actions/vm/export.rb +0 -45
- data/lib/vagrant/actions/vm/forward_ports.rb +0 -134
- data/lib/vagrant/actions/vm/halt.rb +0 -24
- data/lib/vagrant/actions/vm/import.rb +0 -23
- data/lib/vagrant/actions/vm/move_hard_drive.rb +0 -51
- data/lib/vagrant/actions/vm/package.rb +0 -94
- data/lib/vagrant/actions/vm/provision.rb +0 -49
- data/lib/vagrant/actions/vm/reload.rb +0 -17
- data/lib/vagrant/actions/vm/resume.rb +0 -16
- data/lib/vagrant/actions/vm/start.rb +0 -26
- data/lib/vagrant/actions/vm/suspend.rb +0 -16
- data/lib/vagrant/actions/vm/up.rb +0 -53
- data/lib/vagrant/busy.rb +0 -79
- data/lib/vagrant/resource_logger.rb +0 -126
- data/lib/vagrant/util/error_helper.rb +0 -13
- data/lib/vagrant/util/output_helper.rb +0 -9
- data/test/test_helper.rb +0 -149
- data/test/vagrant/actions/base_test.rb +0 -32
- data/test/vagrant/actions/box/add_test.rb +0 -36
- data/test/vagrant/actions/box/destroy_test.rb +0 -17
- data/test/vagrant/actions/box/download_test.rb +0 -137
- data/test/vagrant/actions/box/unpackage_test.rb +0 -99
- data/test/vagrant/actions/box/verify_test.rb +0 -44
- data/test/vagrant/actions/collection_test.rb +0 -113
- data/test/vagrant/actions/runner_test.rb +0 -268
- data/test/vagrant/actions/vm/boot_test.rb +0 -49
- data/test/vagrant/actions/vm/customize_test.rb +0 -21
- data/test/vagrant/actions/vm/destroy_test.rb +0 -37
- data/test/vagrant/actions/vm/down_test.rb +0 -39
- data/test/vagrant/actions/vm/export_test.rb +0 -88
- data/test/vagrant/actions/vm/forward_ports_test.rb +0 -253
- data/test/vagrant/actions/vm/halt_test.rb +0 -65
- data/test/vagrant/actions/vm/import_test.rb +0 -45
- data/test/vagrant/actions/vm/move_hard_drive_test.rb +0 -106
- data/test/vagrant/actions/vm/network_test.rb +0 -291
- data/test/vagrant/actions/vm/package_test.rb +0 -254
- data/test/vagrant/actions/vm/provision_test.rb +0 -99
- data/test/vagrant/actions/vm/reload_test.rb +0 -46
- data/test/vagrant/actions/vm/resume_test.rb +0 -26
- data/test/vagrant/actions/vm/shared_folders_test.rb +0 -211
- data/test/vagrant/actions/vm/start_test.rb +0 -73
- data/test/vagrant/actions/vm/suspend_test.rb +0 -26
- data/test/vagrant/actions/vm/up_test.rb +0 -96
- data/test/vagrant/active_list_test.rb +0 -173
- data/test/vagrant/box_test.rb +0 -154
- data/test/vagrant/busy_test.rb +0 -78
- 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/destroy_test.rb +0 -44
- data/test/vagrant/commands/halt_test.rb +0 -50
- data/test/vagrant/commands/init_test.rb +0 -55
- data/test/vagrant/commands/package_test.rb +0 -104
- data/test/vagrant/commands/provision_test.rb +0 -60
- data/test/vagrant/commands/reload_test.rb +0 -44
- 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 -47
- data/test/vagrant/config_test.rb +0 -287
- data/test/vagrant/downloaders/base_test.rb +0 -28
- data/test/vagrant/downloaders/file_test.rb +0 -33
- data/test/vagrant/downloaders/http_test.rb +0 -62
- data/test/vagrant/environment_test.rb +0 -770
- data/test/vagrant/provisioners/base_test.rb +0 -33
- data/test/vagrant/provisioners/chef_server_test.rb +0 -176
- data/test/vagrant/provisioners/chef_solo_test.rb +0 -183
- data/test/vagrant/provisioners/chef_test.rb +0 -175
- data/test/vagrant/resource_logger_test.rb +0 -145
- data/test/vagrant/ssh_session_test.rb +0 -46
- data/test/vagrant/ssh_test.rb +0 -296
- data/test/vagrant/systems/linux_test.rb +0 -179
- data/test/vagrant/util/error_helper_test.rb +0 -5
- data/test/vagrant/util/output_helper_test.rb +0 -5
- data/test/vagrant/util/plain_logger_test.rb +0 -17
- data/test/vagrant/util/platform_test.rb +0 -18
- data/test/vagrant/util/stacked_proc_runner_test.rb +0 -43
- data/test/vagrant/util/template_renderer_test.rb +0 -144
- data/test/vagrant/util/translator_test.rb +0 -61
- data/test/vagrant/util_test.rb +0 -27
- data/test/vagrant/vm_test.rb +0 -235
- data/vagrant.gemspec +0 -291
@@ -1,49 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module Actions
|
3
|
-
module VM
|
4
|
-
class Provision < Base
|
5
|
-
attr_reader :provisioner
|
6
|
-
|
7
|
-
def intialize(*args)
|
8
|
-
super
|
9
|
-
|
10
|
-
@provisioner = nil
|
11
|
-
end
|
12
|
-
|
13
|
-
def prepare
|
14
|
-
provisioner = @runner.env.config.vm.provisioner
|
15
|
-
|
16
|
-
if provisioner.nil?
|
17
|
-
logger.info("Provisioning not enabled, ignoring this step")
|
18
|
-
return
|
19
|
-
end
|
20
|
-
|
21
|
-
if provisioner.is_a?(Class)
|
22
|
-
@provisioner = provisioner.new(@runner)
|
23
|
-
raise ActionException.new(:provisioner_invalid_class) unless @provisioner.is_a?(Provisioners::Base)
|
24
|
-
elsif provisioner.is_a?(Symbol)
|
25
|
-
# We have a few hard coded provisioners for built-ins
|
26
|
-
mapping = {
|
27
|
-
:chef_solo => Provisioners::ChefSolo,
|
28
|
-
:chef_server => Provisioners::ChefServer
|
29
|
-
}
|
30
|
-
|
31
|
-
provisioner_klass = mapping[provisioner]
|
32
|
-
raise ActionException.new(:provisioner_unknown_type, :provisioner => provisioner.to_s) if provisioner_klass.nil?
|
33
|
-
@provisioner = provisioner_klass.new(@runner)
|
34
|
-
end
|
35
|
-
|
36
|
-
logger.info "Provisioning enabled with #{@provisioner.class}"
|
37
|
-
@provisioner.prepare
|
38
|
-
end
|
39
|
-
|
40
|
-
def execute!
|
41
|
-
if provisioner
|
42
|
-
logger.info "Beginning provisioning process..."
|
43
|
-
provisioner.provision!
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module Actions
|
3
|
-
module VM
|
4
|
-
class Reload < Base
|
5
|
-
def prepare
|
6
|
-
steps = [Customize, ForwardPorts, SharedFolders, Network, Boot]
|
7
|
-
steps.unshift(Halt) if @runner.vm.running?
|
8
|
-
steps << Provision if !@runner.env.config.vm.provisioner.nil?
|
9
|
-
|
10
|
-
steps.each do |action_klass|
|
11
|
-
@runner.add_action(action_klass)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module Actions
|
3
|
-
module VM
|
4
|
-
class Resume < Base
|
5
|
-
def execute!
|
6
|
-
if !@runner.vm.saved?
|
7
|
-
raise ActionException.new(:vm_not_suspended)
|
8
|
-
end
|
9
|
-
|
10
|
-
logger.info "Resuming suspended VM..."
|
11
|
-
@runner.start
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module Actions
|
3
|
-
module VM
|
4
|
-
class Start < Base
|
5
|
-
def prepare
|
6
|
-
# Start is a "meta-action" so it really just queues up a bunch
|
7
|
-
# of other actions in its place:
|
8
|
-
steps = [Boot]
|
9
|
-
if !@runner.vm || !@runner.vm.saved?
|
10
|
-
steps.unshift([Customize, ForwardPorts, SharedFolders, Network])
|
11
|
-
steps << Provision if provision?
|
12
|
-
end
|
13
|
-
|
14
|
-
steps.flatten.each do |action_klass|
|
15
|
-
@runner.add_action(action_klass, options)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def provision?
|
20
|
-
enabled = options[:provision].nil? ? true : options[:provision]
|
21
|
-
!@runner.env.config.vm.provisioner.nil? && enabled
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module Actions
|
3
|
-
module VM
|
4
|
-
class Suspend < Base
|
5
|
-
def execute!
|
6
|
-
if !@runner.vm.running?
|
7
|
-
raise ActionException.new(:vm_not_running_for_suspend)
|
8
|
-
end
|
9
|
-
|
10
|
-
logger.info "Saving VM state and suspending execution..."
|
11
|
-
@runner.vm.save_state
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module Actions
|
3
|
-
module VM
|
4
|
-
class Up < Base
|
5
|
-
def prepare
|
6
|
-
# If the dotfile is not a file, raise error
|
7
|
-
if File.exist?(@runner.env.dotfile_path) && !File.file?(@runner.env.dotfile_path)
|
8
|
-
raise ActionException.new(:dotfile_error, :env => @runner.env)
|
9
|
-
end
|
10
|
-
|
11
|
-
# Up is a "meta-action" so it really just queues up a bunch
|
12
|
-
# of other actions in its place:
|
13
|
-
steps = [Import, Start]
|
14
|
-
steps.insert(0, MoveHardDrive) if @runner.env.config.vm.hd_location
|
15
|
-
|
16
|
-
steps.each do |action_klass|
|
17
|
-
@runner.add_action(action_klass, options)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def after_import
|
22
|
-
update_dotfile
|
23
|
-
setup_mac_address
|
24
|
-
check_guest_additions
|
25
|
-
end
|
26
|
-
|
27
|
-
def update_dotfile
|
28
|
-
logger.info "Persisting the VM UUID (#{@runner.uuid})..."
|
29
|
-
@runner.env.update_dotfile
|
30
|
-
end
|
31
|
-
|
32
|
-
def setup_mac_address
|
33
|
-
logger.info "Matching MAC addresses..."
|
34
|
-
@runner.vm.network_adapters.first.mac_address = @runner.env.config.vm.base_mac
|
35
|
-
@runner.vm.save
|
36
|
-
end
|
37
|
-
|
38
|
-
def check_guest_additions
|
39
|
-
# Use the raw interface for now, while the virtualbox gem
|
40
|
-
# doesn't support guest properties (due to cross platform issues)
|
41
|
-
version = @runner.vm.interface.get_guest_property_value("/VirtualBox/GuestAdd/Version")
|
42
|
-
if version.empty?
|
43
|
-
logger.error Translator.t(:vm_additions_not_detected)
|
44
|
-
elsif version != VirtualBox.version
|
45
|
-
logger.error Translator.t(:vm_additions_version_mismatch,
|
46
|
-
:guest_additions_version => version,
|
47
|
-
:virtualbox_version => VirtualBox.version)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/lib/vagrant/busy.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
def self.busy?
|
3
|
-
Busy.busy?
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.busy(&block)
|
7
|
-
Busy.busy(&block)
|
8
|
-
end
|
9
|
-
|
10
|
-
class Busy
|
11
|
-
extend Vagrant::Util
|
12
|
-
|
13
|
-
@@busy = false
|
14
|
-
@@mutex = Mutex.new
|
15
|
-
@@trap_thread = nil
|
16
|
-
|
17
|
-
class << self
|
18
|
-
def busy?
|
19
|
-
@@busy
|
20
|
-
end
|
21
|
-
|
22
|
-
def busy=(val)
|
23
|
-
@@busy = val
|
24
|
-
end
|
25
|
-
|
26
|
-
def busy(&block)
|
27
|
-
@@mutex.synchronize do
|
28
|
-
begin
|
29
|
-
Signal.trap("INT") { wait_for_not_busy }
|
30
|
-
Busy.busy = true
|
31
|
-
block.call
|
32
|
-
ensure
|
33
|
-
# In the case an exception is thrown, make sure we restore
|
34
|
-
# busy back to some sane state.
|
35
|
-
Busy.busy = false
|
36
|
-
|
37
|
-
# Make sure that the trap thread completes, if it is running
|
38
|
-
trap_thread.join if trap_thread
|
39
|
-
|
40
|
-
# And restore the INT trap to the default
|
41
|
-
Signal.trap("INT", "DEFAULT")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def wait_for_not_busy(sleeptime=5)
|
47
|
-
if @@trap_thread
|
48
|
-
# logger.info "Exiting vagrant immediately!"
|
49
|
-
Thread.kill(@@trap_thread)
|
50
|
-
abort
|
51
|
-
return # for tests
|
52
|
-
end
|
53
|
-
|
54
|
-
@@trap_thread ||= Thread.new do
|
55
|
-
# Wait while the app is busy
|
56
|
-
loop do
|
57
|
-
break unless busy?
|
58
|
-
# logger.info "Waiting for vagrant to clean itself up..."
|
59
|
-
sleep sleeptime
|
60
|
-
end
|
61
|
-
|
62
|
-
# Exit out of the entire script
|
63
|
-
# logger.info "Exiting vagrant..."
|
64
|
-
exit
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# Used for testing
|
69
|
-
def reset_trap_thread!
|
70
|
-
@@trap_thread = nil
|
71
|
-
end
|
72
|
-
|
73
|
-
# Returns the trap thread
|
74
|
-
def trap_thread
|
75
|
-
@@trap_thread
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
require 'thread'
|
2
|
-
|
3
|
-
module Vagrant
|
4
|
-
# Represents a logger for a specific resource within Vagrant. Each
|
5
|
-
# logger should be initialized and set to represent a single
|
6
|
-
# resource. Each logged message will then appear in the following
|
7
|
-
# format:
|
8
|
-
#
|
9
|
-
# [resource] message
|
10
|
-
#
|
11
|
-
# This class is thread safe. The backing class which actually does
|
12
|
-
# all the logging IO is protected.
|
13
|
-
#
|
14
|
-
# This class also handles progress meters of multiple resources and
|
15
|
-
# handles all the proper interleaving and console updating to
|
16
|
-
# display the progress meters in a way which doesn't conflict with
|
17
|
-
# other incoming log messages.
|
18
|
-
class ResourceLogger
|
19
|
-
@@singleton_logger = nil
|
20
|
-
@@progress_reporters = nil
|
21
|
-
@@writer_lock = Mutex.new
|
22
|
-
|
23
|
-
# The resource which this logger represents.
|
24
|
-
attr_reader :resource
|
25
|
-
|
26
|
-
# The environment that this logger is part of
|
27
|
-
attr_reader :env
|
28
|
-
|
29
|
-
# The backing logger which actually handles the IO. This logger
|
30
|
-
# should be a subclass of the standard library Logger, in general.
|
31
|
-
# IMPORTANT: This logger must be thread-safe.
|
32
|
-
attr_reader :logger
|
33
|
-
|
34
|
-
class << self
|
35
|
-
# Returns a singleton logger. If one has not yet be
|
36
|
-
# instantiated, then the given environment will be used to
|
37
|
-
# create a new logger.
|
38
|
-
def singleton_logger(env=nil)
|
39
|
-
if env && env.config && env.config.loaded?
|
40
|
-
@@singleton_logger ||= Util::PlainLogger.new(env.config.vagrant.log_output)
|
41
|
-
else
|
42
|
-
Util::PlainLogger.new(nil)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Resets the singleton logger (only used for testing).
|
47
|
-
def reset_singleton_logger!
|
48
|
-
@@singleton_logger = nil
|
49
|
-
end
|
50
|
-
|
51
|
-
# Returns the progress parts array which contains the various
|
52
|
-
# progress reporters.
|
53
|
-
def progress_reporters
|
54
|
-
@@progress_reporters ||= {}
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def initialize(resource, env)
|
59
|
-
@resource = resource
|
60
|
-
@env = env
|
61
|
-
@logger = self.class.singleton_logger(env)
|
62
|
-
end
|
63
|
-
|
64
|
-
[:debug, :info, :error, :fatal].each do |method|
|
65
|
-
define_method(method) do |message|
|
66
|
-
@@writer_lock.synchronize do
|
67
|
-
# We clear the line in case progress reports have been going
|
68
|
-
# out.
|
69
|
-
print(cl_reset)
|
70
|
-
logger.send(method, "[#{resource}] #{message}")
|
71
|
-
end
|
72
|
-
|
73
|
-
# Once again flush the progress reporters since we probably
|
74
|
-
# cleared any existing ones.
|
75
|
-
flush_progress
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Sets a progress report for the resource that this logger
|
80
|
-
# represents. This progress report is interleaved within the output.
|
81
|
-
def report_progress(progress, total, show_parts=true)
|
82
|
-
# Simply add the progress reporter to the list of progress
|
83
|
-
# reporters
|
84
|
-
self.class.progress_reporters[resource] = {
|
85
|
-
:progress => progress,
|
86
|
-
:total => total,
|
87
|
-
:show_parts => show_parts
|
88
|
-
}
|
89
|
-
|
90
|
-
# And force an update to occur
|
91
|
-
flush_progress
|
92
|
-
end
|
93
|
-
|
94
|
-
# Clears the progress report for this resource
|
95
|
-
def clear_progress
|
96
|
-
self.class.progress_reporters.delete(resource)
|
97
|
-
end
|
98
|
-
|
99
|
-
def flush_progress
|
100
|
-
# Don't do anything if there are no progress reporters
|
101
|
-
return if self.class.progress_reporters.length <= 0
|
102
|
-
|
103
|
-
@@writer_lock.synchronize do
|
104
|
-
reports = []
|
105
|
-
|
106
|
-
# First generate all the report percentages and output
|
107
|
-
self.class.progress_reporters.each do |name, data|
|
108
|
-
percent = (data[:progress].to_f / data[:total].to_f) * 100
|
109
|
-
line = "#{name}: #{percent.to_i}%"
|
110
|
-
line << " (#{data[:progress]} / #{data[:total]})" if data[:show_parts]
|
111
|
-
reports << line
|
112
|
-
end
|
113
|
-
|
114
|
-
# Output it to stdout
|
115
|
-
print "#{cl_reset}[progress] #{reports.join(" ")}"
|
116
|
-
$stdout.flush
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def cl_reset
|
121
|
-
reset = "\r"
|
122
|
-
reset += "\e[0K" unless Mario::Platform.windows?
|
123
|
-
reset
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module Util
|
3
|
-
def error_and_exit(key, data = {})
|
4
|
-
abort <<-error
|
5
|
-
=====================================================================
|
6
|
-
Vagrant experienced an error!
|
7
|
-
|
8
|
-
#{Translator.t(key, data).chomp}
|
9
|
-
=====================================================================
|
10
|
-
error
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,149 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require File.expand_path('../.bundle/environment', __FILE__)
|
3
|
-
rescue LoadError
|
4
|
-
# Fallback on doing the resolve at runtime.
|
5
|
-
require "rubygems"
|
6
|
-
end
|
7
|
-
|
8
|
-
# ruby-debug, not necessary, but useful if we have it
|
9
|
-
begin
|
10
|
-
require 'ruby-debug'
|
11
|
-
rescue LoadError; end
|
12
|
-
|
13
|
-
|
14
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'vagrant')
|
15
|
-
require 'contest'
|
16
|
-
require 'mocha'
|
17
|
-
|
18
|
-
class Test::Unit::TestCase
|
19
|
-
# Mocks an environment, setting it up with the given config.
|
20
|
-
def mock_environment
|
21
|
-
environment = Vagrant::Environment.new
|
22
|
-
|
23
|
-
Vagrant::Config.reset!(environment)
|
24
|
-
|
25
|
-
Vagrant::Config.run do |config|
|
26
|
-
config.vagrant.home = '~/.home'
|
27
|
-
config.vagrant.dotfile_name = ".vagrant"
|
28
|
-
config.vagrant.log_output = nil
|
29
|
-
|
30
|
-
config.ssh.username = "foo"
|
31
|
-
config.ssh.host = "baz"
|
32
|
-
config.ssh.port = 22
|
33
|
-
config.ssh.forwarded_port_key = "ssh"
|
34
|
-
config.ssh.max_tries = 10
|
35
|
-
config.ssh.timeout = 10
|
36
|
-
config.ssh.private_key_path = '~/foo'
|
37
|
-
|
38
|
-
config.vm.box = "foo"
|
39
|
-
config.vm.box_ovf = "box.ovf"
|
40
|
-
config.vm.base_mac = "42"
|
41
|
-
config.vm.disk_image_format = 'VMDK'
|
42
|
-
config.vm.forward_port("ssh", 22, 2222)
|
43
|
-
config.vm.shared_folder_uid = nil
|
44
|
-
config.vm.shared_folder_gid = nil
|
45
|
-
config.vm.system = :linux
|
46
|
-
config.vm.share_folder("v-root", "/vagrant", ".")
|
47
|
-
|
48
|
-
config.package.name = 'vagrant'
|
49
|
-
config.package.extension = '.box'
|
50
|
-
|
51
|
-
# Unison
|
52
|
-
config.unison.folder_suffix = ".sync"
|
53
|
-
config.unison.log_file = "foo-%s"
|
54
|
-
|
55
|
-
# Chef
|
56
|
-
config.chef.chef_server_url = "http://localhost:4000"
|
57
|
-
config.chef.validation_key_path = "validation.pem"
|
58
|
-
config.chef.client_key_path = "/zoo/foo/bar.pem"
|
59
|
-
config.chef.node_name = "baz"
|
60
|
-
config.chef.cookbooks_path = "cookbooks"
|
61
|
-
config.chef.provisioning_path = "/tmp/vagrant-chef"
|
62
|
-
config.chef.log_level = :info
|
63
|
-
config.chef.json = {
|
64
|
-
:recipes => ["vagrant_main"]
|
65
|
-
}
|
66
|
-
end
|
67
|
-
|
68
|
-
if block_given?
|
69
|
-
Vagrant::Config.run do |config|
|
70
|
-
yield config
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
config = Vagrant::Config.execute!
|
75
|
-
|
76
|
-
environment.instance_variable_set(:@config, config)
|
77
|
-
|
78
|
-
# Setup the logger. We create it then reset it so that subsequent
|
79
|
-
# calls will recreate it for us.
|
80
|
-
environment.load_logger!
|
81
|
-
environment.logger.class.reset_singleton_logger!
|
82
|
-
environment.logger.stubs(:flush_progress)
|
83
|
-
environment.logger.stubs(:cl_reset).returns("")
|
84
|
-
|
85
|
-
environment
|
86
|
-
end
|
87
|
-
|
88
|
-
# Sets up the mocks for a VM
|
89
|
-
def mock_vm(env=nil)
|
90
|
-
env ||= mock_environment
|
91
|
-
vm = Vagrant::VM.new
|
92
|
-
vm.stubs(:env).returns(env)
|
93
|
-
vm.stubs(:ssh).returns(Vagrant::SSH.new(vm.env))
|
94
|
-
vm
|
95
|
-
end
|
96
|
-
|
97
|
-
# Sets up the mocks and instantiates an action for testing
|
98
|
-
def mock_action(action_klass, *args)
|
99
|
-
vm = mock("vboxvm")
|
100
|
-
mock_vm = mock("vm")
|
101
|
-
action = action_klass.new(mock_vm, *args)
|
102
|
-
stub_default_action_dependecies(action)
|
103
|
-
|
104
|
-
mock_vm.stubs(:name).returns("foo")
|
105
|
-
mock_vm.stubs(:vm).returns(vm)
|
106
|
-
mock_vm.stubs(:vm=)
|
107
|
-
mock_vm.stubs(:invoke_callback)
|
108
|
-
mock_vm.stubs(:invoke_around_callback).yields
|
109
|
-
mock_vm.stubs(:actions).returns([action])
|
110
|
-
mock_vm.stubs(:env).returns(mock_environment)
|
111
|
-
mock_vm.env.stubs(:logger).returns(quiet_logger("mock"))
|
112
|
-
|
113
|
-
mock_ssh = Vagrant::SSH.new(mock_vm.env)
|
114
|
-
mock_ssh.stubs(:execute)
|
115
|
-
|
116
|
-
mock_vm.stubs(:ssh).returns(mock_ssh)
|
117
|
-
|
118
|
-
vm.stubs(:env).returns(mock_vm.env)
|
119
|
-
|
120
|
-
[mock_vm, vm, action]
|
121
|
-
end
|
122
|
-
|
123
|
-
# Returns a resource logger which is safe for tests
|
124
|
-
def quiet_logger(resource, env=nil)
|
125
|
-
logger = Vagrant::ResourceLogger.new(resource, env)
|
126
|
-
logger.stubs(:flush_progress)
|
127
|
-
logger.stubs(:cl_reset).returns("")
|
128
|
-
logger
|
129
|
-
end
|
130
|
-
|
131
|
-
# Returns a linux system
|
132
|
-
def linux_system(vm)
|
133
|
-
Vagrant::Systems::Linux.new(vm)
|
134
|
-
end
|
135
|
-
|
136
|
-
def stub_default_action_dependecies(mock)
|
137
|
-
mock.stubs(:precedes).returns([])
|
138
|
-
mock.stubs(:follows).returns([])
|
139
|
-
end
|
140
|
-
|
141
|
-
# Sets up the mocks and stubs for a downloader
|
142
|
-
def mock_downloader(downloader_klass)
|
143
|
-
tempfile = mock("tempfile")
|
144
|
-
tempfile.stubs(:write)
|
145
|
-
|
146
|
-
[downloader_klass.new(mock_environment), tempfile]
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|