On Dec 13, 2010, at 4:07 PM, Dan Bode wrote:

> 
> 
> On Mon, Dec 13, 2010 at 3:39 PM, Luke Kanies <[email protected]> wrote:
> On Dec 13, 2010, at 2:00 PM, Dan Bode wrote:
> 
> > Hi all,
> >
> > I was trying to figure out how to include parametrized classes. I 
> > eventually got it to work with the following syntax, but I don't understand 
> > what it does (I tried to read the code). Can someone explain the magic of 
> > known_resource_types?
> >
> > classes.each do |name, params|
> >         klass = Puppet::Resource::Type.new(:hostclass, name, params)
> >         known_resource_types.add klass
> > end 
> Is this from a function, or what?  There's clearly context missing here 
> (e.g., where do 'params' come from? how is 'classes' created?)
> 
> names, and params all come from an external node classifier (I am trying to 
> patch ENC support for param classes)
> 
> This is actually called form the compiler class. When I get it properly 
> sorted, I will submit a patch.

If your goal is to evaluate a parameterized class, it's, um, apparently pretty 
annoyingly complicated.  At least, if the parameterized class has a parent 
class it is.  Look at the 'ensure_in_catalog' method in 
lib/puppet/resource/type.rb in the current master branch for an example of how 
it's done when there aren't parameters.

Paul - would it be possible to extend that method to accept parameters, and 
then promote it as an API method for use in things like functions?

> This shouldn't actually cause class evaluation during parsing - it just 
> creates the class,
> 
> what does it mean to create a class in this context?

It's equivalent to declaring a class (e.g., "class foo {}"), rather than 
'including' it.

-- 
Between two evils, I always pick the one I never tried before.
    -- Mae West
---------------------------------------------------------------------
Luke Kanies  -|-   http://puppetlabs.com   -|-   +1(615)594-8199



-- 
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