5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/puppet/util/host_list_prop.rb', line 5
def newhostlistprop(name, options = {}, &block)
options[:array_matching] ||= :all
newproperty(name, options) do
include Puppet::Util::NetworkDevice::IPCalc
validate do |values|
values = [values].flatten.sort
values.each do |value|
self.fail "Invalid IP Address: #{value.inspect}" unless parse(value)
end
end
munge do |value|
parse(value)[1]
end
def insync?(is)
self.devfail "#{self.class.name}'s should is not array" unless @should.is_a?(Array)
return ([is].flatten.sort == [@should].flatten.sort || [is].flatten.sort == [@should].flatten.map(&:to_s).sort)
end
def value_to_s(value)
value = [value].flatten.sort
value.map{ |v| "#{v}"}.join(",")
end
def change_to_s(currentvalue, newvalue)
currentvalue = value_to_s(currentvalue) if currentvalue != :absent
newvalue = value_to_s(newvalue)
super(currentvalue, newvalue)
end
class_eval(&block) if block
end
end
|