vagrant 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -15,6 +15,7 @@ module Vagrant
15
15
 
16
16
  @runner.add_action(Download)
17
17
  @runner.add_action(Unpackage)
18
+ @runner.add_action(Verify)
18
19
  end
19
20
  end
20
21
  end
@@ -4,7 +4,6 @@ module Vagrant
4
4
  # This action unpackages a downloaded box file into its final
5
5
  # box destination within the vagrant home folder.
6
6
  class Unpackage < Base
7
-
8
7
  def execute!
9
8
  @runner.invoke_around_callback(:unpackage) do
10
9
  setup_box_dir
@@ -0,0 +1,32 @@
1
+ module Vagrant
2
+ module Actions
3
+ module Box
4
+ # This action verifies that a given box is valid. This works by attempting
5
+ # to read/interpret the appliance file (OVF). If the reading succeeds, then
6
+ # the box is assumed to be valid.
7
+ class Verify < Base
8
+ def execute!
9
+ logger.info "Verifying box..."
10
+ reload_configuration
11
+ verify_appliance
12
+ end
13
+
14
+ def reload_configuration
15
+ # We have to reload the environment config since we _just_ added the
16
+ # box. We do this by setting the current box to the recently added box,
17
+ # then reloading
18
+ @runner.env.config.vm.box = @runner.name
19
+ @runner.env.load_box!
20
+ @runner.env.load_config!
21
+ end
22
+
23
+ def verify_appliance
24
+ # We now try to read the applince. If it succeeds, we return true.
25
+ VirtualBox::Appliance.new(@runner.ovf_file)
26
+ rescue VirtualBox::Exceptions::FileErrorException
27
+ raise ActionException.new(:box_verification_failed)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -11,6 +11,13 @@ module Vagrant
11
11
  @runner.add_action(action_klass)
12
12
  end
13
13
  end
14
+
15
+ def after_halt
16
+ # This sleep is here to allow the VM to clean itself up. There appears
17
+ # nothing [obvious] in the VirtualBox API to automate this. For now, this
18
+ # is an interim solution.
19
+ sleep 1
20
+ end
14
21
  end
15
22
  end
16
23
  end
@@ -126,7 +126,7 @@ module Vagrant
126
126
  #
127
127
  # @return [String]
128
128
  def ovf_file
129
- File.join(directory, Vagrant.config.vm.box_ovf)
129
+ File.join(directory, env.config.vm.box_ovf)
130
130
  end
131
131
 
132
132
  # Begins the process of adding a box to the vagrant installation. This
@@ -21,7 +21,7 @@ module Vagrant
21
21
  rootfile_path = File.join(Dir.pwd, Environment::ROOTFILE_NAME)
22
22
  error_and_exit(:rootfile_already_exists) if File.exist?(rootfile_path)
23
23
 
24
- # Copy over the rootfile template into this directory
24
+ # Write the rootfile
25
25
  default_box ||= "base"
26
26
  File.open(rootfile_path, 'w+') do |f|
27
27
  f.write(TemplateRenderer.render(Environment::ROOTFILE_NAME, :default_box => default_box))
@@ -37,6 +37,8 @@ module Vagrant
37
37
  error_and_exit(:virtualbox_not_detected)
38
38
  elsif version.to_f < 3.1
39
39
  error_and_exit(:virtualbox_invalid_version, :version => version.to_s)
40
+ elsif version.to_s.downcase.include?("ose")
41
+ error_and_exit(:virtualbox_invalid_ose, :version => version.to_s)
40
42
  end
41
43
  end
42
44
  end
@@ -17,6 +17,9 @@
17
17
 
18
18
  The box must be added through the `vagrant box add` command. Please view
19
19
  the documentation associated with the command for more information.
20
+ :box_verification_failed: |-
21
+ The specified box is invalid. This can commonly be attributed to incorrectly
22
+ typing in the path to the box or invalid packaging of the box.
20
23
  :box_not_specified: |-
21
24
  No base box was specified! A base box is required as a staring point
22
25
  for every vagrant virtual machine. Please specify one in your Vagrantfile
@@ -115,6 +118,11 @@
115
118
  Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed.
