vagrant 0.7.8 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +39 -0
- data/Gemfile +1 -7
- data/Rakefile +0 -11
- data/bin/vagrant +4 -0
- data/config/default.rb +1 -2
- data/lib/vagrant.rb +7 -5
- data/lib/vagrant/action.rb +5 -1
- data/lib/vagrant/action/builtin.rb +4 -1
- data/lib/vagrant/action/general/package.rb +6 -2
- data/lib/vagrant/action/vm.rb +2 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +9 -22
- data/lib/vagrant/action/vm/clear_shared_folders.rb +9 -14
- data/lib/vagrant/action/vm/customize.rb +9 -4
- data/lib/vagrant/action/vm/forward_ports.rb +10 -11
- data/lib/vagrant/action/vm/match_mac_address.rb +8 -3
- data/lib/vagrant/action/vm/modify.rb +37 -0
- data/lib/vagrant/action/vm/network.rb +9 -2
- data/lib/vagrant/action/vm/provision.rb +10 -17
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +26 -0
- data/lib/vagrant/action/vm/share_folders.rb +16 -8
- data/lib/vagrant/action/warden.rb +8 -2
- data/lib/vagrant/command/ssh.rb +4 -4
- data/lib/vagrant/command/ssh_config.rb +4 -2
- data/lib/vagrant/config/ssh.rb +3 -0
- data/lib/vagrant/config/vm.rb +16 -12
- data/lib/vagrant/downloaders/http.rb +2 -0
- data/lib/vagrant/environment.rb +136 -12
- data/lib/vagrant/errors.rb +15 -0
- data/lib/vagrant/provisioners.rb +1 -1
- data/lib/vagrant/provisioners/base.rb +4 -0
- data/lib/vagrant/provisioners/chef.rb +13 -11
- data/lib/vagrant/provisioners/{chef_server.rb → chef_client.rb} +5 -5
- data/lib/vagrant/provisioners/chef_solo.rb +48 -89
- data/lib/vagrant/provisioners/shell.rb +47 -12
- data/lib/vagrant/ssh.rb +61 -27
- data/lib/vagrant/systems.rb +1 -0
- data/lib/vagrant/systems/base.rb +1 -1
- data/lib/vagrant/systems/linux.rb +7 -9
- data/lib/vagrant/systems/redhat.rb +12 -4
- data/lib/vagrant/systems/solaris.rb +9 -4
- data/lib/vagrant/systems/suse.rb +9 -0
- data/lib/vagrant/ui.rb +12 -5
- data/lib/vagrant/util.rb +2 -2
- data/lib/vagrant/util/counter.rb +22 -0
- data/lib/vagrant/util/platform.rb +1 -2
- data/lib/vagrant/util/safe_exec.rb +28 -0
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +2 -0
- data/templates/chef_solo_solo.erb +4 -4
- data/templates/commands/init/Vagrantfile.erb +4 -0
- data/templates/locales/en.yml +31 -8
- data/templates/ssh_config.erb +6 -0
- data/test/test_helper.rb +5 -3
- data/test/vagrant/action/builder_test.rb +4 -0
- data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +18 -38
- data/test/vagrant/action/vm/clear_shared_folders_test.rb +7 -16
- data/test/vagrant/action/vm/customize_test.rb +12 -5
- data/test/vagrant/action/vm/forward_ports_test.rb +12 -7
- data/test/vagrant/action/vm/match_mac_address_test.rb +5 -1
- data/test/vagrant/action/vm/modify_test.rb +38 -0
- data/test/vagrant/action/vm/provision_test.rb +13 -38
- data/test/vagrant/action/vm/provisioner_cleanup_test.rb +56 -0
- data/test/vagrant/action/vm/share_folders_test.rb +10 -5
- data/test/vagrant/action/warden_test.rb +13 -7
- data/test/vagrant/config/vm_test.rb +0 -22
- data/test/vagrant/downloaders/http_test.rb +2 -0
- data/test/vagrant/environment_test.rb +110 -20
- data/test/vagrant/provisioners/{chef_server_test.rb → chef_client_test.rb} +2 -2
- data/test/vagrant/provisioners/chef_solo_test.rb +16 -173
- data/test/vagrant/ssh_test.rb +8 -43
- data/test/vagrant/systems/linux_test.rb +9 -19
- data/test/vagrant/util/counter_test.rb +29 -0
- data/test/vagrant/util/platform_test.rb +2 -2
- data/vagrant.gemspec +1 -2
- metadata +114 -84
- data/lib/vagrant/util/plain_logger.rb +0 -25
- data/lib/vagrant/util/resource_logger.rb +0 -63
- data/test/vagrant/util/plain_logger_test.rb +0 -17
- data/test/vagrant/util/resource_logger_test.rb +0 -78
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,42 @@
|
|
1
|
+
## 0.8.1 (unreleased)
|
2
|
+
|
3
|
+
- Repush of 0.8.0 to fix a Ruby 1.9.2 RubyGems issue.
|
4
|
+
|
5
|
+
## 0.8.0 (July 20, 2011)
|
6
|
+
|
7
|
+
- VirtualBox 4.1 support _only_. Previous versions of VirtualBox
|
8
|
+
are supported by earlier versions of Vagrant.
|
9
|
+
- Performance optimizations in `virtualbox` gem. Huge speed gains.
|
10
|
+
- `:chef_server` provisioner is now `:chef_client`. [GH-359]
|
11
|
+
- SSH connection is now cached after first access internally,
|
12
|
+
speeding up `vagrant up`, `reload`, etc. quite a bit.
|
13
|
+
- Actions which modify the VM now occur much more quickly,
|
14
|
+
greatly speeding up `vagrant up`, `reload`, etc.
|
15
|
+
- SUSE host only networking support. [GH-369]
|
16
|
+
- Show nice error message for invalid HTTP responses for HTTP
|
17
|
+
downloader. [GH-403]
|
18
|
+
- New `:inline` option for shell provisioner to provide inline
|
19
|
+
scripts as a string. [GH-395]
|
20
|
+
- Host only network now properly works on multiple adapters. [GH-365]
|
21
|
+
- Can now specify owner/group for regular shared folders. [GH-350]
|
22
|
+
- `ssh_config` host name will use VM name if given. [GH-332]
|
23
|
+
- `ssh` `-e` flag changed to `-c` to align with `ssh` standard
|
24
|
+
behavior. [GH-323]
|
25
|
+
- Forward agent and forward X11 settings properly appear in
|
26
|
+
`ssh_config` output. [GH-105]
|
27
|
+
- Chef JSON can now be set with `chef.json =` instead of the old
|
28
|
+
`merge` technique. [GH-314]
|
29
|
+
- Provisioner configuration is no longer cleared when the box
|
30
|
+
needs to be downloaded during an `up`. [GH-308]
|
31
|
+
- Multiple Chef provisioners no longer overwrite cookbook folders. [GH-407]
|
32
|
+
- `package` won't delete previously existing file. [GH-408]
|
33
|
+
- Vagrantfile can be lowercase now. [GH-399]
|
34
|
+
- Only one copy of Vagrant may be running at any given time. [GH-364]
|
35
|
+
- Default home directory for Vagrant moved to `~/.vagrant.d` [GH-333]
|
36
|
+
- Specify a `forwarded_port_destination` for SSH configuration and
|
37
|
+
SSH port searching will fall back to that if it can't find any
|
38
|
+
other port. [GH-375]
|
39
|
+
|
1
40
|
## 0.7.8 (July 19, 2011)
|
2
41
|
|
3
42
|
- Make sure VirtualBox version check verifies that it is 4.0.x.
|
data/Gemfile
CHANGED
@@ -4,7 +4,7 @@ gem "vagrant", :path => '.'
|
|
4
4
|
|
5
5
|
# Use the following gems straight from git, since Vagrant dev
|
6
6
|
# typically coincides with it
|
7
|
-
gem "virtualbox", :git => "git://github.com/mitchellh/virtualbox.git"
|
7
|
+
gem "virtualbox", :git => "git://github.com/mitchellh/virtualbox.git"
|
8
8
|
|
9
9
|
# Gems required for testing only. To install run
|
10
10
|
# gem bundle test
|
@@ -12,10 +12,4 @@ group :test do
|
|
12
12
|
gem "rake"
|
13
13
|
gem "contest", ">= 0.1.2"
|
14
14
|
gem "mocha"
|
15
|
-
|
16
|
-
# For documentation
|
17
|
-
platforms :ruby do
|
18
|
-
gem "yard", "~> 0.6.1"
|
19
|
-
gem "bluecloth"
|
20
|
-
end
|
21
15
|
end
|
data/Rakefile
CHANGED
@@ -9,14 +9,3 @@ Rake::TestTask.new do |t|
|
|
9
9
|
t.libs << "test"
|
10
10
|
t.pattern = 'test/**/*_test.rb'
|
11
11
|
end
|
12
|
-
|
13
|
-
begin
|
14
|
-
require 'yard'
|
15
|
-
YARD::Rake::YardocTask.new do |t|
|
16
|
-
t.options = ['--main', 'README.md', '--markup', 'markdown']
|
17
|
-
t.options += ['--title', 'Vagrant Developer Documentation']
|
18
|
-
end
|
19
|
-
rescue LoadError
|
20
|
-
puts "Yard not available. Install it with: gem install yard"
|
21
|
-
puts "if you wish to be able to generate developer documentation."
|
22
|
-
end
|
data/bin/vagrant
CHANGED
@@ -5,6 +5,10 @@ require 'vagrant/cli'
|
|
5
5
|
env = Vagrant::Environment.new
|
6
6
|
|
7
7
|
begin
|
8
|
+
# Begin logging early here
|
9
|
+
env.logger.info("vagrant") { "`vagrant` invoked: #{ARGV.inspect}" }
|
10
|
+
|
11
|
+
# Disable color if the proper argument was passed
|
8
12
|
shell = ARGV.include?("--no-color") ? Thor::Shell::Basic.new : Thor::Base.shell.new
|
9
13
|
|
10
14
|
# Set the UI early in case any errors are raised, and load
|
data/config/default.rb
CHANGED
@@ -6,6 +6,7 @@ Vagrant::Config.run do |config|
|
|
6
6
|
config.ssh.username = "vagrant"
|
7
7
|
config.ssh.host = "127.0.0.1"
|
8
8
|
config.ssh.forwarded_port_key = "ssh"
|
9
|
+
config.ssh.forwarded_port_destination = 22
|
9
10
|
config.ssh.max_tries = 10
|
10
11
|
config.ssh.timeout = 30
|
11
12
|
config.ssh.private_key_path = File.expand_path("keys/vagrant", Vagrant.source_root)
|
@@ -18,8 +19,6 @@ Vagrant::Config.run do |config|
|
|
18
19
|
config.vm.base_mac = nil
|
19
20
|
config.vm.forward_port("ssh", 22, 2222, :auto => true)
|
20
21
|
config.vm.disk_image_format = 'VMDK'
|
21
|
-
config.vm.shared_folder_uid = nil
|
22
|
-
config.vm.shared_folder_gid = nil
|
23
22
|
config.vm.boot_mode = "vrdp"
|
24
23
|
config.vm.system = :linux
|
25
24
|
|
data/lib/vagrant.rb
CHANGED
@@ -3,6 +3,10 @@ require 'json'
|
|
3
3
|
require 'i18n'
|
4
4
|
require 'virtualbox'
|
5
5
|
|
6
|
+
# OpenSSL must be loaded here since when it is loaded via `autoload`
|
7
|
+
# there are issues with ciphers not being properly loaded.
|
8
|
+
require 'openssl'
|
9
|
+
|
6
10
|
module Vagrant
|
7
11
|
autoload :Action, 'vagrant/action'
|
8
12
|
autoload :Box, 'vagrant/box'
|
@@ -15,6 +19,7 @@ module Vagrant
|
|
15
19
|
autoload :Errors, 'vagrant/errors'
|
16
20
|
autoload :Hosts, 'vagrant/hosts'
|
17
21
|
autoload :Plugin, 'vagrant/plugin'
|
22
|
+
autoload :SSH, 'vagrant/ssh'
|
18
23
|
autoload :TestHelpers, 'vagrant/test_helpers'
|
19
24
|
autoload :UI, 'vagrant/ui'
|
20
25
|
autoload :Util, 'vagrant/util'
|
@@ -27,16 +32,13 @@ module Vagrant
|
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
30
|
-
# Default I18n to load the en locale
|
35
|
+
# # Default I18n to load the en locale
|
31
36
|
I18n.load_path << File.expand_path("templates/locales/en.yml", Vagrant.source_root)
|
32
37
|
|
33
|
-
# Load the things which must be loaded before anything else.
|
34
|
-
# I'm not sure why 'vagrant/ssh' must be loaded. But if I don't, I get
|
35
|
-
# a very scary "unsupported cipher" error from net-ssh for no apparent reason.
|
38
|
+
# Load the things which must be loaded before anything else.
|
36
39
|
require 'vagrant/command'
|
37
40
|
require 'vagrant/provisioners'
|
38
41
|
require 'vagrant/systems'
|
39
|
-
require 'vagrant/ssh'
|
40
42
|
require 'vagrant/version'
|
41
43
|
Vagrant::Action.builtin!
|
42
44
|
Vagrant::Plugin.load!
|
data/lib/vagrant/action.rb
CHANGED
@@ -128,7 +128,11 @@ module Vagrant
|
|
128
128
|
@@reported_interrupt = true
|
129
129
|
end
|
130
130
|
|
131
|
-
|
131
|
+
# We place a process lock around every action that is called
|
132
|
+
env.logger.info "Running action: #{callable_id}"
|
133
|
+
env.lock do
|
134
|
+
Busy.busy(int_callback) { callable.call(action_environment) }
|
135
|
+
end
|
132
136
|
end
|
133
137
|
end
|
134
138
|
end
|
@@ -14,7 +14,6 @@ module Vagrant
|
|
14
14
|
# environment.
|
15
15
|
register(:start, Builder.new do
|
16
16
|
use VM::CleanMachineFolder
|
17
|
-
use VM::Customize
|
18
17
|
use VM::ClearForwardedPorts
|
19
18
|
use VM::ForwardPorts
|
20
19
|
use VM::Provision
|
@@ -23,6 +22,8 @@ module Vagrant
|
|
23
22
|
use VM::ShareFolders
|
24
23
|
use VM::HostName
|
25
24
|
use VM::Network
|
25
|
+
use VM::Customize
|
26
|
+
use VM::Modify
|
26
27
|
use VM::Boot
|
27
28
|
end)
|
28
29
|
|
@@ -61,6 +62,7 @@ module Vagrant
|
|
61
62
|
# destroy - Halts, cleans up, and destroys an existing VM
|
62
63
|
register(:destroy, Builder.new do
|
63
64
|
use Action[:halt], :force => true
|
65
|
+
use VM::ProvisionerCleanup
|
64
66
|
use VM::ClearNFSExports
|
65
67
|
use VM::Destroy
|
66
68
|
use VM::CleanMachineFolder
|
@@ -72,6 +74,7 @@ module Vagrant
|
|
72
74
|
use Action[:halt]
|
73
75
|
use VM::ClearForwardedPorts
|
74
76
|
use VM::ClearSharedFolders
|
77
|
+
use VM::Modify
|
75
78
|
use VM::Export
|
76
79
|
use VM::PackageVagrantfile
|
77
80
|
use VM::Package
|
@@ -38,8 +38,12 @@ module Vagrant
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def recover(env)
|
41
|
-
#
|
42
|
-
|
41
|
+
# Don't delete the tar_path if the error is that the output already
|
42
|
+
# exists, since this will nuke the user's previous file.
|
43
|
+
if !env["vagrant.error"].is_a?(Errors::PackageOutputExists)
|
44
|
+
# Cleanup any packaged files if the packaging failed at some point.
|
45
|
+
File.delete(tar_path) if File.exist?(tar_path)
|
46
|
+
end
|
43
47
|
end
|
44
48
|
|
45
49
|
def files_to_copy
|
data/lib/vagrant/action/vm.rb
CHANGED
@@ -18,11 +18,13 @@ module Vagrant
|
|
18
18
|
autoload :HostName, 'vagrant/action/vm/host_name'
|
19
19
|
autoload :Import, 'vagrant/action/vm/import'
|
20
20
|
autoload :MatchMACAddress, 'vagrant/action/vm/match_mac_address'
|
21
|
+
autoload :Modify, 'vagrant/action/vm/modify'
|
21
22
|
autoload :Network, 'vagrant/action/vm/network'
|
22
23
|
autoload :NFS, 'vagrant/action/vm/nfs'
|
23
24
|
autoload :Package, 'vagrant/action/vm/package'
|
24
25
|
autoload :PackageVagrantfile, 'vagrant/action/vm/package_vagrantfile'
|
25
26
|
autoload :Provision, 'vagrant/action/vm/provision'
|
27
|
+
autoload :ProvisionerCleanup, 'vagrant/action/vm/provisioner_cleanup'
|
26
28
|
autoload :Resume, 'vagrant/action/vm/resume'
|
27
29
|
autoload :ShareFolders, 'vagrant/action/vm/share_folders'
|
28
30
|
autoload :Suspend, 'vagrant/action/vm/suspend'
|
@@ -1,37 +1,24 @@
|
|
1
|
-
require File.expand_path("../forward_ports_helpers", __FILE__)
|
2
|
-
|
3
1
|
module Vagrant
|
4
2
|
class Action
|
5
3
|
module VM
|
6
4
|
class ClearForwardedPorts
|
7
|
-
include ForwardPortsHelpers
|
8
|
-
|
9
5
|
def initialize(app, env)
|
10
6
|
@app = app
|
11
|
-
@env = env
|
12
7
|
end
|
13
8
|
|
14
9
|
def call(env)
|
15
|
-
|
16
|
-
|
17
|
-
@app.call(env)
|
18
|
-
end
|
10
|
+
proc = lambda do |vm|
|
11
|
+
env.ui.info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
|
19
12
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@env["vm"].reload!
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Deletes existing forwarded ports.
|
29
|
-
def clear_ports
|
30
|
-
@env["vm"].vm.network_adapters.each do |na|
|
31
|
-
na.nat_driver.forwarded_ports.dup.each do |fp|
|
32
|
-
fp.destroy
|
13
|
+
vm.network_adapters.each do |na|
|
14
|
+
na.nat_driver.forwarded_ports.dup.each do |fp|
|
15
|
+
fp.destroy
|
16
|
+
end
|
33
17
|
end
|
34
18
|
end
|
19
|
+
|
20
|
+
env["vm.modify"].call(proc)
|
21
|
+
@app.call(env)
|
35
22
|
end
|
36
23
|
end
|
37
24
|
end
|
@@ -8,23 +8,18 @@ module Vagrant
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(env)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@app.call(env)
|
15
|
-
end
|
11
|
+
proc = lambda do |vm|
|
12
|
+
if vm.shared_folders.length > 0
|
13
|
+
env.ui.info I18n.t("vagrant.actions.vm.clear_shared_folders.deleting")
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
folders = @env["vm"].vm.shared_folders.dup
|
22
|
-
folders.each do |shared_folder|
|
23
|
-
shared_folder.destroy
|
15
|
+
vm.shared_folders.dup.each do |shared_folder|
|
16
|
+
shared_folder.destroy
|
17
|
+
end
|
24
18
|
end
|
25
|
-
|
26
|
-
@env["vm"].reload!
|
27
19
|
end
|
20
|
+
|
21
|
+
env["vm.modify"].call(proc)
|
22
|
+
@app.call(env)
|
28
23
|
end
|
29
24
|
end
|
30
25
|
end
|
@@ -7,10 +7,15 @@ module Vagrant
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
-
if !env
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
if !env["config"].vm.proc_stack.empty?
|
11
|
+
# Create the proc which runs all of our procs
|
12
|
+
proc = lambda do |vm|
|
13
|
+
env.ui.info I18n.t("vagrant.actions.vm.customize.running")
|
14
|
+
env["config"].vm.run_procs!(vm)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Add it to modify sequence
|
18
|
+
env["vm.modify"].call(proc)
|
14
19
|
end
|
15
20
|
|
16
21
|
@app.call(env)
|
@@ -83,14 +83,16 @@ module Vagrant
|
|
83
83
|
def call(env)
|
84
84
|
@env = env
|
85
85
|
|
86
|
-
|
86
|
+
proc = lambda do |vm|
|
87
|
+
env.ui.info I18n.t("vagrant.actions.vm.forward_ports.forwarding")
|
88
|
+
forward_ports(vm)
|
89
|
+
end
|
87
90
|
|
91
|
+
env["vm.modify"].call(proc)
|
88
92
|
@app.call(env)
|
89
93
|
end
|
90
94
|
|
91
|
-
def forward_ports
|
92
|
-
@env.ui.info I18n.t("vagrant.actions.vm.forward_ports.forwarding")
|
93
|
-
|
95
|
+
def forward_ports(vm)
|
94
96
|
@env.env.config.vm.forwarded_ports.each do |name, options|
|
95
97
|
adapter = options[:adapter]
|
96
98
|
message_attributes = {
|
@@ -103,16 +105,13 @@ module Vagrant
|
|
103
105
|
# Assuming the only reason to establish port forwarding is because the VM is using Virtualbox NAT networking.
|
104
106
|
# Host-only or Bridged networking don't require port-forwarding and establishing forwarded ports on these
|
105
107
|
# attachment types has uncertain behaviour.
|
106
|
-
if
|
108
|
+
if vm.network_adapters[adapter].attachment_type == :nat
|
107
109
|
@env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.forwarding_entry", message_attributes))
|
108
|
-
forward_port(name, options)
|
110
|
+
forward_port(vm, name, options)
|
109
111
|
else
|
110
112
|
@env.ui.info(I18n.t("vagrant.actions.vm.forward_ports.non_nat", message_attributes))
|
111
113
|
end
|
112
114
|
end
|
113
|
-
|
114
|
-
@env["vm"].vm.save
|
115
|
-
@env["vm"].reload!
|
116
115
|
end
|
117
116
|
|
118
117
|
#--------------------------------------------------------------
|
@@ -120,13 +119,13 @@ module Vagrant
|
|
120
119
|
#--------------------------------------------------------------
|
121
120
|
|
122
121
|
# Forwards a port.
|
123
|
-
def forward_port(name, options)
|
122
|
+
def forward_port(vm, name, options)
|
124
123
|
port = VirtualBox::NATForwardedPort.new
|
125
124
|
port.name = name
|
126
125
|
port.guestport = options[:guestport]
|
127
126
|
port.hostport = options[:hostport]
|
128
127
|
port.protocol = options[:protocol] || :tcp
|
129
|
-
|
128
|
+
vm.network_adapters[options[:adapter]].nat_driver.forwarded_ports << port
|
130
129
|
end
|
131
130
|
end
|
132
131
|
end
|
@@ -9,9 +9,14 @@ module Vagrant
|
|
9
9
|
def call(env)
|
10
10
|
raise Errors::VMBaseMacNotSpecified if !env.env.config.vm.base_mac
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
# Create the proc which we want to use to modify the virtual machine
|
13
|
+
proc = lambda do |vm|
|
14
|
+
env.ui.info I18n.t("vagrant.actions.vm.match_mac.matching")
|
15
|
+
vm.network_adapters.first.mac_address = env["config"].vm.base_mac
|
16
|
+
end
|
17
|
+
|
18
|
+
# Add the proc to the modification chain
|
19
|
+
env["vm.modify"].call(proc)
|
15
20
|
|
16
21
|
@app.call(env)
|
17
22
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Vagrant
|
2
|
+
class Action
|
3
|
+
module VM
|
4
|
+
# This class allows other actions on the virtual machine object
|
5
|
+
# to be consolidated under a single write lock. This vastly speeds
|
6
|
+
# up modification of virtual machines. This should be used whereever
|
7
|
+
# possible when dealing with virtual machine modifications.
|
8
|
+
class Modify
|
9
|
+
include Util::StackedProcRunner
|
10
|
+
|
11
|
+
def initialize(app, env)
|
12
|
+
@app = app
|
13
|
+
|
14
|
+
# Initialize the proc_stack, which should already be empty
|
15
|
+
# but just making sure here.
|
16
|
+
proc_stack.clear
|
17
|
+
|
18
|
+
# Create the lambda in the environment which is to be called
|
19
|
+
# to add new procs to the modification sequence.
|
20
|
+
env["vm.modify"] = lambda do |*procs|
|
21
|
+
procs.each { |p| push_proc(&p) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def call(env)
|
26
|
+
# Run the procs we have saved up, save the machine, and reload
|
27
|
+
# to verify we get the new settings
|
28
|
+
run_procs!(env["vm"].vm)
|
29
|
+
env["vm"].vm.save
|
30
|
+
env["vm"].reload!
|
31
|
+
|
32
|
+
@app.call(env)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -25,8 +25,15 @@ module Vagrant
|
|
25
25
|
|
26
26
|
if enable_network?
|
27
27
|
@env.ui.info I18n.t("vagrant.actions.vm.network.enabling")
|
28
|
-
|
28
|
+
|
29
|
+
# Prepare for new networks...
|
30
|
+
options = @env.env.config.vm.network_options.compact
|
31
|
+
options.each do |network_options|
|
29
32
|
@env["vm"].system.prepare_host_only_network(network_options)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Then enable the networks...
|
36
|
+
options.each do |network_options|
|
30
37
|
@env["vm"].system.enable_host_only_network(network_options)
|
31
38
|
end
|
32
39
|
end
|
@@ -64,7 +71,7 @@ module Vagrant
|
|
64
71
|
adapter = @env["vm"].vm.network_adapters[network_options[:adapter]]
|
65
72
|
adapter.enabled = true
|
66
73
|
adapter.attachment_type = :host_only
|
67
|
-
adapter.
|
74
|
+
adapter.host_only_interface = network_name(network_options)
|
68
75
|
adapter.mac_address = network_options[:mac].gsub(':', '') if network_options[:mac]
|
69
76
|
adapter.save
|
70
77
|
end
|