vagrant 0.4.1 → 0.4.2
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/Rakefile +1 -1
- data/VERSION +1 -1
- data/config/default.rb +10 -4
- data/lib/vagrant/actions/vm/forward_ports.rb +10 -32
- data/lib/vagrant/actions/vm/network.rb +29 -0
- data/lib/vagrant/actions/vm/package.rb +2 -0
- data/lib/vagrant/actions/vm/shared_folders.rb +50 -13
- data/lib/vagrant/config.rb +11 -23
- data/lib/vagrant/environment.rb +1 -1
- data/lib/vagrant/ssh.rb +6 -12
- data/lib/vagrant/systems/base.rb +7 -0
- data/lib/vagrant/systems/linux.rb +21 -26
- data/lib/vagrant/util/template_renderer.rb +1 -1
- data/templates/strings.yml +17 -1
- data/templates/unison/crontab_entry.erb +1 -0
- data/templates/unison/script.erb +71 -0
- data/test/test_helper.rb +5 -4
- data/test/vagrant/actions/vm/forward_ports_test.rb +39 -85
- data/test/vagrant/actions/vm/network_test.rb +67 -13
- data/test/vagrant/actions/vm/package_test.rb +5 -0
- data/test/vagrant/actions/vm/shared_folders_test.rb +113 -44
- data/test/vagrant/config_test.rb +0 -33
- data/test/vagrant/environment_test.rb +4 -4
- data/test/vagrant/ssh_test.rb +2 -13
- data/test/vagrant/systems/linux_test.rb +38 -33
- data/test/vagrant/util/template_renderer_test.rb +6 -0
- data/vagrant.gemspec +53 -53
- metadata +69 -52
- data/templates/crontab_entry.erb +0 -1
- data/templates/sync.erb +0 -14
data/templates/strings.yml
CHANGED
@@ -70,6 +70,12 @@
|
|
70
70
|
A box with the name '<%= box_name %>' already exists, please use another name or use `vagrant box remove <%= box_name %>`
|
71
71
|
:box_download_unknown_type: |-
|
72
72
|
Unknown URI type for box download.
|
73
|
+
:box_file_exists: |-
|
74
|
+
The specified output file for packaging already exists. Please move
|
75
|
+
the file or modify the output filename parameter then try to package
|
76
|
+
again.
|
77
|
+
|
78
|
+
Specified output file: <%= output_file %>
|
73
79
|
:box_remove_doesnt_exist: |-
|
74
80
|
The box you're attempting to remove does not exist!
|
75
81
|
:box_specified_doesnt_exist: |-
|
@@ -136,6 +142,11 @@
|
|
136
142
|
If the name specification is removed, Vagrant will create a new
|
137
143
|
host only network for you. Alternatively, please create the
|
138
144
|
specified network manually.
|
145
|
+
:network_collides: |-
|
146
|
+
The specified host network collides with a non-hostonly network!
|
147
|
+
This will cause your specified IP to be inaccessible. Please change
|
148
|
+
the IP or name of your host only network to not match that of
|
149
|
+
a bridged or non-hostonly network.
|
139
150
|
:package_include_file_doesnt_exist: |-
|
140
151
|
File specified to include: '<%= filename %>' does not exist!
|
141
152
|
:package_multivm: |-
|
@@ -212,6 +223,11 @@
|
|
212
223
|
:system_unspecified: |-
|
213
224
|
A VM system type must be specified! This is done via the `config.vm.system`
|
214
225
|
configuration value. Please read the documentation online for more information.
|
226
|
+
:unison_not_found: |-
|
227
|
+
The `unison` binary was not found on the guest machine. This is required
|
228
|
+
for folder syncing via unison. Please install unison on your system to
|
229
|
+
use folder syncing. You may also disable folder syncing, install unison,
|
230
|
+
re-enable syncing, then call a `vagrant reload` to enable syncing.
|
215
231
|
:unknown_vm: |-
|
216
232
|
The specified VM could not be found: <%= vm %>
|
217
233
|
:virtualbox_import_failure: |-
|
@@ -219,7 +235,7 @@
|
|
219
235
|
manually for more verbose error output.
|
220
236
|
:virtualbox_invalid_version: |-
|
221
237
|
Vagrant has detected that you have VirtualBox version <%= version %> installed!
|
222
|
-
Vagrant requires that you use at least VirtualBox version 3.
|
238
|
+
Vagrant requires that you use at least VirtualBox version 3.2. Please install
|
223
239
|
a more recent version of VirtualBox to continue.
|
224
240
|
:virtualbox_not_detected: |-
|
225
241
|
Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed.
|
@@ -0,0 +1 @@
|
|
1
|
+
* * * * * <%= script %> '<%= from %>' '<%= to %>' '<%= options %>' >> <%= log_file %> 2>&1
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#------------------------------------------------------------
|
3
|
+
# Author : John Bender and Mitchell Hashimoto
|
4
|
+
# Description : Runs the `unison` folder synchronization
|
5
|
+
# utility for shared folders.
|
6
|
+
#------------------------------------------------------------
|
7
|
+
|
8
|
+
#------------------------------------------------------------
|
9
|
+
# Argument verification
|
10
|
+
#------------------------------------------------------------
|
11
|
+
if [ $# -ne 3 ]; then
|
12
|
+
echo "Usage: `basename $0` from_folder to_folder options"
|
13
|
+
exit 1
|
14
|
+
fi
|
15
|
+
|
16
|
+
# Sanitization function which turns any non-alphanumeric char
|
17
|
+
# into a dash '-' and returns it by echoing the result.
|
18
|
+
function sanitize() {
|
19
|
+
local DATA=$1
|
20
|
+
DATA=${DATA//[^a-zA-Z0-9_-]/-}
|
21
|
+
echo ${DATA}
|
22
|
+
}
|
23
|
+
|
24
|
+
#------------------------------------------------------------
|
25
|
+
# "Configuration"
|
26
|
+
#------------------------------------------------------------
|
27
|
+
# TODO Change lockfile to depend on the from/to folder to
|
28
|
+
# allow multiple syncs of diff folders to happen at once.
|
29
|
+
FROM=$1
|
30
|
+
TO=$2
|
31
|
+
OPTIONS=$3
|
32
|
+
LOCK_FILE=`basename $0`-$(sanitize ${TO}).lck
|
33
|
+
|
34
|
+
#------------------------------------------------------------
|
35
|
+
# Am I Running?
|
36
|
+
#------------------------------------------------------------
|
37
|
+
if [ -f "${LOCK_FILE}" ]; then
|
38
|
+
# The file exists, verify its running and if so exit.
|
39
|
+
OUR_PID=`head -n 1 "${LOCK_FILE}"`
|
40
|
+
TEST_RUNNING=`ps -p ${OUR_PID} | grep ${OUR_PID}`
|
41
|
+
|
42
|
+
if [ "${TEST_RUNNING}" ]; then
|
43
|
+
# The process is running, echo and exit.
|
44
|
+
echo "Unison sync already running. [PID: ${OUR_PID}]"
|
45
|
+
exit 0
|
46
|
+
fi
|
47
|
+
fi
|
48
|
+
|
49
|
+
# We're not running if we reached this point, so lock
|
50
|
+
# it up.
|
51
|
+
echo $$ > "${LOCK_FILE}"
|
52
|
+
|
53
|
+
#------------------------------------------------------------
|
54
|
+
# The Meat
|
55
|
+
#------------------------------------------------------------
|
56
|
+
echo "Beginning Sync:"
|
57
|
+
echo " -- From: ${FROM}"
|
58
|
+
echo " -- To: ${TO}"
|
59
|
+
echo " -- Options: ${OPTIONS}"
|
60
|
+
while [ 1 ]; do
|
61
|
+
echo "Syncing: $(date)"
|
62
|
+
# TODO check result and output log data... somewhere!
|
63
|
+
sudo unison ${FROM} ${TO} ${OPTIONS}
|
64
|
+
sleep 1
|
65
|
+
done
|
66
|
+
|
67
|
+
#------------------------------------------------------------
|
68
|
+
# Cleanup and Exit
|
69
|
+
#------------------------------------------------------------
|
70
|
+
rm -f "${LOCK_FILE}"
|
71
|
+
exit 0
|
data/test/test_helper.rb
CHANGED
@@ -23,6 +23,7 @@ class Test::Unit::TestCase
|
|
23
23
|
Vagrant::Config.reset!(environment)
|
24
24
|
|
25
25
|
Vagrant::Config.run do |config|
|
26
|
+
config.vagrant.home = '~/.home'
|
26
27
|
config.vagrant.dotfile_name = ".vagrant"
|
27
28
|
config.vagrant.log_output = nil
|
28
29
|
|
@@ -42,13 +43,15 @@ class Test::Unit::TestCase
|
|
42
43
|
config.vm.shared_folder_uid = nil
|
43
44
|
config.vm.shared_folder_gid = nil
|
44
45
|
config.vm.system = :linux
|
45
|
-
config.vm.sync_script = "/foo"
|
46
|
-
config.vm.sync_crontab_entry_file = "/tmp/foo"
|
47
46
|
config.vm.share_folder("v-root", "/vagrant", ".")
|
48
47
|
|
49
48
|
config.package.name = 'vagrant'
|
50
49
|
config.package.extension = '.box'
|
51
50
|
|
51
|
+
# Unison
|
52
|
+
config.unison.folder_suffix = ".sync"
|
53
|
+
config.unison.log_file = "foo-%s"
|
54
|
+
|
52
55
|
# Chef
|
53
56
|
config.chef.chef_server_url = "http://localhost:4000"
|
54
57
|
config.chef.validation_key_path = "validation.pem"
|
@@ -60,8 +63,6 @@ class Test::Unit::TestCase
|
|
60
63
|
config.chef.json = {
|
61
64
|
:recipes => ["vagrant_main"]
|
62
65
|
}
|
63
|
-
|
64
|
-
config.vagrant.home = '~/.home'
|
65
66
|
end
|
66
67
|
|
67
68
|
if block_given?
|
@@ -103,9 +103,10 @@ class ForwardPortsActionTest < Test::Unit::TestCase
|
|
103
103
|
forwarded_ports = mock("forwarded_ports")
|
104
104
|
network_adapter = mock("network_adapter")
|
105
105
|
|
106
|
-
@vm.
|
106
|
+
@vm.stubs(:network_adapters).returns([network_adapter])
|
107
107
|
network_adapter.expects(:attachment_type).returns(:nat)
|
108
108
|
|
109
|
+
@action.expects(:forward_port).once
|
109
110
|
@vm.expects(:save).once
|
110
111
|
@runner.expects(:reload!).once
|
111
112
|
@action.forward_ports
|
@@ -182,13 +183,6 @@ class ForwardPortsActionTest < Test::Unit::TestCase
|
|
182
183
|
@action.used_ports
|
183
184
|
end
|
184
185
|
|
185
|
-
should "return the forwarded ports for VB 3.1.x" do
|
186
|
-
VirtualBox.stubs(:version).returns("3.1.4")
|
187
|
-
fps = [mock_fp(2222), mock_fp(80)]
|
188
|
-
@vms << mock_vm(:forwarded_ports => fps)
|
189
|
-
assert_equal %W[2222 80], @action.used_ports
|
190
|
-
end
|
191
|
-
|
192
186
|
should "return the forwarded ports for VB 3.2.x" do
|
193
187
|
VirtualBox.stubs(:version).returns("3.2.4")
|
194
188
|
fps = [mock_fp(2222), mock_fp(80)]
|
@@ -208,92 +202,52 @@ class ForwardPortsActionTest < Test::Unit::TestCase
|
|
208
202
|
fp
|
209
203
|
end
|
210
204
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
@vm.stubs(:forwarded_ports).returns(@fps)
|
216
|
-
end
|
217
|
-
|
218
|
-
should "destroy each forwarded port" do
|
219
|
-
@fps << mock_fp
|
220
|
-
@fps << mock_fp
|
221
|
-
@action.clear_ports
|
222
|
-
end
|
205
|
+
setup do
|
206
|
+
VirtualBox.stubs(:version).returns("3.2.8")
|
207
|
+
@adapters = []
|
208
|
+
@vm.stubs(:network_adapters).returns(@adapters)
|
223
209
|
end
|
224
210
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
def mock_adapter
|
233
|
-
na = mock("adapter")
|
234
|
-
engine = mock("engine")
|
235
|
-
engine.stubs(:forwarded_ports).returns([mock_fp])
|
236
|
-
na.stubs(:nat_driver).returns(engine)
|
237
|
-
na
|
238
|
-
end
|
211
|
+
def mock_adapter
|
212
|
+
na = mock("adapter")
|
213
|
+
engine = mock("engine")
|
214
|
+
engine.stubs(:forwarded_ports).returns([mock_fp])
|
215
|
+
na.stubs(:nat_driver).returns(engine)
|
216
|
+
na
|
217
|
+
end
|
239
218
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
end
|
219
|
+
should "destroy each forwarded port" do
|
220
|
+
@adapters << mock_adapter
|
221
|
+
@adapters << mock_adapter
|
222
|
+
@action.clear_ports
|
245
223
|
end
|
246
224
|
end
|
247
225
|
|
248
|
-
context "forwarding ports" do
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
end
|
226
|
+
context "forwarding ports implementation" do
|
227
|
+
setup do
|
228
|
+
VirtualBox.stubs(:version).returns("3.2.8")
|
229
|
+
end
|
230
|
+
|
231
|
+
should "forward ports" do
|
232
|
+
name, opts = @runner.env.config.vm.forwarded_ports.first
|
233
|
+
|
234
|
+
adapters = []
|
235
|
+
adapter = mock("adapter")
|
236
|
+
engine = mock("engine")
|
237
|
+
fps = mock("forwarded ports")
|
238
|
+
adapter.stubs(:nat_driver).returns(engine)
|
239
|
+
engine.stubs(:forwarded_ports).returns(fps)
|
240
|
+
fps.expects(:<<).with do |port|
|
241
|
+
assert_equal name, port.name
|
242
|
+
assert_equal opts[:hostport], port.hostport
|
243
|
+
assert_equal opts[:guestport], port.guestport
|
244
|
+
true
|
268
245
|
end
|
269
|
-
end
|
270
246
|
|
271
|
-
|
272
|
-
|
273
|
-
VirtualBox.stubs(:version).returns("3.2.8")
|
274
|
-
end
|
247
|
+
adapters[opts[:adapter]] = adapter
|
248
|
+
@vm.stubs(:network_adapters).returns(adapters)
|
275
249
|
|
276
|
-
|
277
|
-
name, opts = @runner.env.config.vm.forwarded_ports.first
|
278
|
-
|
279
|
-
adapters = []
|
280
|
-
adapter = mock("adapter")
|
281
|
-
engine = mock("engine")
|
282
|
-
fps = mock("forwarded ports")
|
283
|
-
adapter.stubs(:nat_driver).returns(engine)
|
284
|
-
engine.stubs(:forwarded_ports).returns(fps)
|
285
|
-
fps.expects(:<<).with do |port|
|
286
|
-
assert_equal name, port.name
|
287
|
-
assert_equal opts[:hostport], port.hostport
|
288
|
-
assert_equal opts[:guestport], port.guestport
|
289
|
-
true
|
290
|
-
end
|
291
|
-
|
292
|
-
adapters[opts[:adapter]] = adapter
|
293
|
-
@vm.stubs(:network_adapters).returns(adapters)
|
294
|
-
|
295
|
-
@action.forward_port(name, opts)
|
296
|
-
end
|
250
|
+
@action.forward_port(name, opts)
|
297
251
|
end
|
298
252
|
end
|
299
253
|
end
|
@@ -4,6 +4,36 @@ class NetworkTest < Test::Unit::TestCase
|
|
4
4
|
setup do
|
5
5
|
@runner, @vm, @action = mock_action(Vagrant::Actions::VM::Network)
|
6
6
|
@runner.stubs(:system).returns(linux_system(@vm))
|
7
|
+
|
8
|
+
@interfaces = []
|
9
|
+
VirtualBox::Global.global.host.stubs(:network_interfaces).returns(@interfaces)
|
10
|
+
end
|
11
|
+
|
12
|
+
def mock_interface(options=nil)
|
13
|
+
options = {
|
14
|
+
:interface_type => :host_only,
|
15
|
+
:name => "foo"
|
16
|
+
}.merge(options || {})
|
17
|
+
|
18
|
+
interface = mock("interface")
|
19
|
+
options.each do |k,v|
|
20
|
+
interface.stubs(k).returns(v)
|
21
|
+
end
|
22
|
+
|
23
|
+
@interfaces << interface
|
24
|
+
interface
|
25
|
+
end
|
26
|
+
|
27
|
+
context "preparing" do
|
28
|
+
should "verify no bridge collisions for each network enabled" do
|
29
|
+
@runner.env.config.vm.network("foo")
|
30
|
+
@action.expects(:verify_no_bridge_collision).once.with() do |options|
|
31
|
+
assert_equal "foo", options[:ip]
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
@action.prepare
|
36
|
+
end
|
7
37
|
end
|
8
38
|
|
9
39
|
context "before destroy" do
|
@@ -112,11 +142,30 @@ class NetworkTest < Test::Unit::TestCase
|
|
112
142
|
end
|
113
143
|
end
|
114
144
|
|
115
|
-
context "
|
145
|
+
context "verify no bridge collision" do
|
116
146
|
setup do
|
117
|
-
@
|
118
|
-
|
147
|
+
@action.stubs(:matching_network?).returns(false)
|
148
|
+
@options = { :ip => :foo, :netmask => :bar, :name => nil }
|
149
|
+
end
|
119
150
|
|
151
|
+
should "do nothing if everything is okay" do
|
152
|
+
mock_interface
|
153
|
+
|
154
|
+
assert_nothing_raised { @action.verify_no_bridge_collision(@options) }
|
155
|
+
end
|
156
|
+
|
157
|
+
should "raise an exception if a collision is found" do
|
158
|
+
mock_interface(:interface_type => :bridged)
|
159
|
+
@action.stubs(:matching_network?).returns(true)
|
160
|
+
|
161
|
+
assert_raises(Vagrant::Actions::ActionException) {
|
162
|
+
@action.verify_no_bridge_collision(@options)
|
163
|
+
}
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
context "network name" do
|
168
|
+
setup do
|
120
169
|
@action.stubs(:matching_network?).returns(false)
|
121
170
|
|
122
171
|
@options = { :ip => :foo, :netmask => :bar, :name => nil }
|
@@ -124,21 +173,26 @@ class NetworkTest < Test::Unit::TestCase
|
|
124
173
|
|
125
174
|
should "return the network which matches" do
|
126
175
|
result = mock("result")
|
127
|
-
interface =
|
128
|
-
interface.stubs(:name).returns(result)
|
129
|
-
@interfaces << interface
|
176
|
+
interface = mock_interface(:name => result)
|
130
177
|
|
131
178
|
@action.expects(:matching_network?).with(interface, @options).returns(true)
|
132
179
|
assert_equal result, @action.network_name(@options)
|
133
180
|
end
|
134
181
|
|
135
|
-
should "
|
182
|
+
should "ignore non-host only interfaces" do
|
136
183
|
@options[:name] = "foo"
|
184
|
+
mock_interface(:name => @options[:name],
|
185
|
+
:interface_type => :bridged)
|
137
186
|
|
138
|
-
|
139
|
-
|
140
|
-
|
187
|
+
assert_raises(Vagrant::Actions::ActionException) {
|
188
|
+
@action.network_name(@options)
|
189
|
+
}
|
190
|
+
end
|
191
|
+
|
192
|
+
should "return the network which matches the name if given" do
|
193
|
+
@options[:name] = "foo"
|
141
194
|
|
195
|
+
interface = mock_interface(:name => @options[:name])
|
142
196
|
assert_equal @options[:name], @action.network_name(@options)
|
143
197
|
end
|
144
198
|
|
@@ -154,12 +208,12 @@ class NetworkTest < Test::Unit::TestCase
|
|
154
208
|
|
155
209
|
should "create a network for the IP and netmask" do
|
156
210
|
result = mock("result")
|
157
|
-
interface = mock("interface")
|
158
211
|
network_ip = :foo
|
212
|
+
|
213
|
+
interface = mock_interface(:name => result)
|
214
|
+
interface.expects(:enable_static).with(network_ip, @options[:netmask])
|
159
215
|
@interfaces.expects(:create).returns(interface)
|
160
216
|
@action.expects(:network_ip).with(@options[:ip], @options[:netmask]).once.returns(network_ip)
|
161
|
-
interface.expects(:enable_static).with(network_ip, @options[:netmask])
|
162
|
-
interface.expects(:name).returns(result)
|
163
217
|
|
164
218
|
assert_equal result, @action.network_name(@options)
|
165
219
|
end
|
@@ -226,6 +226,11 @@ class PackageActionTest < Test::Unit::TestCase
|
|
226
226
|
@action.prepare
|
227
227
|
end
|
228
228
|
|
229
|
+
should "raise an exception if the output file already exists" do
|
230
|
+
File.expects(:exist?).with(@action.tar_path).returns(false)
|
231
|
+
assert_raises(Vagrant::Actions::ActionException) { @action.prepare }
|
232
|
+
end
|
233
|
+
|
229
234
|
should "raise an exception when an include file does not exist" do
|
230
235
|
File.expects(:exists?).once.returns(false)
|
231
236
|
assert_raises(Vagrant::Actions::ActionException) { @action.prepare }
|