116
119
  If VirtualBox is installed, it may be an incorrect version. Vagrant currently
117
120
  only supports VirtualBox 3.1.x. Please install the proper version to continue.
121
+ :virtualbox_invalid_ose: |-
122
+ Vagrant has detected you're using an OSE ("Open Source Edition") of VirtualBox.
123
+ Vagrant currently doesn't support any of the OSE editions due to slight API
124
+ differences. Please download the regular package from virtualbox.org and install
125
+ to continue.
118
126
  :vm_failed_to_boot: |-
119
127
  Failed to connect to VM! Failed to boot?
120
128
  :vm_base_not_found: |-
@@ -7,7 +7,7 @@ class AddBoxActionTest < Test::Unit::TestCase
7
7
 
8
8
  context "prepare" do
9
9
  setup do
10
- @default_order = [Vagrant::Actions::Box::Download, Vagrant::Actions::Box::Unpackage]
10
+ @default_order = [Vagrant::Actions::Box::Download, Vagrant::Actions::Box::Unpackage, Vagrant::Actions::Box::Verify]
11
11
  @runner.stubs(:directory).returns("foo")
12
12
  File.stubs(:exists?).returns(false)
13
13
  end
@@ -0,0 +1,44 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
2
+
3
+ class VerifyBoxActionTest < Test::Unit::TestCase
4
+ setup do
5
+ @runner, @vm, @action = mock_action(Vagrant::Actions::Box::Verify)
6
+ @runner.stubs(:name).returns("foo")
7
+ @runner.stubs(:temp_path).returns("bar")
8
+ end
9
+
10
+ context "executing" do
11
+ should "execute the proper actions in the proper order" do
12
+ exec_seq = sequence("exec_seq")
13
+ @action.expects(:reload_configuration).in_sequence(exec_seq)
14
+ @action.expects(:verify_appliance).in_sequence(exec_seq)
15
+ @action.execute!
16
+ end
17
+ end
18
+
19
+ context "reloading configuration" do
20
+ should "set the new box, load box, then load config" do
21
+ reload_seq = sequence("reload_seq")
22
+ @runner.env.config.vm.expects(:box=).with(@runner.name).in_sequence(reload_seq)
23
+ @runner.env.expects(:load_box!).in_sequence(reload_seq)
24
+ @runner.env.expects(:load_config!).in_sequence(reload_seq)
25
+ @action.reload_configuration
26
+ end
27
+ end
28
+
29
+ context "verifying appliance" do
30
+ setup do
31
+ @runner.stubs(:ovf_file).returns("foo")
32
+ end
33
+
34
+ should "create new appliance and return true if succeeds" do
35
+ VirtualBox::Appliance.expects(:new).with(@runner.ovf_file)
36
+ assert_nothing_raised { @action.verify_appliance }
37
+ end
38
+
39
+ should "return false if an exception is raised" do
40
+ VirtualBox::Appliance.expects(:new).with(@runner.ovf_file).raises(VirtualBox::Exceptions::FileErrorException)
41
+ assert_raises(Vagrant::Actions::ActionException) { @action.verify_appliance }
42
+ end
43
+ end
44
+ end
@@ -112,6 +112,7 @@ class BoxTest < Test::Unit::TestCase
112
112
  context "instance methods" do
113
113
  setup do
114
114
  @box = Vagrant::Box.new
115
+ @box.env = mock_environment
115
116
  end
116
117
 
117
118
  should "execute the Add action when add is called" do
@@ -141,10 +142,12 @@ class BoxTest < Test::Unit::TestCase
141
142
  context "ovf file" do
142
143
  setup do
143
144
  @box.stubs(:directory).returns("foo")
145
+
146
+ @box.env.config.vm.box_ovf = "foo.ovf"
144
147
  end
145
148
 
146
149
  should "be the directory joined with the config ovf file" do
147
- assert_equal File.join(@box.directory, Vagrant.config.vm.box_ovf), @box.ovf_file
150
+ assert_equal File.join(@box.directory, @box.env.config.vm.box_ovf), @box.ovf_file
148
151
  end
149
152
  end
150
153
  end
