vagrant 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/.gitignore +11 -0
  2. data/Gemfile +17 -0
  3. data/README.md +45 -0
  4. data/Rakefile +41 -0
  5. data/VERSION +1 -0
  6. data/bin/.gitignore +0 -0
  7. data/bin/vagrant +15 -0
  8. data/bin/vagrant-box +35 -0
  9. data/bin/vagrant-down +28 -0
  10. data/bin/vagrant-halt +29 -0
  11. data/bin/vagrant-init +28 -0
  12. data/bin/vagrant-package +30 -0
  13. data/bin/vagrant-reload +30 -0
  14. data/bin/vagrant-resume +28 -0
  15. data/bin/vagrant-ssh +28 -0
  16. data/bin/vagrant-suspend +28 -0
  17. data/bin/vagrant-up +30 -0
  18. data/config/default.rb +29 -0
  19. data/lib/vagrant.rb +14 -0
  20. data/lib/vagrant/actions/base.rb +93 -0
  21. data/lib/vagrant/actions/box/add.rb +22 -0
  22. data/lib/vagrant/actions/box/destroy.rb +14 -0
  23. data/lib/vagrant/actions/box/download.rb +63 -0
  24. data/lib/vagrant/actions/box/unpackage.rb +49 -0
  25. data/lib/vagrant/actions/runner.rb +128 -0
  26. data/lib/vagrant/actions/vm/destroy.rb +14 -0
  27. data/lib/vagrant/actions/vm/down.rb +12 -0
  28. data/lib/vagrant/actions/vm/export.rb +41 -0
  29. data/lib/vagrant/actions/vm/forward_ports.rb +32 -0
  30. data/lib/vagrant/actions/vm/halt.rb +14 -0
  31. data/lib/vagrant/actions/vm/import.rb +17 -0
  32. data/lib/vagrant/actions/vm/move_hard_drive.rb +53 -0
  33. data/lib/vagrant/actions/vm/package.rb +61 -0
  34. data/lib/vagrant/actions/vm/provision.rb +71 -0
  35. data/lib/vagrant/actions/vm/reload.rb +17 -0
  36. data/lib/vagrant/actions/vm/resume.rb +16 -0
  37. data/lib/vagrant/actions/vm/shared_folders.rb +69 -0
  38. data/lib/vagrant/actions/vm/start.rb +50 -0
  39. data/lib/vagrant/actions/vm/suspend.rb +16 -0
  40. data/lib/vagrant/actions/vm/up.rb +35 -0
  41. data/lib/vagrant/box.rb +129 -0
  42. data/lib/vagrant/busy.rb +73 -0
  43. data/lib/vagrant/commands.rb +174 -0
  44. data/lib/vagrant/config.rb +156 -0
  45. data/lib/vagrant/downloaders/base.rb +13 -0
  46. data/lib/vagrant/downloaders/file.rb +21 -0
  47. data/lib/vagrant/downloaders/http.rb +47 -0
  48. data/lib/vagrant/env.rb +140 -0
  49. data/lib/vagrant/ssh.rb +43 -0
  50. data/lib/vagrant/util.rb +45 -0
  51. data/lib/vagrant/vm.rb +57 -0
  52. data/script/vagrant-ssh-expect.sh +22 -0
  53. data/templates/Vagrantfile +8 -0
  54. data/test/test_helper.rb +91 -0
  55. data/test/vagrant/actions/base_test.rb +32 -0
  56. data/test/vagrant/actions/box/add_test.rb +37 -0
  57. data/test/vagrant/actions/box/destroy_test.rb +18 -0
  58. data/test/vagrant/actions/box/download_test.rb +118 -0
  59. data/test/vagrant/actions/box/unpackage_test.rb +101 -0
  60. data/test/vagrant/actions/runner_test.rb +236 -0
  61. data/test/vagrant/actions/vm/destroy_test.rb +24 -0
  62. data/test/vagrant/actions/vm/down_test.rb +32 -0
  63. data/test/vagrant/actions/vm/export_test.rb +88 -0
  64. data/test/vagrant/actions/vm/forward_ports_test.rb +50 -0
  65. data/test/vagrant/actions/vm/halt_test.rb +27 -0
  66. data/test/vagrant/actions/vm/import_test.rb +36 -0
  67. data/test/vagrant/actions/vm/move_hard_drive_test.rb +108 -0
  68. data/test/vagrant/actions/vm/package_test.rb +155 -0
  69. data/test/vagrant/actions/vm/provision_test.rb +103 -0
  70. data/test/vagrant/actions/vm/reload_test.rb +44 -0
  71. data/test/vagrant/actions/vm/resume_test.rb +27 -0
  72. data/test/vagrant/actions/vm/shared_folders_test.rb +117 -0
  73. data/test/vagrant/actions/vm/start_test.rb +55 -0
  74. data/test/vagrant/actions/vm/suspend_test.rb +27 -0
  75. data/test/vagrant/actions/vm/up_test.rb +76 -0
  76. data/test/vagrant/box_test.rb +92 -0
  77. data/test/vagrant/busy_test.rb +81 -0
  78. data/test/vagrant/commands_test.rb +252 -0
  79. data/test/vagrant/config_test.rb +123 -0
  80. data/test/vagrant/downloaders/base_test.rb +20 -0
  81. data/test/vagrant/downloaders/file_test.rb +32 -0
  82. data/test/vagrant/downloaders/http_test.rb +40 -0
  83. data/test/vagrant/env_test.rb +293 -0
  84. data/test/vagrant/ssh_test.rb +95 -0
  85. data/test/vagrant/util_test.rb +64 -0
  86. data/test/vagrant/vm_test.rb +96 -0
  87. metadata +275 -0
