Browse Source

Fix order of IP check.

Joe Clarke 4 years ago
parent
commit
9fec690fbd
1 changed files with 5 additions and 4 deletions
  1. 5 4
      automation/cleu-ansible-n9k/add_vlan.py

+ 5 - 4
automation/cleu-ansible-n9k/add_vlan.py

@@ -159,15 +159,16 @@ def main():
 
     if args.svi_v4_network:
         m = re.match(r"(\d+)\.(\d+)\.(\d+).(\d+)", args.svi_v4_network)
-        for i in range(1, 5):
-            if int(m.group(i)) > 255:
-                print("ERROR: Invalid SVI IPv4 address, {}".format(args.svi_v4_network))
-                sys.exit(1)
 
         if not m:
             print("ERROR: SVI Network must be an IPv4 network address.")
             sys.exit(1)
 
+        for i in range(1, 5):
+            if int(m.group(i)) > 255:
+                print("ERROR: Invalid SVI IPv4 address, {}".format(args.svi_v4_network))
+                sys.exit(1)
+
         if not args.svi_subnet_len:
             print("ERROR: SVI Prefix Length is required when an SVI Network is specified.")
             sys.exit(1)