@@ -24,6 +24,13 @@ class EnvironmentTest < Test::Unit::TestCase
24
24
  VirtualBox.expects(:version).returns(version)
25
25
  Vagrant::Environment.check_virtualbox!
26
26
  end
27
+
28
+ should "error and exit for OSE VirtualBox" do
29
+ version = "3.1.6_OSE"
30
+ Vagrant::Environment.expects(:error_and_exit).with(:virtualbox_invalid_ose, :version => version.to_s).once
31
+ VirtualBox.expects(:version).returns(version)
32
+ Vagrant::Environment.check_virtualbox!
33
+ end
27
34
  end
28
35
 
29
36
  context "class method load!" do
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{vagrant}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mitchell Hashimoto", "John Bender"]
12
- s.date = %q{2010-04-15}
12
+ s.date = %q{2010-04-21}
13
13
  s.default_executable = %q{vagrant}
14
14
  s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.}
15
15
  s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"]
@@ -38,6 +38,7 @@ Gem::Specification.new do |s|
38
38
  "lib/vagrant/actions/box/destroy.rb",
39
39
  "lib/vagrant/actions/box/download.rb",
40
40
  "lib/vagrant/actions/box/unpackage.rb",
41
+ "lib/vagrant/actions/box/verify.rb",
41
42
  "lib/vagrant/actions/collection.rb",
42
43
  "lib/vagrant/actions/runner.rb",
43
44
  "lib/vagrant/actions/vm/boot.rb",
@@ -107,6 +108,7 @@ Gem::Specification.new do |s|
107
108
  "test/vagrant/actions/box/destroy_test.rb",
108
109
  "test/vagrant/actions/box/download_test.rb",
109
110
  "test/vagrant/actions/box/unpackage_test.rb",
111
+ "test/vagrant/actions/box/verify_test.rb",
110
112
  "test/vagrant/actions/collection_test.rb",
111
113
  "test/vagrant/actions/runner_test.rb",
112
114
  "test/vagrant/actions/vm/boot_test.rb",
@@ -176,6 +178,7 @@ Gem::Specification.new do |s|
176
178
  "test/vagrant/actions/box/destroy_test.rb",
177
179
  "test/vagrant/actions/box/download_test.rb",
178
180
  "test/vagrant/actions/box/unpackage_test.rb",
181
+ "test/vagrant/actions/box/verify_test.rb",
179
182
  "test/vagrant/actions/collection_test.rb",
180
183
  "test/vagrant/actions/runner_test.rb",
181
184
  "test/vagrant/actions/vm/boot_test.rb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mitchell Hashimoto
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-04-15 00:00:00 -07:00
18
+ date: 2010-04-21 00:00:00 -07:00
19
19
  default_executable: vagrant
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -133,6 +133,7 @@ files:
133
133
  - lib/vagrant/actions/box/destroy.rb
134
134
  - lib/vagrant/actions/box/download.rb
135
135
  - lib/vagrant/actions/box/unpackage.rb
136
+ - lib/vagrant/actions/box/verify.rb
136
137
  - lib/vagrant/actions/collection.rb
137
138
  - lib/vagrant/actions/runner.rb
138
139
  - lib/vagrant/actions/vm/boot.rb
@@ -202,6 +203,7 @@ files:
202
203
  - test/vagrant/actions/box/destroy_test.rb
203
204
  - test/vagrant/actions/box/download_test.rb
204
205
  - test/vagrant/actions/box/unpackage_test.rb
206
+ - test/vagrant/actions/box/verify_test.rb
205
207
  - test/vagrant/actions/collection_test.rb
206
208
  - test/vagrant/actions/runner_test.rb
207
209
  - test/vagrant/actions/vm/boot_test.rb
@@ -295,6 +297,7 @@ test_files:
295
297
  - test/vagrant/actions/box/destroy_test.rb
296
298
  - test/vagrant/actions/box/download_test.rb
297
299
  - test/vagrant/actions/box/unpackage_test.rb
300
+ - test/vagrant/actions/box/verify_test.rb
298
301
  - test/vagrant/actions/collection_test.rb
299
302
  - test/vagrant/actions/runner_test.rb
300
303
  - test/vagrant/actions/vm/boot_test.rb