vagrant 0.2.0 → 0.3.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.
- data/Gemfile +4 -4
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/bin/vagrant +5 -13
- data/config/default.rb +1 -0
- data/keys/README.md +8 -1
- data/keys/vagrant.ppk +26 -0
- data/lib/vagrant.rb +3 -3
- data/lib/vagrant/actions/base.rb +15 -4
- data/lib/vagrant/actions/box/add.rb +1 -1
- data/lib/vagrant/actions/box/download.rb +72 -66
- data/lib/vagrant/actions/box/unpackage.rb +1 -4
- data/lib/vagrant/actions/runner.rb +1 -1
- data/lib/vagrant/actions/vm/boot.rb +5 -7
- data/lib/vagrant/actions/vm/customize.rb +2 -2
- data/lib/vagrant/actions/vm/destroy.rb +2 -2
- data/lib/vagrant/actions/vm/down.rb +7 -0
- data/lib/vagrant/actions/vm/export.rb +10 -4
- data/lib/vagrant/actions/vm/forward_ports.rb +5 -15
- data/lib/vagrant/actions/vm/halt.rb +5 -3
- data/lib/vagrant/actions/vm/import.rb +10 -3
- data/lib/vagrant/actions/vm/move_hard_drive.rb +1 -3
- data/lib/vagrant/actions/vm/package.rb +33 -10
- data/lib/vagrant/actions/vm/provision.rb +4 -4
- data/lib/vagrant/actions/vm/reload.rb +1 -1
- data/lib/vagrant/actions/vm/resume.rb +1 -1
- data/lib/vagrant/actions/vm/shared_folders.rb +7 -7
- data/lib/vagrant/actions/vm/start.rb +3 -2
- data/lib/vagrant/actions/vm/suspend.rb +2 -2
- data/lib/vagrant/actions/vm/up.rb +7 -17
- data/lib/vagrant/active_list.rb +52 -45
- data/lib/vagrant/box.rb +18 -11
- data/lib/vagrant/busy.rb +7 -0
- data/lib/vagrant/command.rb +27 -0
- data/lib/vagrant/commands/base.rb +163 -0
- data/lib/vagrant/commands/box.rb +16 -0
- data/lib/vagrant/commands/box/add.rb +24 -0
- data/lib/vagrant/commands/box/list.rb +30 -0
- data/lib/vagrant/commands/box/remove.rb +31 -0
- data/lib/vagrant/commands/destroy.rb +23 -0
- data/lib/vagrant/commands/down.rb +16 -0
- data/lib/vagrant/commands/halt.rb +23 -0
- data/lib/vagrant/commands/init.rb +32 -0
- data/lib/vagrant/commands/package.rb +46 -0
- data/lib/vagrant/commands/reload.rb +22 -0
- data/lib/vagrant/commands/resume.rb +22 -0
- data/lib/vagrant/commands/ssh.rb +22 -0
- data/lib/vagrant/commands/ssh_config.rb +30 -0
- data/lib/vagrant/commands/status.rb +58 -0
- data/lib/vagrant/commands/suspend.rb +23 -0
- data/lib/vagrant/commands/up.rb +26 -0
- data/lib/vagrant/config.rb +21 -11
- data/lib/vagrant/downloaders/file.rb +5 -5
- data/lib/vagrant/downloaders/http.rb +10 -15
- data/lib/vagrant/environment.rb +259 -0
- data/lib/vagrant/provisioners/base.rb +7 -0
- data/lib/vagrant/provisioners/chef.rb +24 -9
- data/lib/vagrant/provisioners/chef_server.rb +23 -48
- data/lib/vagrant/provisioners/chef_solo.rb +48 -22
- data/lib/vagrant/ssh.rb +95 -46
- data/lib/vagrant/util.rb +2 -2
- data/lib/vagrant/util/errors.rb +36 -0
- data/lib/vagrant/util/platform.rb +12 -0
- data/lib/vagrant/util/progress_meter.rb +33 -0
- data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
- data/lib/vagrant/util/template_renderer.rb +83 -0
- data/lib/vagrant/vm.rb +1 -0
- data/templates/{Vagrantfile → Vagrantfile.erb} +2 -2
- data/templates/chef_server_client.erb +16 -0
- data/templates/chef_solo_solo.erb +4 -0
- data/templates/errors.yml +157 -0
- data/templates/package_Vagrantfile.erb +11 -0
- data/templates/ssh_config.erb +7 -0
- data/test/test_helper.rb +12 -15
- data/test/vagrant/actions/box/add_test.rb +1 -2
- data/test/vagrant/actions/box/destroy_test.rb +0 -1
- data/test/vagrant/actions/box/download_test.rb +40 -15
- data/test/vagrant/actions/box/unpackage_test.rb +2 -3
- data/test/vagrant/actions/collection_test.rb +8 -5
- data/test/vagrant/actions/runner_test.rb +8 -6
- data/test/vagrant/actions/vm/boot_test.rb +12 -11
- data/test/vagrant/actions/vm/customize_test.rb +2 -3
- data/test/vagrant/actions/vm/destroy_test.rb +2 -3
- data/test/vagrant/actions/vm/down_test.rb +16 -3
- data/test/vagrant/actions/vm/export_test.rb +4 -5
- data/test/vagrant/actions/vm/forward_ports_test.rb +6 -5
- data/test/vagrant/actions/vm/halt_test.rb +8 -2
- data/test/vagrant/actions/vm/import_test.rb +5 -5
- data/test/vagrant/actions/vm/move_hard_drive_test.rb +4 -6
- data/test/vagrant/actions/vm/package_test.rb +60 -22
- data/test/vagrant/actions/vm/provision_test.rb +7 -16
- data/test/vagrant/actions/vm/reload_test.rb +3 -2
- data/test/vagrant/actions/vm/resume_test.rb +0 -1
- data/test/vagrant/actions/vm/shared_folders_test.rb +17 -12
- data/test/vagrant/actions/vm/start_test.rb +10 -3
- data/test/vagrant/actions/vm/suspend_test.rb +1 -2
- data/test/vagrant/actions/vm/up_test.rb +19 -11
- data/test/vagrant/active_list_test.rb +148 -129
- data/test/vagrant/box_test.rb +26 -14
- data/test/vagrant/busy_test.rb +15 -6
- data/test/vagrant/command_test.rb +53 -0
- data/test/vagrant/commands/base_test.rb +118 -0
- data/test/vagrant/commands/box/add_test.rb +34 -0
- data/test/vagrant/commands/box/list_test.rb +32 -0
- data/test/vagrant/commands/box/remove_test.rb +41 -0
- data/test/vagrant/commands/destroy_test.rb +32 -0
- data/test/vagrant/commands/down_test.rb +17 -0
- data/test/vagrant/commands/halt_test.rb +28 -0
- data/test/vagrant/commands/init_test.rb +55 -0
- data/test/vagrant/commands/package_test.rb +84 -0
- data/test/vagrant/commands/reload_test.rb +28 -0
- data/test/vagrant/commands/resume_test.rb +33 -0
- data/test/vagrant/commands/ssh_config_test.rb +54 -0
- data/test/vagrant/commands/ssh_test.rb +32 -0
- data/test/vagrant/commands/status_test.rb +20 -0
- data/test/vagrant/commands/suspend_test.rb +33 -0
- data/test/vagrant/commands/up_test.rb +41 -0
- data/test/vagrant/config_test.rb +42 -17
- data/test/vagrant/downloaders/file_test.rb +7 -0
- data/test/vagrant/downloaders/http_test.rb +12 -0
- data/test/vagrant/environment_test.rb +595 -0
- data/test/vagrant/provisioners/base_test.rb +7 -1
- data/test/vagrant/provisioners/chef_server_test.rb +41 -51
- data/test/vagrant/provisioners/chef_solo_test.rb +93 -62
- data/test/vagrant/provisioners/chef_test.rb +61 -15
- data/test/vagrant/ssh_test.rb +166 -38
- data/test/vagrant/util/errors_test.rb +57 -0
- data/test/vagrant/util/progress_meter_test.rb +33 -0
- data/test/vagrant/{stacked_proc_runner_test.rb → util/stacked_proc_runner_test.rb} +3 -3
- data/test/vagrant/util/template_renderer_test.rb +138 -0
- data/test/vagrant/vm_test.rb +3 -2
- data/vagrant.gemspec +88 -33
- metadata +94 -51
- data/bin/vagrant-box +0 -34
- data/bin/vagrant-down +0 -27
- data/bin/vagrant-halt +0 -28
- data/bin/vagrant-init +0 -27
- data/bin/vagrant-package +0 -29
- data/bin/vagrant-reload +0 -29
- data/bin/vagrant-resume +0 -27
- data/bin/vagrant-ssh +0 -27
- data/bin/vagrant-status +0 -29
- data/bin/vagrant-suspend +0 -27
- data/bin/vagrant-up +0 -29
- data/lib/vagrant/commands.rb +0 -234
- data/lib/vagrant/env.rb +0 -189
- data/lib/vagrant/stacked_proc_runner.rb +0 -33
- data/test/vagrant/commands_test.rb +0 -269
- data/test/vagrant/env_test.rb +0 -418
@@ -0,0 +1,32 @@
|
|
1
|
+
module Vagrant
|
2
|
+
class Commands
|
3
|
+
class Init < Base
|
4
|
+
Base.subcommand "init", self
|
5
|
+
description "Initializes current folder for Vagrant usage"
|
6
|
+
|
7
|
+
def execute(args)
|
8
|
+
create_vagrantfile(args[0])
|
9
|
+
end
|
10
|
+
|
11
|
+
def options_spec(opts)
|
12
|
+
opts.banner = "Usage: vagrant init [name]"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Actually writes the initial Vagrantfile to the current working directory.
|
16
|
+
# The Vagrantfile will contain the base box configuration specified, or
|
17
|
+
# will just use "base" if none is specified.
|
18
|
+
#
|
19
|
+
# @param [String] default_box The default base box for this Vagrantfile
|
20
|
+
def create_vagrantfile(default_box=nil)
|
21
|
+
rootfile_path = File.join(Dir.pwd, Environment::ROOTFILE_NAME)
|
22
|
+
error_and_exit(:rootfile_already_exists) if File.exist?(rootfile_path)
|
23
|
+
|
24
|
+
# Copy over the rootfile template into this directory
|
25
|
+
default_box ||= "base"
|
26
|
+
File.open(rootfile_path, 'w+') do |f|
|
27
|
+
f.write(TemplateRenderer.render(Environment::ROOTFILE_NAME, :default_box => default_box))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Vagrant
|
2
|
+
class Commands
|
3
|
+
# Export and package the current vm
|
4
|
+
#
|
5
|
+
# This command requires that an instance be powered off
|
6
|
+
class Package < Base
|
7
|
+
Base.subcommand "package", self
|
8
|
+
description "Packages a vagrant environment for distribution"
|
9
|
+
|
10
|
+
def execute(args=[])
|
11
|
+
parse_options(args)
|
12
|
+
|
13
|
+
if !options[:base]
|
14
|
+
# Packaging a pre-existing environment
|
15
|
+
env.require_persisted_vm
|
16
|
+
else
|
17
|
+
# Packaging a base box; that is a VM not tied to a specific
|
18
|
+
# vagrant environment
|
19
|
+
vm = VM.find(options[:base])
|
20
|
+
vm.env = env if vm
|
21
|
+
env.vm = vm
|
22
|
+
|
23
|
+
error_and_exit(:vm_base_not_found, :name => options[:base]) unless vm
|
24
|
+
end
|
25
|
+
|
26
|
+
error_and_exit(:vm_power_off_to_package) unless env.vm.powered_off?
|
27
|
+
env.vm.package(args[0], options[:include])
|
28
|
+
end
|
29
|
+
|
30
|
+
def options_spec(opts)
|
31
|
+
opts.banner = "Usage: vagrant package [--base BASE] [--include FILES]"
|
32
|
+
|
33
|
+
# Defaults
|
34
|
+
options[:include] = []
|
35
|
+
|
36
|
+
opts.on("--base [BASE]", "Name or UUID of VM to create a base box from") do |v|
|
37
|
+
options[:base] = v
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on("--include x,y,z", Array, "List of files to include in the package") do |v|
|
41
|
+
options[:include] = v
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Vagrant
|
2
|
+
class Commands
|
3
|
+
# Reload the environment. This is almost equivalent to the {up} command
|
4
|
+
# except that it doesn't import the VM and do the initialize bootstrapping
|
5
|
+
# of the instance. Instead, it forces a shutdown (if its running) of the
|
6
|
+
# VM, updates the metadata (shared folders, forwarded ports), restarts
|
7
|
+
# the VM, and then reruns the provisioning if enabled.
|
8
|
+
class Reload < Base
|
9
|
+
Base.subcommand "reload", self
|
10
|
+
description "Reload the vagrant environment"
|
11
|
+
|
12
|
+
def execute(args=[])
|
13
|
+
env.require_persisted_vm
|
14
|
+
env.vm.execute!(Actions::VM::Reload)
|
15
|
+
end
|
16
|
+
|
17
|
+
def options_spec(opts)
|
18
|
+
opts.banner = "Usage: vagrant reload"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Vagrant
|
2
|
+
class Commands
|
3
|
+
# Resume a running vagrant instance. This resumes an already suspended
|
4
|
+
# instance (from {suspend}).
|
5
|
+
#
|
6
|
+
# This command requires that an instance already be brought up with
|
7
|
+
# `vagrant up`.
|
8
|
+
class Resume < Base
|
9
|
+
Base.subcommand "resume", self
|
10
|
+
description "Resumes a suspend vagrant environment"
|
11
|
+
|
12
|
+
def execute(args=[])
|
13
|
+
env.require_persisted_vm
|
14
|
+
env.vm.resume
|
15
|
+
end
|
16
|
+
|
17
|
+
def options_spec(opts)
|
18
|
+
opts.banner = "Usage: vagrant resume"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Vagrant
|
2
|
+
class Commands
|
3
|
+
# Reload the environment. This is almost equivalent to the {up} command
|
4
|
+
# except that it doesn't import the VM and do the initialize bootstrapping
|
5
|
+
# of the instance. Instead, it forces a shutdown (if its running) of the
|
6
|
+
# VM, updates the metadata (shared folders, forwarded ports), restarts
|
7
|
+
# the VM, and then reruns the provisioning if enabled.
|
8
|
+
class SSH < Base
|
9
|
+
Base.subcommand "ssh", self
|
10
|
+
description "SSH into the currently running environment"
|
11
|
+
|
12
|
+
def execute(args=[])
|
13
|
+
env.require_persisted_vm
|
14
|
+
env.ssh.connect
|
15
|
+
end
|
16
|
+
|
17
|
+
def options_spec(opts)
|
18
|
+
opts.banner = "Usage: vagrant ssh"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Vagrant
|
2
|
+
class Commands
|
3
|
+
# Outputs a valid entry for .ssh/config which can be used to connect
|
4
|
+
# to this environment.
|
5
|
+
class SSHConfig < Base
|
6
|
+
Base.subcommand "ssh-config", self
|
7
|
+
description "outputs .ssh/config valid syntax for connecting to this environment via ssh"
|
8
|
+
|
9
|
+
def execute(args=[])
|
10
|
+
env.require_root_path
|
11
|
+
|
12
|
+
parse_options(args)
|
13
|
+
puts TemplateRenderer.render("ssh_config", {
|
14
|
+
:host_key => options[:host] || "vagrant",
|
15
|
+
:ssh_user => env.config.ssh.username,
|
16
|
+
:ssh_port => env.ssh.port,
|
17
|
+
:private_key_path => env.config.ssh.private_key_path
|
18
|
+
})
|
19
|
+
end
|
20
|
+
|
21
|
+
def options_spec(opts)
|
22
|
+
opts.banner = "Usage: vagrant ssh-config [--host NAME]"
|
23
|
+
|
24
|
+
opts.on("-h", "--host [HOST]", "Host name for the SSH config") do |h|
|
25
|
+
options[:host] = h
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Vagrant
|
2
|
+
class Commands
|
3
|
+
# Outputs the status of the current environment. This command outputs
|
4
|
+
# useful information such as whether or not the environment is created
|
5
|
+
# and if its running, suspended, etc.
|
6
|
+
class Status < Base
|
7
|
+
Base.subcommand "status", self
|
8
|
+
description "Shows the status of the current environment."
|
9
|
+
|
10
|
+
def execute(args=[])
|
11
|
+
wrap_output do
|
12
|
+
if !env.root_path
|
13
|
+
puts <<-msg
|
14
|
+
No vagrant environment detected. Run `vagrant init` to setup a Vagrantfile
|
15
|
+
in the current directory to get started with Vagrant.
|
16
|
+
msg
|
17
|
+
elsif !env.vm
|
18
|
+
puts <<-msg
|
19
|
+
The environment has not yet been created. Run `vagrant up` to create the
|
20
|
+
environment.
|
21
|
+
msg
|
22
|
+
else
|
23
|
+
additional_msg = ""
|
24
|
+
if env.vm.vm.running?
|
25
|
+
additional_msg = <<-msg
|
26
|
+
To stop this VM, you can run `vagrant halt` to shut it down forcefully,
|
27
|
+
or you can run `vagrant suspend` to simply suspend the virtual machine.
|
28
|
+
In either case, to restart it again, simply run a `vagrant up`.
|
29
|
+
msg
|
30
|
+
elsif env.vm.vm.saved?
|
31
|
+
additional_msg = <<-msg
|
32
|
+
To resume this VM, simply run `vagrant up`.
|
33
|
+
msg
|
34
|
+
elsif env.vm.vm.powered_off?
|
35
|
+
additional_msg = <<-msg
|
36
|
+
To restart this VM, simply run `vagrant up`.
|
37
|
+
msg
|
38
|
+
end
|
39
|
+
|
40
|
+
if !additional_msg.empty?
|
41
|
+
additional_msg.chomp!
|
42
|
+
additional_msg = "\n\n#{additional_msg}"
|
43
|
+
end
|
44
|
+
|
45
|
+
puts <<-msg
|
46
|
+
The environment has been created. The status of the current environment's
|
47
|
+
virtual machine is: "#{env.vm.vm.state}."#{additional_msg}
|
48
|
+
msg
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def options_spec(opts)
|
54
|
+
opts.banner = "Usage: vagrant status"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Vagrant
|
2
|
+
class Commands
|
3
|
+
# Suspend a running vagrant instance. This suspends the instance, saving
|
4
|
+
# the state of the VM and "pausing" it. The instance can be resumed
|
5
|
+
# again with {resume}.
|
6
|
+
#
|
7
|
+
# This command requires that an instance already be brought up with
|
8
|
+
# `vagrant up`.
|
9
|
+
class Suspend < Base
|
10
|
+
Base.subcommand "suspend", self
|
11
|
+
description "Suspends the currently running vagrant environment"
|
12
|
+
|
13
|
+
def execute(args=[])
|
14
|
+
env.require_persisted_vm
|
15
|
+
env.vm.suspend
|
16
|
+
end
|
17
|
+
|
18
|
+
def options_spec(opts)
|
19
|
+
opts.banner = "Usage: vagrant suspend"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Vagrant
|
2
|
+
class Commands
|
3
|
+
# Bring up a vagrant instance. This handles everything from importing
|
4
|
+
# the base VM, setting up shared folders, forwarded ports, etc to
|
5
|
+
# provisioning the instance with chef. {up} also starts the instance,
|
6
|
+
# running it in the background.
|
7
|
+
class Up < Base
|
8
|
+
Base.subcommand "up", self
|
9
|
+
description "Creates the vagrant environment"
|
10
|
+
|
11
|
+
def execute(args=[])
|
12
|
+
if env.vm
|
13
|
+
logger.info "VM already created. Starting VM if its not already running..."
|
14
|
+
env.vm.start
|
15
|
+
else
|
16
|
+
env.require_box
|
17
|
+
env.create_vm.execute!(Actions::VM::Up)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def options_spec(opts)
|
22
|
+
opts.banner = "Usage: vagrant up"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/vagrant/config.rb
CHANGED
@@ -4,22 +4,25 @@ module Vagrant
|
|
4
4
|
end
|
5
5
|
|
6
6
|
class Config
|
7
|
-
extend StackedProcRunner
|
7
|
+
extend Util::StackedProcRunner
|
8
8
|
|
9
9
|
@@config = nil
|
10
10
|
|
11
11
|
class << self
|
12
|
-
def reset!
|
12
|
+
def reset!(env=nil)
|
13
13
|
@@config = nil
|
14
14
|
proc_stack.clear
|
15
|
+
|
16
|
+
# Reset the configuration to the specified environment
|
17
|
+
config(env)
|
15
18
|
end
|
16
19
|
|
17
20
|
def configures(key, klass)
|
18
21
|
config.class.configures(key, klass)
|
19
22
|
end
|
20
23
|
|
21
|
-
def config
|
22
|
-
@@config ||= Config::Top.new
|
24
|
+
def config(env=nil)
|
25
|
+
@@config ||= Config::Top.new(env)
|
23
26
|
end
|
24
27
|
|
25
28
|
def run(&block)
|
@@ -29,12 +32,15 @@ module Vagrant
|
|
29
32
|
def execute!
|
30
33
|
run_procs!(config)
|
31
34
|
config.loaded!
|
35
|
+
config
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
36
40
|
class Config
|
37
41
|
class Base
|
42
|
+
attr_accessor :env
|
43
|
+
|
38
44
|
def [](key)
|
39
45
|
send(key)
|
40
46
|
end
|
@@ -45,7 +51,7 @@ module Vagrant
|
|
45
51
|
|
46
52
|
def instance_variables_hash
|
47
53
|
instance_variables.inject({}) do |acc, iv|
|
48
|
-
acc[iv.to_s[1..-1].to_sym] = instance_variable_get(iv)
|
54
|
+
acc[iv.to_s[1..-1].to_sym] = instance_variable_get(iv) unless iv.to_sym == :@env
|
49
55
|
acc
|
50
56
|
end
|
51
57
|
end
|
@@ -61,16 +67,17 @@ module Vagrant
|
|
61
67
|
attr_accessor :private_key_path
|
62
68
|
|
63
69
|
def private_key_path
|
64
|
-
File.expand_path(@private_key_path,
|
70
|
+
File.expand_path(@private_key_path, env.root_path)
|
65
71
|
end
|
66
72
|
end
|
67
73
|
|
68
74
|
class VMConfig < Base
|
69
|
-
include StackedProcRunner
|
75
|
+
include Util::StackedProcRunner
|
70
76
|
|
71
77
|
attr_accessor :box
|
72
78
|
attr_accessor :box_ovf
|
73
79
|
attr_accessor :base_mac
|
80
|
+
attr_accessor :boot_mode
|
74
81
|
attr_accessor :project_directory
|
75
82
|
attr_reader :forwarded_ports
|
76
83
|
attr_reader :shared_folders
|
@@ -107,11 +114,11 @@ module Vagrant
|
|
107
114
|
end
|
108
115
|
|
109
116
|
def shared_folder_uid
|
110
|
-
@shared_folder_uid ||
|
117
|
+
@shared_folder_uid || env.config.ssh.username
|
111
118
|
end
|
112
119
|
|
113
120
|
def shared_folder_gid
|
114
|
-
@shared_folder_gid ||
|
121
|
+
@shared_folder_gid || env.config.ssh.username
|
115
122
|
end
|
116
123
|
|
117
124
|
def customize(&block)
|
@@ -154,12 +161,15 @@ module Vagrant
|
|
154
161
|
configures :vm, VMConfig
|
155
162
|
configures :vagrant, VagrantConfig
|
156
163
|
|
157
|
-
def initialize
|
164
|
+
def initialize(env=nil)
|
158
165
|
self.class.configures_list.each do |key, klass|
|
159
|
-
|
166
|
+
config = klass.new
|
167
|
+
config.env = env
|
168
|
+
instance_variable_set("@#{key}".to_sym, config)
|
160
169
|
end
|
161
170
|
|
162
171
|
@loaded = false
|
172
|
+
@env = env
|
163
173
|
end
|
164
174
|
|
165
175
|
def loaded?
|
@@ -3,13 +3,13 @@ module Vagrant
|
|
3
3
|
# "Downloads" a file to a temporary file. Basically, this downloader
|
4
4
|
# simply does a file copy.
|
5
5
|
class File < Base
|
6
|
+
def self.match?(uri)
|
7
|
+
::File.exists?(uri)
|
8
|
+
end
|
9
|
+
|
6
10
|
def prepare(source_url)
|
7
11
|
if !::File.file?(source_url)
|
8
|
-
raise Actions::ActionException.new(
|
9
|
-
The given box does not exist on the file system:
|
10
|
-
|
11
|
-
#{source_url}
|
12
|
-
msg
|
12
|
+
raise Actions::ActionException.new(:downloader_file_doesnt_exist, :source_url => source_url)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -3,8 +3,14 @@ module Vagrant
|
|
3
3
|
# Downloads a file from an HTTP URL to a temporary file. This
|
4
4
|
# downloader reports its progress to stdout while downloading.
|
5
5
|
class HTTP < Base
|
6
|
-
|
7
|
-
|
6
|
+
include Util::ProgressMeter
|
7
|
+
|
8
|
+
def self.match?(uri)
|
9
|
+
# URI.parse barfs on '<drive letter>:\\files \on\ windows'
|
10
|
+
# TODO temprorary
|
11
|
+
extracted = URI.extract(uri).first
|
12
|
+
extracted && extracted.include?(uri)
|
13
|
+
end
|
8
14
|
|
9
15
|
def download!(source_url, destination_file)
|
10
16
|
Net::HTTP.get_response(URI.parse(source_url)) do |response|
|
@@ -20,7 +26,7 @@ module Vagrant
|
|
20
26
|
# Progress reporting is limited to every 25 segments just so
|
21
27
|
# we're not constantly updating
|
22
28
|
if segment_count % 25 == 0
|
23
|
-
|
29
|
+
update_progress(progress, total)
|
24
30
|
segment_count = 0
|
25
31
|
end
|
26
32
|
|
@@ -31,17 +37,6 @@ module Vagrant
|
|
31
37
|
|
32
38
|
complete_progress
|
33
39
|
end
|
34
|
-
|
35
|
-
def report_progress(progress, total)
|
36
|
-
percent = (progress.to_f / total.to_f) * 100
|
37
|
-
print "#{CL_RESET}Download Progress: #{percent.to_i}% (#{progress} / #{total})"
|
38
|
-
$stdout.flush
|
39
|
-
end
|
40
|
-
|
41
|
-
def complete_progress
|
42
|
-
# Just clear the line back out
|
43
|
-
print "#{CL_RESET}"
|
44
|
-
end
|
45
40
|
end
|
46
41
|
end
|
47
|
-
end
|
42
|
+
end
|