I'm not an expert on the topic, but my understanding is that you can't
create a type without well-defined property/parameter names.  Or, to put it
a different way, there is currently no officially sanctioned means by which
to support dynamic property/parameter names for a type or a provider.

One way that you could work around it is to define a property with a name
like "options", whose value would be a hash.  Then there are no
restrictions on your hash key names.

There is some discussion around this topic on the following tickets:

http://projects.puppetlabs.com/issues/4113
http://projects.puppetlabs.com/issues/12843

You can see an example use of this pattern via the "install_options"
parameter in the following type/provider pair:

https://github.com/puppetlabs/puppet/blob/master/lib/puppet/type/package.rb
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/package/msi.rb

Note, however, that this is not generally considered to be an ideal
solution to this sort of problem; I believe we are still honing in on the
best long-term solution for this, so I'm not necessarily recommending this
hash-based approach... but just thought I'd point it out in case it helps
you get unstuck for now.


On Thu, May 3, 2012 at 6:18 PM, Philip Brown <p...@bolthole.com> wrote:

> Hi folks,
>
> I'm trying to write a new provider, to set SMF properties, and I need help
> on a piece of puppet internals syntax.
> I understand(?) that generally speaking when a resource has a KNOWN set of
> property names, for example, "quota" and "readonly", all you have to do to
> properly handle that sort of thing is,
>
> def quota
>   (return value of quota)
> end
> def quota=
>   (set quota to be equal to :name value)
> end
>
> However, I'm trying to write a provider, where the property names are
> free-form.
> From the end user point of view, usage should look something like
>
> ###site.pp
> node somenode{
>   mynewtype { 'svc:/top/level/holder':
>       property => 'funky_holder_switch',
>       value => 'blue_switch'
>   }
> }
> #####
>
> The name of the value in "property" is completely unknown to me at time of
> writing the provider code. it could be literally anything the user chooses.
>
> How can I handle that?
>
>
> For the curious, I already figure that the end result, will be a command
> line that looks like
> svccfg("-s", @resource[:name],"setprop", @resource[:property],"=", :value)
>
>
> I know how to do that backend part. and I've written the front end 'type'
> definition.  I'm just missing the trick of finding the middle layer glue to
> connect the two together :-}
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-dev/-/JBpEd0SYmoMJ.
> To post to this group, send email to puppet-dev@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-dev+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-dev?hl=en.
>

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

Reply via email to