25b711032d91bb1c7f45aba12770940bcacf10a6
[mirror/dsa-puppet.git] / 3rdparty / modules / neutron / lib / puppet / parser / functions / validate_vxlan_udp_port.rb
1 #
2 # Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 #         Martin Magr <mmagr@redhat.com>
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License"); you may
8 # not use this file except in compliance with the License. You may obtain
9 # a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16 # License for the specific language governing permissions and limitations
17 # under the License.
18 #
19 # Advanced validation for VXLAN UDP port configuration
20 #
21
22 module Puppet::Parser::Functions
23   newfunction(:validate_vxlan_udp_port) do |args|
24     value = Integer(args[0])
25
26     # check if port is either default value or one of the private ports
27     # according to http://tools.ietf.org/html/rfc6056
28     if value != 4789 or (49151 >= value and value > 65535)
29       raise Puppet::Error, "vxlan udp port is invalid."
30     end
31   end
32 end