On Wednesday, March 5, 2014 11:56:08 AM UTC-6, Shook Shivers wrote:
>
> I get Error: Could not prefetch zenoss_device provider 'zenoss_device': 
> undefined local variable or method `resource' for 
> Puppet::Type::Zenoss_device::ProviderZenoss_device:Class when using the 
> following 
>
> def self.prefetch(r)
>         @transport ||= 
> PuppetX::Puppetlabs::Transport.retrieve(:resource_ref => 
> resource[:transport], :catalog => resource.catalog, :provider => 'vsphere')
>
>     p "#{r}"
>   end
>
> The above is only for testing purposes
>
> Im writing a type provider for zenoss my first so please be kind and im 
> trying to access the  resource hash but cannot 
>
> All id like to know is what module (is it the provider) that will allow me 
> to access this resource hash
>
> I tried accessing it from within a provider but that does not work 
> "resource[:transport]".  
>
> Im using a usefull hack from https://github.com/vmware/vmware-vmware_libwhere 
> instead of using a SSH as a connector im using a Rest class i created 
> for connecting to a Zenoss master
>
> I guess the issue here is how do I use this transport type provider 
>
> Any clues anyone??
>


If you have not already done so, you should read PuppetLabs's docs on the 
subject.  In particular, see 
http://docs.puppetlabs.com/guides/provider_development.html.

Specifically with regard to your issue, however, you should probably be 
writing an instances() method, not a prefetch() method.  The latter is 
supplied by Puppet.  Furthermore, neither of those is an instance method of 
the provider class (how could they be?), so there cannot be any specific 
resource to refer to unless you select one by some mechanism.  Indeed, 
choosing which resource instance, if any, to assign to each discovered 
provider instance is the a large part of the job of the provider class's 
prefetch() method.

Note, too, that prefetching is an optional behavior.  If it is not feasible 
for your provider class to identify and enumerate all initially-available 
instances, then its instances() method should simply return an empty list.  
That will have some implications for other aspects of the provider 
implementation, but it is a reasonable approach.  Not every conceivable 
resource type can be prefetched (consider File, for example).


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/46597474-faad-40a5-961e-c2cb57932863%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to