On Mon, Oct 15, 2012 at 01:09:09PM +0200, Jakov Sosic wrote:
> On 10/15/2012 09:13 AM, Stefan Schulte wrote:
> 
> > Is it possible to run a command to get all the desired information about
> > every systems at once? This way you can implement a prefetch pattern.
> > Basically you create provider instances for each system at once and
> > write the current values in the @property_hash hash. Then your get methods
> > just return the cached value which scales pretty well.
> 
> 
> Yes it is possible to get all systems at once. It's what the XMLRPC call
> does:
> 
>    xmlrpcresult = cobblerserver.call("get_systems")
> 
> I already do that, but I select only one system, examine the hash, and
> if I notice differences from current puppet settings, approach to
> running CLI commands editing that system.
> 
> Your idea would require top to bottom rewrite of provider, and I don't
> have currently time for it... also, what are the benefits?
> 
> Currently I am planning to change params to properties (every param that
> is not needed for creation of system can be managed as property - it's
> more native way as I figured it out now).
> 

The fact that your exists? method does not really answer the question if
a resource is present or absent is a bit strange. And inside the create
method you are basically reimplementing properties with parameters. If
something has to be checked for correctness it should be a property.
Otherwise it is a parameter. Like the service resource: enable is a
property because it can be out of sync. hasstatus is a parameter because
it cannot be out of sync but only changes the behaviour of the provider

Your main concern against properties if I got you correctly was about
speed because puppet would run one query for each property. One way around
that is to implement a query method that will query all properties at once
and store them in a hash (@property_hash). Every get-method now check
if @property_hash[:some_property] does already exist and return that
value if it does or run the query method that would populate the
@property_hash hash.

Another speed improvement is to implement an `instances` and `prefetch`
method. That has the benefit that puppet does "react" on such methods
if they are implemented:

* you are able to run "puppet resource cobblersystem" on the command
  line to get the current configuration of all systems (that depends on
  an instances classmethod)
* you can use the resources type to purge unmanaged systems

    resources { 'cobblersystem':
      purge => true
    }
* the prefetch method is automatically called by puppet if implemented
  to create provider instances
* your get methods become trivial

-Stefan

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to