Puppet Function: validate_vni_ranges
- Defined in:
-
lib/puppet/parser/functions/validate_vni_ranges.rb
- Function type:
- Ruby 3.x API
Overview
validate_vni_ranges() ⇒ Any
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/puppet/parser/functions/validate_vni_ranges.rb', line 23
newfunction(:validate_vni_ranges) do |args|
value = args[0]
if not value.kind_of?(Array)
value = [value]
end
value.each do |range|
if m = /^(\d+):(\d+)$/.match(range)
first_id = Integer(m[1])
second_id = Integer(m[2])
if not (0 <= first_id && first_id <= 16777215)
raise Puppet::Error, "vni ranges are invalid."
end
if not (0 <= second_id && second_id <= 16777215)
raise Puppet::Error, "vni ranges are invalid."
end
if (second_id < first_id)
raise Puppet::Error, "vni ranges are invalid."
end
elsif range
raise Puppet::Error, "vni ranges are invalid."
end
end
end
|