On Friday, September 7, 2012 8:04:57 AM UTC-5, Jakov Sosic wrote:
>
> On 09/05/2012 08:07 PM, Jakov Sosic wrote:
> > newparam(:destdir) do
> > desc "The link of the distro ISO image."
> > validate do |value|
> > unless Pathname.new(value).absolute?
> > raise ArgumentError, "Full pathname must be set"
> > end
> > end
> > end
>
>
> > cobblerdistro {'CentOS-6.3-x86_64':
> > ensure => absent,
> > destdir => '/distro',
> > }
>
>
>
> Maybe I didn't make my self clear enough.... On a puppet run, if the
> resource doesn't have destdir defined, i get this error:
>
> err:
> /Stage[main]//Node[sunce.srce.hr]/Cobbler::Add_distro[CentOS-6.3-x86_64]/Cobblerdistro[CentOS-6.3-x86_64]:
>
>
> Could not evaluate: undefined method `+' for nil:NilClass
>
> I would like to inform user what the problem is rather then print out
> some obscure message like this one.
>
> So, how can I do this from type definition ruby code? Thank you.
>
You cannot use the parameter validation hook for this because it is invoked
only when a value is set. The case you want to trap is exactly the case to
which that hook does not apply.
As far as I know or can tell, there is no hook for what you want --
basically, whole-resource validation. You can put the validation code into
your provider(s), at the point where you (first) use the value. That's not
ideal, but it can get you a better error message (albeit issued on the
client side, not the master).
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/UDMxli5gn7QJ.
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-users?hl=en.