From 967f7bce1a0102e2366e1e5ac0cf0b567126879c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 10 Apr 2014 10:02:27 -0700 Subject: [PATCH] providers/virtualbox: usability test --- plugins/providers/virtualbox/provider.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/providers/virtualbox/provider.rb b/plugins/providers/virtualbox/provider.rb index 61c7a5ef5..a52c07fb3 100644 --- a/plugins/providers/virtualbox/provider.rb +++ b/plugins/providers/virtualbox/provider.rb @@ -5,6 +5,19 @@ module VagrantPlugins class Provider < Vagrant.plugin("2", :provider) attr_reader :driver + def self.usable?(raise_error=false) + # Instantiate the driver, which will determine the VirtualBox + # version and all that, which checks for VirtualBox being present + Driver::Meta.new + true + rescue Vagrant::Errors::VirtualBoxInvalidVersion + raise if raise_error + return false + rescue Vagrant::Errors::VirtualBoxNotDetected + raise if raise_error + return false + end + def initialize(machine) @logger = Log4r::Logger.new("vagrant::provider::virtualbox") @machine = machine