Hi,

I think you should direct those e-mails to the puppet-dev mailing list,
you'll get certainly more answers there.

Also, I didn't closely read your previous posts about the NetApp
provider you're writing, but let just me say that's awesome!

On Mon, 2012-11-12 at 05:16 -0800, Gavin Williams wrote:
> Afternoon all... 
> 
> I'm trying to use Munge in a custom Puppet type to set the param value
> to that of another param if the current value is null...
> 
> Code I've got is:
> 
>         Puppet::Type.newtype(:netapp_export) do
>           @doc = "Manage Netapp NFS Export creation, modification and
>         deletion."
>         
>           apply_to_device
>         
>           ensurable do
>             desc "Netapp NFS Export resource state. Valid values are:
>         present, absent."
>         
>             defaultto(:present)
>         
>             newvalue(:present) do
>               provider.create
>             end
>         
>             newvalue(:absent) do
>               provider.destroy
>             end
>           end
>         
>           newparam(:name) do
>             desc "The export name."
>             isnamevar
>           end
>         
>           newparam(:persistent) do
>             desc "Persistent export?"
>             newvalues(:true, :false)
>             defaultto(:true)
>           end
>         
>           newparam(:path) do
>             desc "The filer path to export."
>             Puppet.debug("Validating path param.")
>             munge do |value|
>               if value.nil?
>                 Puppet.debug("path param is nil. Setting to
>         #{@resource[:name]}")
>                 resource[:name]
>               else
>                 Puppet.debug("path param is not nil.")
>               end
>             end
>             #Puppet.debug("path value is: #{@resource[:path]}.")
>           end
>         
>         end
>         
> 
> However I'm not having any success with the above. 

Well, what kind of error or output do you get?

> Any ideas???

Isn't it better to use a defaultto, like this:

defaultto { @resource[:name] }

(That's what I did in the network device interface type, and it was
working)
-- 
Brice Figureau
Follow the latest Puppet Community evolutions on www.planetpuppet.org!

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