I've also updated the ticket, but it looks like this patch got
stalled.  Brian, could you update the ticket status to let us know the
state of this patch?  It looks like Luke +1'd the idea but had a few
suggested improvements.

On Tue, Aug 31, 2010 at 11:04 AM, Luke Kanies <[email protected]> wrote:
> On Aug 26, 2010, at 3:08 PM, [email protected] wrote:
>
>> This addresses Redmine ticket #4020.
>>
>> Currently, the Nagios types default to :array_matching=>:first.  That
>> is a problem if you want to have, say, multiple systems in a
>> hostgroup.  This patch will enable array_matching=>:all, along with
>> the requisite helper functions for file verification.  This patch is
>> against Puppet 0.25.5.
>
> This is a good idea.
>
>> --- puppet-0.25.5/lib/puppet/util/nagios_maker.rb       Thu Aug 26
>> 13:14:52 2010
>> +++ /var/opt/webstack/ruby/1.8/gem_home/gems/puppet-0.25.5/lib/puppet/
>> util/nagios_maker.rb      Thu Aug 26 13:22:56 2010
>
> Any chance you can do the diff against the git repo?  We can handle this 
> commit if not, but it'd be helpful.
>
>> @@ -27,10 +27,49 @@
>>             # supported.
>>             next if param.to_s =~ /^[0-9]/
>>
>> -            type.newproperty(param) do
>> -                desc "Nagios configuration file parameter."
>> +           type.newproperty(param, :array_matching => :all) do
>> +               desc "Nagios array-capable configuration file
>> parameter."
>> +               def change_to_s(currentvalue, newvalue)
>> +                   currentvalue = currentvalue.join(",") if
>> currentvalue != :absent and currentvalue.is_a?(Array)
>> +                   currentvalue = currentvalue.to_s() if
>> currentvalue.is_a?(Symbol)
>> +                   newvalue = newvalue.join(",") if newvalue.is_a?
>> (Array)
>> +                   newvalue = newvalue.to_s() if newvalue.is_a?
>> (Symbol)
>> +                   super(currentvalue, newvalue)
>>             end
>> +
>> +               def is_to_s(value)
>> +                   if value.is_a?(Array)
>> +                       if value.include?(:absent)
>> +                           super
>> +                       else
>> +                           super(value.join(','))
>>         end
>> +                   else
>> +                       super(value.to_s())
>> +                   end
>> +               end
>> +
>> +               def should_to_s(value)
>> +                   if value.is_a?(Array)
>> +                       if value.include?(:absent)
>> +                           super
>> +                       else
>> +                           super(value.join(','))
>> +                       end
>> +                   else
>> +                       super(value.to_s())
>> +                   end
>> +               end
>> +
>> +               def insync?(is)
>> +                   if defined? @should and @should
>
> You shouldn't need this any more - the 'insync?' method shouldn't be called 
> if @should is nil.
>
>> +                       self.is_to_s(is) == self.should_to_s(@should)
>
> This won't quite work, assuming that order doesn't matter for groups.  This 
> would consider 'a,b' to not be equal to 'b,a', but my guess it that they're 
> actually equal for the purposes of Nagios, right?
>
> I'd recommend something like:
>
> def insync?(is)
> �[email protected] == is.sort
> end
>
> This only works if all of the values are strings or integers, but that should 
> be the case here.
>
>> +                   else
>> +                       false
>> +                   end
>> +               end
>> +           end
>> +       end
>
>
>
> --
> Every generation laughs at the old fashions, but follows religiously
> the new.        -- Henry David Thoreau
> ---------------------------------------------------------------------
> 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.
>
>

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