From 8f1f0e9da6967319c044d410cc10f144659cc0ef Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 30 May 2020 11:21:15 +0200 Subject: vrf: T2530: instance name must be 15 characters or less --- interface-definitions/vrf.xml.in | 2 +- src/validators/vrf-name | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/interface-definitions/vrf.xml.in b/interface-definitions/vrf.xml.in index 7c75bf824..9b9828ddd 100644 --- a/interface-definitions/vrf.xml.in +++ b/interface-definitions/vrf.xml.in @@ -19,7 +19,7 @@ - VRF instance name must be 16 characters or less and can not\nbe named as regular network interfaces + VRF instance name must be 15 characters or less and can not\nbe named as regular network interfaces.\n name Instance name diff --git a/src/validators/vrf-name b/src/validators/vrf-name index 878893c46..7b6313888 100755 --- a/src/validators/vrf-name +++ b/src/validators/vrf-name @@ -14,30 +14,28 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . - import re -import sys - +from sys import argv, exit if __name__ == '__main__': - if len(sys.argv) != 2: - sys.exit(1) + if len(argv) != 2: + exit(1) - vrf = sys.argv[1] + vrf = argv[1] length = len(vrf) - if length not in range(1, 17): - sys.exit('VRF instance name must be 16 characters or less') + if length not in range(1, 16): + exit(1) # Treat loopback interface "lo" explicitly. Adding "lo" explicitly to the # following regex pattern would deny any VRF name starting with lo - thuse # local-vrf would be illegal - and that we do not want. if vrf == "lo": - exit(f'"{vrf}" is invalid as VRF name as it is an interface name') + exit(1) pattern = "^(?!(bond|br|dum|eth|lan|eno|ens|enp|enx|gnv|ipoe|l2tp|l2tpeth|" \ "vtun|ppp|pppoe|peth|tun|vti|vxlan|wg|wlan|wlm)\d+(\.\d+(v.+)?)?$).*$" if not re.match(pattern, vrf): - sys.exit(f'"{vrf}" is invalid as VRF name as it is an interface name') + exit(1) - sys.exit(0) + exit(0) -- cgit v1.2.3