I haven't checked the time for the catalog search. I'll give it a shot but,
in light of the complexity, I'll just do the multi search.

The issue, in this case, is that I need to require all resources of a given
type for multiple types.

I didn't see an obvious way of globbing, so I did a direct search.

Thanks for the quick response!

Trevor

On Tue, Feb 19, 2013 at 12:19 PM, Luke Kanies <[email protected]> wrote:

> On Feb 19, 2013, at 7:20 AM, Trevor Vaughan <[email protected]>
> wrote:
>
> I've got a situation where I have multiple types that I need to
> autorequire but I only want to search through the catalog once to require
> them.
>
> I've tried:
>
> @autodeps = {
>   :typea => [],
>   :typeb => [],
>   :typec => []
> }
>
> @autodeps.each_key do |dep|
>   autorequire(dep) do
>     if @autodeps[type].nil? then
>       @autodeps[type] = []
>       catalog.resources.find_all do |r|
>         @autodeps.keys.each do |dep|
>           r.is_a?(Puppet::Type.type(dep)) and @autodeps[dep] << r[:name]
>         end
>       end
>     end
>     @autodeps[type]
>   end
> end
>
> I understand that I'm passing a block down to autorequire and that I'm
> completely losing scope on @autodeps but is there some reasonable way to do
> this so that I only have to dig through the catalog one time to find my
> dependencies?
>
>
> Why are you trying to avoid searching the catalog multiple times?  It
> should just be a simple hash search, which is generally fast enough that
> you shouldn't see significant slowdown.
>
> The short answer is that I think that this would be impressively difficult
> in general, and unless you're seeing concrete slowdowns resulting from
> three separate autorequires, I'd recommend you stick with plain autorequire.
>
> Remember that autorequire can just return the title of the resource you're
> looking for; you don't have to return the actual resource.  That should
> make your code much shorter and simpler.
>
> --
> Luke Kanies | http://about.me/lak | http://puppetlabs.com/ |
> +1-615-594-8199
>
>  --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
[email protected]

-- This account not approved for unencrypted proprietary information --

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to