On Apr 27, 2009, at 10:27 AM, [email protected] wrote:

>
> Hey,
>
> I am new in the puppet code and I am trying to write a patch for this
> feature, but I need some advice about the global design.
> How could I manage the fact that there is many packages, do I have to
> create another type that handle multiple packages ?
> I have to select packages that could be install without breaking the
> dependency graph, how could I make this new type part of the graph ?
> And, where does it should be handle in the process ?
> How can I link this new "metatype" with the existing providers ?

I don't think a new type is either necessary or a good idea.  The  
critical issue is the interface between the package provider and the  
transaction, and it should look somewhat like how prefetching looks.

In terms of ordering, there are basically two choices:  Combine  
adjacent packages, or just combine all packages.  I expect that most  
package types would be fine combining all packages into a single call,  
but there should be a new package parameter added to allow people to  
disable this.

So, the transaction would have to track what kinds of packages it had  
run into, with a method something like this:

   def eval_resource
     ...
     if resource.provider.class.respond_to?(:install_multiple)
       events = install_multiple(resource)
     else
       ...
     end
   end

   def install_multiple(resource)
     provider_class = resource.provider.class
     @multiple_install_events ||= {}
     @multiple_install_events[provider_class] ||= {}
     if event = @multiple_install_events[provider_class][resource.path]
       return event
     end

     # Find all resources matching the provider class that set combining
     resource_names = catalog.vertices.collect { |r|  
r.provider.class.equal?(provider.class) }.reject { |r| r[:combine] ==  
false }.collect { |r| r[:name] }

     @multiple_install_events[provider_class] =  
provider_class.install_multiple(resource_names)

     @multiple_install_events[provider_class][resource.path]
   end

----

Obviously this isn't quite right, but you get the idea -- you need to  
have per-resource events, so that notification and dependencies work  
correctly, but otherwise you want to combine everything.

You'll also need to check all of the resources first to see if they're  
in sync - you don't want to include packages that are already  
installed in the list to be installed.

-- 
Honest criticism is hard to take, particularly from a relative, a
friend, an acquaintance, or a stranger. -- Franklin P. Jones
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to