@@ -0,0 +1,64 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ class UtilTest < Test::Unit::TestCase
4
+ class RegUtil
5
+ extend Vagrant::Util
6
+ end
7
+
8
+ context "erroring" do
9
+ # TODO: Any way to stub Kernel.exit? Can't test nicely
10
+ # otherwise
11
+ end
12
+
13
+ context "logger" do
14
+ class OtherUtil
15
+ extend Vagrant::Util
16
+ end
17
+
18
+ setup do
19
+ @config = Vagrant::Config::Top.new
20
+ @config.stubs(:loaded?).returns(true)
21
+ @config.vagrant.log_output = STDOUT
22
+ Vagrant::Config.stubs(:config).returns(@config)
23
+ Vagrant::Logger.reset_logger!
24
+ end
25
+
26
+ teardown do
27
+ Vagrant::Logger.reset_logger!
28
+ end
29
+
30
+ should "return a logger to nil if config is not loaded" do
31
+ @config.expects(:loaded?).returns(false)
32
+ logger = RegUtil.logger
33
+ assert_nil logger.instance_variable_get(:@logdev)
34
+ end
35
+
36
+ should "return a logger using the configured output" do
37
+ logger = RegUtil.logger
38
+ logdev = logger.instance_variable_get(:@logdev)
39
+ assert logger
40
+ assert !logdev.nil?
41
+ assert_equal STDOUT, logdev.dev
42
+ end
43
+
44
+ should "only instantiate a logger once" do
45
+ Vagrant::Logger.expects(:new).once.returns("GOOD")
46
+ RegUtil.logger
47
+ RegUtil.logger
48
+ end
49
+
50
+ should "be able to reset the logger" do
51
+ Vagrant::Logger.expects(:new).twice
52
+ RegUtil.logger
53
+ Vagrant::Logger.reset_logger!
54
+ RegUtil.logger
55
+ end
56
+
57
+ should "return the same logger across classes" do
58
+ logger = RegUtil.logger
59
+ other = OtherUtil.logger
60
+
61
+ assert logger.equal?(other)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,96 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
2
+
3
+ class VMTest < Test::Unit::TestCase
4
+ setup do
5
+ @mock_vm = mock("vm")
6
+ mock_config
7
+
8
+ @persisted_vm = mock("persisted_vm")
9
+ Vagrant::Env.stubs(:persisted_vm).returns(@persisted_vm)
10
+
11
+ Net::SSH.stubs(:start)
12
+ end
13
+
14
+ context "being an action runner" do
15
+ should "be an action runner" do
16
+ vm = Vagrant::VM.new
17
+ assert vm.is_a?(Vagrant::Actions::Runner)
18
+ end
19
+ end
20
+
21
+ context "finding a VM" do
22
+ should "return nil if the VM is not found" do
23
+ VirtualBox::VM.expects(:find).returns(nil)
24
+ assert_nil Vagrant::VM.find("foo")
25
+ end
26
+
27
+ should "return a Vagrant::VM object for that VM otherwise" do
28
+ VirtualBox::VM.expects(:find).with("foo").returns("bar")
29
+ result = Vagrant::VM.find("foo")
30
+ assert result.is_a?(Vagrant::VM)
31
+ assert_equal "bar", result.vm
32
+ end
33
+ end
34
+
35
+ context "vagrant VM instance" do
36
+ setup do
37
+ @vm = Vagrant::VM.new(@mock_vm)
38
+ end
39
+
40
+ context "packaging" do
41
+ should "queue up the actions and execute" do
42
+ out_path = mock("out_path")
43
+ action_seq = sequence("actions")
44
+ @vm.expects(:add_action).with(Vagrant::Actions::VM::Export).once.in_sequence(action_seq)
45
+ @vm.expects(:add_action).with(Vagrant::Actions::VM::Package, out_path, []).once.in_sequence(action_seq)
46
+ @vm.expects(:execute!).in_sequence(action_seq)
47
+ @vm.package(out_path)
48
+ end
49
+ end
50
+
51
+ context "destroying" do
52
+ should "execute the down action" do
53
+ @vm.expects(:execute!).with(Vagrant::Actions::VM::Down).once
54
+ @vm.destroy
55
+ end
56
+ end
57
+
58
+ context "suspending" do
59
+ should "execute the suspend action" do
60
+ @vm.expects(:execute!).with(Vagrant::Actions::VM::Suspend).once
61
+ @vm.suspend
62
+ end
63
+ end
64
+
65
+ context "resuming" do
66
+ should "execute the resume action" do
67
+ @vm.expects(:execute!).with(Vagrant::Actions::VM::Resume).once
68
+ @vm.resume
69
+ end
70
+ end
71
+
72
+ context "starting" do
73
+ setup do
74
+ @mock_vm.stubs(:running?).returns(false)
75
+ end
76
+
77
+ should "not do anything if the VM is already running" do
78
+ @mock_vm.stubs(:running?).returns(true)
79
+ @vm.expects(:execute!).never
80
+ @vm.start
81
+ end
82
+
83
+ should "add and execute the proper actions" do
84
+ actions = [Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders, Vagrant::Actions::VM::Start]
85
+
86
+ action_seq = sequence("action_seq")
87
+ actions.each do |action|
88
+ @vm.expects(:add_action).with(action).in_sequence(action_seq)
89
+ end
90
+
91
+ @vm.expects(:execute!).once.in_sequence(action_seq)
92
+ @vm.start
93
+ end
94
+ end
95
+ end
96
+ end
metadata ADDED
@@ -0,0 +1,275 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Mitchell Hashimoto
13
+ - John Bender
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-03-07 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: virtualbox
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 5
31
+ - 0
32
+ version: 0.5.0
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: net-ssh
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 2
44
+ - 0
45
+ - 19
46
+ version: 2.0.19
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: net-scp
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 1
58
+ - 0
59
+ - 2
60
+ version: 1.0.2
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: json
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 1
72
+ - 2
73
+ - 0
74
+ version: 1.2.0
75
+ type: :runtime
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: git-style-binaries
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ - 1
87
+ - 10
88
+ version: 0.1.10
89
+ type: :runtime
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
92
+ name: tarruby
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ segments:
99
+ - 0
100
+ - 1
101
+ - 5
102
+ version: 0.1.5
103
+ type: :runtime
104
+ version_requirements: *id006
105
+ description: Vagrant is a tool for building and distributing virtualized development environments.
106
+ email:
107
+ - mitchell.hashimoto@gmail.com
108
+ - john.m.bender@gmail.com
109
+ executables:
110
+ - vagrant
111
+ - vagrant-box
112
+ - vagrant-down
113
+ - vagrant-halt
114
+ - vagrant-init
115
+ - vagrant-package
116
+ - vagrant-reload
117
+ - vagrant-resume
118
+ - vagrant-ssh
119
+ - vagrant-suspend
120
+ - vagrant-up
121
+ extensions: []
122
+
123
+ extra_rdoc_files:
124
+ - README.md
125
+ files:
126
+ - .gitignore
127
+ - Gemfile
128
+ - README.md
129
+ - Rakefile
130
+ - VERSION
131
+ - bin/.gitignore
132
+ - bin/vagrant
133
+ - bin/vagrant-box
134
+ - bin/vagrant-down
135
+ - bin/vagrant-halt
136
+ - bin/vagrant-init
137
+ - bin/vagrant-package
138
+ - bin/vagrant-reload
139
+ - bin/vagrant-resume
140
+ - bin/vagrant-ssh
141
+ - bin/vagrant-suspend
142
+ - bin/vagrant-up
143
+ - config/default.rb
144
+ - lib/vagrant.rb
145
+ - lib/vagrant/actions/base.rb
146
+ - lib/vagrant/actions/box/add.rb
147
+ - lib/vagrant/actions/box/destroy.rb
148
+ - lib/vagrant/actions/box/download.rb
149
+ - lib/vagrant/actions/box/unpackage.rb
150
+ - lib/vagrant/actions/runner.rb
151
+ - lib/vagrant/actions/vm/destroy.rb
152
+ - lib/vagrant/actions/vm/down.rb
153
+ - lib/vagrant/actions/vm/export.rb
154
+ - lib/vagrant/actions/vm/forward_ports.rb
155
+ - lib/vagrant/actions/vm/halt.rb
156
+ - lib/vagrant/actions/vm/import.rb
157
+ - lib/vagrant/actions/vm/move_hard_drive.rb
158
+ - lib/vagrant/actions/vm/package.rb
159
+ - lib/vagrant/actions/vm/provision.rb
160
+ - lib/vagrant/actions/vm/reload.rb
161
+ - lib/vagrant/actions/vm/resume.rb
162
+ - lib/vagrant/actions/vm/shared_folders.rb
163
+ - lib/vagrant/actions/vm/start.rb
164
+ - lib/vagrant/actions/vm/suspend.rb
165
+ - lib/vagrant/actions/vm/up.rb
166
+ - lib/vagrant/box.rb
167
+ - lib/vagrant/busy.rb
168
+ - lib/vagrant/commands.rb
169
+ - lib/vagrant/config.rb
170
+ - lib/vagrant/downloaders/base.rb
171
+ - lib/vagrant/downloaders/file.rb
172
+ - lib/vagrant/downloaders/http.rb
173
+ - lib/vagrant/env.rb
174
+ - lib/vagrant/ssh.rb
175
+ - lib/vagrant/util.rb
176
+ - lib/vagrant/vm.rb
177
+ - script/vagrant-ssh-expect.sh
178
+ - templates/Vagrantfile
179
+ - test/test_helper.rb
180
+ - test/vagrant/actions/base_test.rb
181
+ - test/vagrant/actions/box/add_test.rb
182
+ - test/vagrant/actions/box/destroy_test.rb
183
+ - test/vagrant/actions/box/download_test.rb
184
+ - test/vagrant/actions/box/unpackage_test.rb
185
+ - test/vagrant/actions/runner_test.rb
186
+ - test/vagrant/actions/vm/destroy_test.rb
187
+ - test/vagrant/actions/vm/down_test.rb
188
+ - test/vagrant/actions/vm/export_test.rb
189
+ - test/vagrant/actions/vm/forward_ports_test.rb
190
+ - test/vagrant/actions/vm/halt_test.rb
191
+ - test/vagrant/actions/vm/import_test.rb
192
+ - test/vagrant/actions/vm/move_hard_drive_test.rb
193
+ - test/vagrant/actions/vm/package_test.rb
194
+ - test/vagrant/actions/vm/provision_test.rb
195
+ - test/vagrant/actions/vm/reload_test.rb
196
+ - test/vagrant/actions/vm/resume_test.rb
197
+ - test/vagrant/actions/vm/shared_folders_test.rb
198
+ - test/vagrant/actions/vm/start_test.rb
199
+ - test/vagrant/actions/vm/suspend_test.rb
200
+ - test/vagrant/actions/vm/up_test.rb
201
+ - test/vagrant/box_test.rb
202
+ - test/vagrant/busy_test.rb
203
+ - test/vagrant/commands_test.rb
204
+ - test/vagrant/config_test.rb
205
+ - test/vagrant/downloaders/base_test.rb
206
+ - test/vagrant/downloaders/file_test.rb
207
+ - test/vagrant/downloaders/http_test.rb
208
+ - test/vagrant/env_test.rb
209
+ - test/vagrant/ssh_test.rb
210
+ - test/vagrant/util_test.rb
211
+ - test/vagrant/vm_test.rb
212
+ has_rdoc: true
213
+ homepage: http://github.com/mitchellh/vagrant
214
+ licenses: []
215
+
216
+ post_install_message:
217
+ rdoc_options:
218
+ - --charset=UTF-8
219
+ require_paths:
220
+ - lib
221
+ required_ruby_version: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - ">="
224
+ - !ruby/object:Gem::Version
225
+ segments:
226
+ - 0
227
+ version: "0"
228
+ required_rubygems_version: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ segments:
233
+ - 0
234
+ version: "0"
235
+ requirements: []
236
+
237
+ rubyforge_project:
238
+ rubygems_version: 1.3.6
239
+ signing_key:
240
+ specification_version: 3
241
+ summary: Vagrant is a tool for building and distributing virtualized development environments.
242
+ test_files:
243
+ - test/test_helper.rb
244
+ - test/vagrant/actions/base_test.rb
245
+ - test/vagrant/actions/box/add_test.rb
246
+ - test/vagrant/actions/box/destroy_test.rb
247
+ - test/vagrant/actions/box/download_test.rb
248
+ - test/vagrant/actions/box/unpackage_test.rb
249
+ - test/vagrant/actions/runner_test.rb
250
+ - test/vagrant/actions/vm/destroy_test.rb
251
+ - test/vagrant/actions/vm/down_test.rb
252
+ - test/vagrant/actions/vm/export_test.rb
253
+ - test/vagrant/actions/vm/forward_ports_test.rb
254
+ - test/vagrant/actions/vm/halt_test.rb
255
+ - test/vagrant/actions/vm/import_test.rb
256
+ - test/vagrant/actions/vm/move_hard_drive_test.rb
257
+ - test/vagrant/actions/vm/package_test.rb
258
+ - test/vagrant/actions/vm/provision_test.rb
259
+ - test/vagrant/actions/vm/reload_test.rb
260
+ - test/vagrant/actions/vm/resume_test.rb
261
+ - test/vagrant/actions/vm/shared_folders_test.rb
262
+ - test/vagrant/actions/vm/start_test.rb
263
+ - test/vagrant/actions/vm/suspend_test.rb
264
+ - test/vagrant/actions/vm/up_test.rb
265
+ - test/vagrant/box_test.rb
266
+ - test/vagrant/busy_test.rb
267
+ - test/vagrant/commands_test.rb
268
+ - test/vagrant/config_test.rb
269
+ - test/vagrant/downloaders/base_test.rb
270
+ - test/vagrant/downloaders/file_test.rb
271
+ - test/vagrant/downloaders/http_test.rb
272
+ - test/vagrant/env_test.rb
273
+ - test/vagrant/ssh_test.rb
274
+ - test/vagrant/util_test.rb
275
+ - test/vagrant/vm_test.rb