Check that VirtualBox exists early. [GH-746]
This commit is contained in:
parent
af884e4b74
commit
8969605fe2
|
@ -23,6 +23,7 @@
|
|||
- Add an `fsid` option to Linux NFS exports. [GH-736]
|
||||
- Fix edge case where an exception could be raised in networking code. [GH-742]
|
||||
- Add missing translation for the "guru meditation" state. [GH-745]
|
||||
- Check that VirtualBox exists before certain commands. [GH-746]
|
||||
|
||||
## 0.9.7 (February 9, 2012)
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
module General
|
||||
autoload :CheckVirtualbox, 'vagrant/action/general/check_virtualbox'
|
||||
autoload :Package, 'vagrant/action/general/package'
|
||||
autoload :Validate, 'vagrant/action/general/validate'
|
||||
end
|
||||
|
|
|
@ -20,6 +20,7 @@ module Vagrant
|
|||
# provision - Provisions a running VM
|
||||
register(:provision) do
|
||||
Builder.new do
|
||||
use General::CheckVirtualbox
|
||||
use General::Validate
|
||||
use VM::CheckAccessible
|
||||
use VM::Provision
|
||||
|
@ -30,6 +31,7 @@ module Vagrant
|
|||
# environment.
|
||||
register(:start) do
|
||||
Builder.new do
|
||||
use General::CheckVirtualbox
|
||||
use General::Validate
|
||||
use VM::CheckAccessible
|
||||
use VM::CleanMachineFolder
|
||||
|
@ -53,6 +55,7 @@ module Vagrant
|
|||
# a restart if fails.
|
||||
register(:halt) do
|
||||
Builder.new do
|
||||
use General::CheckVirtualbox
|
||||
use General::Validate
|
||||
use VM::CheckAccessible
|
||||
use VM::DiscardState
|
||||
|
@ -63,6 +66,7 @@ module Vagrant
|
|||
# suspend - Suspends the VM
|
||||
register(:suspend) do
|
||||
Builder.new do
|
||||
use General::CheckVirtualbox
|
||||
use General::Validate
|
||||
use VM::CheckAccessible
|
||||
use VM::Suspend
|
||||
|
@ -72,6 +76,7 @@ module Vagrant
|
|||
# resume - Resume a VM
|
||||
register(:resume) do
|
||||
Builder.new do
|
||||
use General::CheckVirtualbox
|
||||
use General::Validate
|
||||
use VM::CheckAccessible
|
||||
use VM::CheckPortCollisions
|
||||
|
@ -82,6 +87,7 @@ module Vagrant
|
|||
# reload - Halts then restarts the VM
|
||||
register(:reload) do
|
||||
Builder.new do
|
||||
use General::CheckVirtualbox
|
||||
use General::Validate
|
||||
use VM::CheckAccessible
|
||||
use registry.get(:halt)
|
||||
|
@ -92,6 +98,7 @@ module Vagrant
|
|||
# up - Imports, prepares, then starts a fresh VM.
|
||||
register(:up) do
|
||||
Builder.new do
|
||||
use General::CheckVirtualbox
|
||||
use General::Validate
|
||||
use VM::CheckAccessible
|
||||
use VM::CheckBox
|
||||
|
@ -106,6 +113,7 @@ module Vagrant
|
|||
# destroy - Halts, cleans up, and destroys an existing VM
|
||||
register(:destroy) do
|
||||
Builder.new do
|
||||
use General::CheckVirtualbox
|
||||
use General::Validate
|
||||
use VM::CheckAccessible
|
||||
use registry.get(:halt), :force => true
|
||||
|
@ -120,6 +128,7 @@ module Vagrant
|
|||
# package - Export and package the VM
|
||||
register(:package) do
|
||||
Builder.new do
|
||||
use General::CheckVirtualbox
|
||||
use General::Validate
|
||||
use VM::SetupPackageFiles
|
||||
use VM::CheckAccessible
|
||||
|
@ -135,6 +144,7 @@ module Vagrant
|
|||
# box_add - Download and add a box.
|
||||
register(:box_add) do
|
||||
Builder.new do
|
||||
use General::CheckVirtualbox
|
||||
use Box::Download
|
||||
use Box::Unpackage
|
||||
use Box::Verify
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
module Vagrant
|
||||
module Action
|
||||
module General
|
||||
# Checks that virtualbox is installed and ready to be used.
|
||||
class CheckVirtualbox
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
env[:vm].driver.verify!
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,12 +6,11 @@ module Vagrant
|
|||
class Validate
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
@env = env
|
||||
end
|
||||
|
||||
def call(env)
|
||||
@env[:vm].config.validate!(@env[:vm].env) if !@env.has_key?("validate") || @env["validate"]
|
||||
@app.call(@env)
|
||||
env[:vm].config.validate!(env[:vm].env) if !env.has_key?("validate") || env["validate"]
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -99,6 +99,7 @@ module Vagrant
|
|||
:ssh_port,
|
||||
:start,
|
||||
:suspend,
|
||||
:verify!,
|
||||
:verify_image,
|
||||
:vm_exists?
|
||||
|
||||
|
|
|
@ -440,6 +440,12 @@ module Vagrant
|
|||
execute("controlvm", @uuid, "savestate")
|
||||
end
|
||||
|
||||
def verify!
|
||||
# This command sometimes fails if kernel drivers aren't properly loaded
|
||||
# so we just run the command and verify that it succeeded.
|
||||
execute("list", "hostonlyifs")
|
||||
end
|
||||
|
||||
def verify_image(path)
|
||||
r = raw("import", path.to_s, "--dry-run")
|
||||
return r.exit_code == 0
|
||||
|
|
|
@ -440,6 +440,12 @@ module Vagrant
|
|||
execute("controlvm", @uuid, "savestate")
|
||||
end
|
||||
|
||||
def verify!
|
||||
# This command sometimes fails if kernel drivers aren't properly loaded
|
||||
# so we just run the command and verify that it succeeded.
|
||||
execute("list", "hostonlyifs")
|
||||
end
|
||||
|
||||
def verify_image(path)
|
||||
r = raw("import", path.to_s, "--dry-run")
|
||||
return r.exit_code == 0
|
||||
|
|
|
@ -234,6 +234,12 @@ module Vagrant
|
|||
def suspend
|
||||
end
|
||||
|
||||
# Verifies that the driver is ready to accept work.
|
||||
#
|
||||
# This should raise a VagrantError if things are not ready.
|
||||
def verify!
|
||||
end
|
||||
|
||||
# Verifies that an image can be imported properly.
|
||||
#
|
||||
# @param [String] path Path to an OVF file.
|
||||
|
|
Loading…
Reference in New Issue