diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-05-30 11:21:15 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-05-30 11:21:15 +0200 |
commit | 8f1f0e9da6967319c044d410cc10f144659cc0ef (patch) | |
tree | b0692a064bf73b0955d3123dec729b601bb98ad0 /src/validators | |
parent | 5096a7cd4c4579ce32fa27b0a5025ce1e8660474 (diff) | |
download | vyos-1x-8f1f0e9da6967319c044d410cc10f144659cc0ef.tar.gz vyos-1x-8f1f0e9da6967319c044d410cc10f144659cc0ef.zip |
vrf: T2530: instance name must be 15 characters or less
Diffstat (limited to 'src/validators')
-rwxr-xr-x | src/validators/vrf-name | 20 |
1 files changed, 9 insertions, 11 deletions
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 <http://www.gnu.org/licenses/>. - 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) |