diff --git a/lib/vagrant/plugin/v2/provider.rb b/lib/vagrant/plugin/v2/provider.rb index e208496e3..59bc0c089 100644 --- a/lib/vagrant/plugin/v2/provider.rb +++ b/lib/vagrant/plugin/v2/provider.rb @@ -9,6 +9,21 @@ module Vagrant class Provider include CapabilityHost + # This is called early, before a machine is instantiated, to check + # if this provider is usable. This should return true or false. + # + # If raise_error is true, then instead of returning false, this + # should raise an error with a helpful message about why this + # provider cannot be used. + # + # @param [Boolean] raise_error If true, raise exception if not usable. + # @return [Boolean] + def self.usable?(raise_error=false) + # Return true by default for backwards compat since this was + # introduced long after providers were being written. + true + end + # Initialize the provider to represent the given machine. # # @param [Vagrant::Machine] machine The machine that this provider diff --git a/test/unit/vagrant/plugin/v2/provider_test.rb b/test/unit/vagrant/plugin/v2/provider_test.rb index 77b7ab5d7..c27274db1 100644 --- a/test/unit/vagrant/plugin/v2/provider_test.rb +++ b/test/unit/vagrant/plugin/v2/provider_test.rb @@ -8,6 +8,10 @@ describe Vagrant::Plugin::V2::Provider do subject { instance } + it "should be usable by default" do + expect(described_class).to be_usable + end + it "should return nil by default for actions" do expect(instance.action(:whatever)).to be_nil end