Hey Josh, thanks for the reply. I'm still struggling with this. I have a hash of the values passed in from the manifest with the keys including '_' which need to be re-written.
properties => {'john_wayne' => '1', 'liberty_valance' => '0', ...} this needs to become: properties => {'john-wayne' => '1', 'liberty-valance' => '0', ...} I believe this is where they are defined in my type: newproperty(:properties) do desc "A hash table of propname=propvalue entries to apply to the link" end So, I should write a method in the type to re-write the keys? Something like (forgive my ruby too): def modify_keys(h) h.keys.each do |k| if(k.include? '_') then h[k.gsub(/_/, '-')] = h[k] h.delete(k) end end end Can I add a method like this to my property? How is such a method then called in the provider? Thanks, Geoffrey On Monday, December 1, 2014 11:09:47 PM UTC-7, Josh Cooper wrote: > > > > On Mon, Dec 1, 2014 at 9:06 PM, Geoffrey Gardella <gard...@gmail.com > <javascript:>> wrote: > >> I am working on updating types/providers for new functionality in >> Solaris. I need to take a list of properties (not their values) and modify >> them before any operations (checking current values, etc). Specifically, I >> will need to substitute '-' for '_' in the property names. What is the >> proper place for me to do this? In the provider or type? I am very new to >> Puppet, and don't want to implement a solution that isn't done the right >> way. >> >> I know I'm being a bit vague, but this is in response to functional >> changes in Solaris, which aren't even integrated yet. >> > > Assuming this is a static list of properties, then you would define the > list of properties in the type, e.g. newproperty(:property_one), and then > define getter and setters in the provider: > > def property_one > # retrieve the value > end > > def property_one=(value) > # set the new value > end > > That assumes each property can be independently managed. If you need both > property_one and property_two to be set before you apply the changes to the > underlying native resource, then you'd want the setters to store the new > values: > > def property_one=(value) > @one = value > end > > def property_two=(value) > @two = value > end > > and implement a `flush` method to update the resource with all of the new > values. > > def flush > # save resource using @one & @two > end > > Josh > > -- > Josh Cooper > Developer, Puppet Labs > > *Join us at **PuppetConf 2015, October 5-9 in Portland, OR - * > http://2015.puppetconf.com. > *Register early to save 40%!* > -- 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 puppet-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/ad0a3285-aa79-4761-8110-679155d9aac3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.