summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface-definitions/vrf.xml.in2
-rwxr-xr-xsrc/validators/vrf-name20
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 @@
<constraint>
<validator name="vrf-name"/>
</constraint>
- <constraintErrorMessage>VRF instance name must be 16 characters or less and can not\nbe named as regular network interfaces</constraintErrorMessage>
+ <constraintErrorMessage>VRF instance name must be 15 characters or less and can not\nbe named as regular network interfaces.\n</constraintErrorMessage>
<valueHelp>
<format>name</format>
<description>Instance name</description>
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)