In my smartos_zones cookbook I have two different resource types but a single provider.
I wanted to highlight what I had to do to detect which was used.
I have a KVM and a Zone resource, in the provider’s load_current_resource I have:
... restype = get_restype @current_resource ||= restype.new(@new_resource.name) ...
Get restype looks like this:
... def get_restype if @new_resource.resource_name.eql? :zone; return Chef::Resource::Zone; end if @new_resource.resource_name.eql? :kvm; return Chef::Resource::Kvm; end Chef::Application.fatal!("Couldn't find resource class") end ...
Fairly simple, but took me a bit of messing around to get it to be right, hence a note about it.