]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: fix isis-topo1 topologies 8626/head
authorIgor Ryzhov <iryzhov@nfware.com>
Wed, 5 May 2021 09:26:07 +0000 (12:26 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 5 May 2021 09:26:38 +0000 (12:26 +0300)
parse_topology function doesn't correctly process vertex types with
spaces. Therefore the reference topology files are completely messed up,
we have values in incorrect fields - types in metrics, metrics in
parents, etc.

This commit fixes the parsing function and the reference files.

The same fix was done for isis-topo1-vrf in #8365.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
tests/topotests/isis-topo1/r1/r1_topology.json
tests/topotests/isis-topo1/r2/r2_topology.json
tests/topotests/isis-topo1/r3/r3_topology.json
tests/topotests/isis-topo1/r4/r4_topology.json
tests/topotests/isis-topo1/r5/r5_topology.json
tests/topotests/isis-topo1/test_isis_topo1.py

index 6d2bbb80c9fb8ce81bc7a94f43bf6c3d871b1e90..337d6bf5ef08ab5b6f6aa51240b6e259e6759af1 100644 (file)
@@ -18,9 +18,9 @@
           "vertex": "r1"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP",
+          "metric": "0",
+          "parent": "r1(4)",
+          "type": "IP internal",
           "vertex": "10.0.20.0/24"
         },
         {
           "vertex": "r3"
         },
         {
-          "interface": "r3",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r1-eth0",
-          "type": "IP",
+          "interface": "r1-eth0",
+          "metric": "10",
+          "next-hop": "r3",
+          "parent": "r3(4)",
+          "type": "IP TE",
           "vertex": "10.0.10.0/24"
         },
         {
-          "interface": "r3",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r1-eth0",
-          "type": "IP",
+          "interface": "r1-eth0",
+          "metric": "10",
+          "next-hop": "r3",
+          "parent": "r3(4)",
+          "type": "IP TE",
           "vertex": "10.0.20.0/24"
         },
         {
-          "interface": "r3",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r1-eth0",
-          "type": "IP",
+          "interface": "r1-eth0",
+          "metric": "10",
+          "next-hop": "r3",
+          "parent": "r3(4)",
+          "type": "IP TE",
           "vertex": "10.254.0.3/32"
         }
       ],
@@ -61,9 +61,9 @@
           "vertex": "r1"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP6",
+          "metric": "0",
+          "parent": "r1(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:1:1::/64"
         },
         {
           "vertex": "r3"
         },
         {
-          "interface": "r3",
-          "next-hop": "10",
-          "parent": "r1-eth0",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r1-eth0",
+          "next-hop": "r3",
+          "parent": "r3(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:2:1::/64"
         },
         {
-          "interface": "r3",
-          "next-hop": "10",
-          "parent": "r1-eth0",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r1-eth0",
+          "next-hop": "r3",
+          "parent": "r3(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:f::3/128"
         }
       ]
index 396c618caa07c4449dc7065154ed04061bf247dd..de90fb5a32d07ba8a083534a66225cd350a30660 100644 (file)
@@ -18,9 +18,9 @@
           "vertex": "r2"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP",
+          "metric": "0",
+          "parent": "r2(4)",
+          "type": "IP internal",
           "vertex": "10.0.21.0/24"
         },
         {
           "vertex": "r4"
         },
         {
-          "interface": "r4",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r2-eth0",
-          "type": "IP",
+          "interface": "r2-eth0",
+          "metric": "10",
+          "next-hop": "r4",
+          "parent": "r4(4)",
+          "type": "IP TE",
           "vertex": "10.0.11.0/24"
         },
         {
-          "interface": "r4",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r2-eth0",
-          "type": "IP",
+          "interface": "r2-eth0",
+          "metric": "10",
+          "next-hop": "r4",
+          "parent": "r4(4)",
+          "type": "IP TE",
           "vertex": "10.0.21.0/24"
         },
         {
-          "interface": "r4",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r2-eth0",
-          "type": "IP",
+          "interface": "r2-eth0",
+          "metric": "10",
+          "next-hop": "r4",
+          "parent": "r4(4)",
+          "type": "IP TE",
           "vertex": "10.254.0.4/32"
         }
       ],
@@ -61,9 +61,9 @@
           "vertex": "r2"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP6",
+          "metric": "0",
+          "parent": "r2(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:1:2::/64"
         },
         {
           "vertex": "r4"
         },
         {
-          "interface": "r4",
-          "next-hop": "10",
-          "parent": "r2-eth0",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r2-eth0",
+          "next-hop": "r4",
+          "parent": "r4(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:2:2::/64"
         },
         {
-          "interface": "r4",
-          "next-hop": "10",
-          "parent": "r2-eth0",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r2-eth0",
+          "next-hop": "r4",
+          "parent": "r4(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:f::4/128"
         }
       ]
index 5ab58c41a63624e5adadddef67b07644da321464..2d36f9b427aa0b845a671a89a0025feeb20dcc18 100644 (file)
@@ -6,9 +6,9 @@
           "vertex": "r3"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP",
+          "metric": "0",
+          "parent": "r3(4)",
+          "type": "IP internal",
           "vertex": "10.0.10.0/24"
         },
         {
           "vertex": "r5"
         },
         {
-          "interface": "r5",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r3-eth1",
-          "type": "IP",
+          "interface": "r3-eth1",
+          "metric": "10",
+          "next-hop": "r5",
+          "parent": "r5(4)",
+          "type": "IP TE",
           "vertex": "10.0.10.0/24"
         },
         {
-          "interface": "r5",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r3-eth1",
-          "type": "IP",
+          "interface": "r3-eth1",
+          "metric": "10",
+          "next-hop": "r5",
+          "parent": "r5(4)",
+          "type": "IP TE",
           "vertex": "10.0.11.0/24"
         },
         {
-          "interface": "r5",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r3-eth1",
-          "type": "IP",
+          "interface": "r3-eth1",
+          "metric": "10",
+          "next-hop": "r5",
+          "parent": "r5(4)",
+          "type": "IP TE",
           "vertex": "10.254.0.5/32"
         },
         {
           "vertex": "r4"
         },
         {
-          "interface": "r5",
-          "metric": "TE",
-          "next-hop": "20",
-          "parent": "r3-eth1",
-          "type": "IP",
+          "interface": "r3-eth1",
+          "metric": "20",
+          "next-hop": "r5",
+          "parent": "r4(4)",
+          "type": "IP TE",
           "vertex": "10.0.21.0/24"
         },
         {
-          "interface": "r5",
-          "metric": "TE",
-          "next-hop": "20",
-          "parent": "r3-eth1",
-          "type": "IP",
+          "interface": "r3-eth1",
+          "metric": "20",
+          "next-hop": "r5",
+          "parent": "r4(4)",
+          "type": "IP TE",
           "vertex": "10.254.0.4/32"
         }
       ],
@@ -72,9 +72,9 @@
           "vertex": "r3"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP6",
+          "metric": "0",
+          "parent": "r3(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:2:1::/64"
         },
         {
           "vertex": "r5"
         },
         {
-          "interface": "r5",
-          "next-hop": "10",
-          "parent": "r3-eth1",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r3-eth1",
+          "next-hop": "r5",
+          "parent": "r5(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:2:2::/64"
         },
         {
-          "interface": "r5",
-          "next-hop": "10",
-          "parent": "r3-eth1",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r3-eth1",
+          "next-hop": "r5",
+          "parent": "r5(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:f::5/128"
         },
         {
           "vertex": "r4"
         },
         {
-          "interface": "r5",
-          "next-hop": "20",
-          "parent": "r3-eth1",
-          "type": "IP6",
+          "metric": "20",
+          "interface": "r3-eth1",
+          "next-hop": "r5",
+          "parent": "r4(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:1:2::/64"
         },
         {
-          "interface": "r5",
-          "next-hop": "20",
-          "parent": "r3-eth1",
-          "type": "IP6",
+          "metric": "20",
+          "interface": "r3-eth1",
+          "next-hop": "r5",
+          "parent": "r4(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:f::4/128"
         }
       ]
           "vertex": "r3"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP",
+          "metric": "0",
+          "parent": "r3(4)",
+          "type": "IP internal",
           "vertex": "10.0.20.0/24"
         },
         {
           "vertex": "r1"
         },
         {
-          "interface": "r1",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r3-eth0",
-          "type": "IP",
+          "interface": "r3-eth0",
+          "metric": "10",
+          "next-hop": "r1",
+          "parent": "r1(4)",
+          "type": "IP TE",
           "vertex": "10.0.20.0/24"
         },
         {
-          "interface": "r1",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r3-eth0",
-          "type": "IP",
+          "interface": "r3-eth0",
+          "metric": "10",
+          "next-hop": "r1",
+          "parent": "r1(4)",
+          "type": "IP TE",
           "vertex": "10.254.0.1/32"
         }
       ],
           "vertex": "r3"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP6",
+          "metric": "0",
+          "parent": "r3(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:1:1::/64"
         },
         {
           "vertex": "r1"
         },
         {
-          "interface": "r1",
-          "next-hop": "10",
-          "parent": "r3-eth0",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r3-eth0",
+          "next-hop": "r1",
+          "parent": "r1(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:f::1/128"
         }
       ]
index ae74a609489a9d523ba3545540625ed23befbfd1..e7d78419127be0dde4362e8e7261aef135213e3f 100644 (file)
@@ -6,9 +6,9 @@
           "vertex": "r4"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP",
+          "metric": "0",
+          "parent": "r4(4)",
+          "type": "IP internal",
           "vertex": "10.0.11.0/24"
         },
         {
           "vertex": "r5"
         },
         {
-          "interface": "r5",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r4-eth1",
-          "type": "IP",
+          "interface": "r4-eth1",
+          "metric": "10",
+          "next-hop": "r5",
+          "parent": "r5(4)",
+          "type": "IP TE",
           "vertex": "10.0.10.0/24"
         },
         {
-          "interface": "r5",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r4-eth1",
-          "type": "IP",
+          "interface": "r4-eth1",
+          "metric": "10",
+          "next-hop": "r5",
+          "parent": "r5(4)",
+          "type": "IP TE",
           "vertex": "10.0.11.0/24"
         },
         {
-          "interface": "r5",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r4-eth1",
-          "type": "IP",
+          "interface": "r4-eth1",
+          "metric": "10",
+          "next-hop": "r5",
+          "parent": "r5(4)",
+          "type": "IP TE",
           "vertex": "10.254.0.5/32"
         },
         {
           "vertex": "r3"
         },
         {
-          "interface": "r5",
-          "metric": "TE",
-          "next-hop": "20",
-          "parent": "r4-eth1",
-          "type": "IP",
+          "interface": "r4-eth1",
+          "metric": "20",
+          "next-hop": "r5",
+          "parent": "r3(4)",
+          "type": "IP TE",
           "vertex": "10.0.20.0/24"
         },
         {
-          "interface": "r5",
-          "metric": "TE",
-          "next-hop": "20",
-          "parent": "r4-eth1",
-          "type": "IP",
+          "interface": "r4-eth1",
+          "metric": "20",
+          "next-hop": "r5",
+          "parent": "r3(4)",
+          "type": "IP TE",
           "vertex": "10.254.0.3/32"
         }
       ],
@@ -72,9 +72,9 @@
           "vertex": "r4"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP6",
+          "metric": "0",
+          "parent": "r4(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:2:2::/64"
         },
         {
           "vertex": "r5"
         },
         {
-          "interface": "r5",
-          "next-hop": "10",
-          "parent": "r4-eth1",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r4-eth1",
+          "next-hop": "r5",
+          "parent": "r5(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:2:1::/64"
         },
         {
-          "interface": "r5",
-          "next-hop": "10",
-          "parent": "r4-eth1",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r4-eth1",
+          "next-hop": "r5",
+          "parent": "r5(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:f::5/128"
         },
         {
           "vertex": "r3"
         },
         {
-          "interface": "r5",
-          "next-hop": "20",
-          "parent": "r4-eth1",
-          "type": "IP6",
+          "metric": "20",
+          "interface": "r4-eth1",
+          "next-hop": "r5",
+          "parent": "r3(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:1:1::/64"
         },
         {
-          "interface": "r5",
-          "next-hop": "20",
-          "parent": "r4-eth1",
-          "type": "IP6",
+          "metric": "20",
+          "interface": "r4-eth1",
+          "next-hop": "r5",
+          "parent": "r3(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:f::3/128"
         }
       ]
           "vertex": "r4"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP",
+          "metric": "0",
+          "parent": "r4(4)",
+          "type": "IP internal",
           "vertex": "10.0.21.0/24"
         },
         {
           "vertex": "r2"
         },
         {
-          "interface": "r2",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r4-eth0",
-          "type": "IP",
+          "interface": "r4-eth0",
+          "metric": "10",
+          "next-hop": "r2",
+          "parent": "r2(4)",
+          "type": "IP TE",
           "vertex": "10.0.21.0/24"
         },
         {
-          "interface": "r2",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r4-eth0",
-          "type": "IP",
+          "interface": "r4-eth0",
+          "metric": "10",
+          "next-hop": "r2",
+          "parent": "r2(4)",
+          "type": "IP TE",
           "vertex": "10.254.0.2/32"
         }
       ],
           "vertex": "r4"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP6",
+          "metric": "0",
+          "parent": "r4(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:1:2::/64"
         },
         {
           "vertex": "r2"
         },
         {
-          "interface": "r2",
-          "next-hop": "10",
-          "parent": "r4-eth0",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r4-eth0",
+          "next-hop": "r2",
+          "parent": "r2(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:f::2/128"
         }
       ]
index 0224661411b434bd71f484e5e9690dfe9bd4e851..3d887b7cea69e6196641584a444a24e4c5118841 100644 (file)
@@ -6,15 +6,15 @@
           "vertex": "r5"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP",
+          "metric": "0",
+          "parent": "r5(4)",
+          "type": "IP internal",
           "vertex": "10.0.10.0/24"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP",
+          "metric": "0",
+          "parent": "r5(4)",
+          "type": "IP internal",
           "vertex": "10.0.11.0/24"
         },
         {
           "vertex": "r4"
         },
         {
-          "interface": "r3",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r5-eth0",
-          "type": "IP",
+          "interface": "r5-eth0",
+          "metric": "10",
+          "next-hop": "r3",
+          "parent": "r3(4)",
+          "type": "IP TE",
           "vertex": "10.0.10.0/24"
         },
         {
-          "interface": "r3",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r5-eth0",
-          "type": "IP",
+          "interface": "r5-eth0",
+          "metric": "10",
+          "next-hop": "r3",
+          "parent": "r3(4)",
+          "type": "IP TE",
           "vertex": "10.0.20.0/24"
         },
         {
-          "interface": "r3",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r5-eth0",
-          "type": "IP",
+          "interface": "r5-eth0",
+          "metric": "10",
+          "next-hop": "r3",
+          "parent": "r3(4)",
+          "type": "IP TE",
           "vertex": "10.254.0.3/32"
         },
         {
-          "interface": "r4",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r5-eth1",
-          "type": "IP",
+          "interface": "r5-eth1",
+          "metric": "10",
+          "next-hop": "r4",
+          "parent": "r4(4)",
+          "type": "IP TE",
           "vertex": "10.0.11.0/24"
         },
         {
-          "interface": "r4",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r5-eth1",
-          "type": "IP",
+          "interface": "r5-eth1",
+          "metric": "10",
+          "next-hop": "r4",
+          "parent": "r4(4)",
+          "type": "IP TE",
           "vertex": "10.0.21.0/24"
         },
         {
-          "interface": "r4",
-          "metric": "TE",
-          "next-hop": "10",
-          "parent": "r5-eth1",
-          "type": "IP",
+          "interface": "r5-eth1",
+          "metric": "10",
+          "next-hop": "r4",
+          "parent": "r4(4)",
+          "type": "IP TE",
           "vertex": "10.254.0.4/32"
         }
       ],
           "vertex": "r5"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP6",
+          "metric": "0",
+          "parent": "r5(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:2:1::/64"
         },
         {
-          "metric": "internal",
-          "parent": "0",
-          "type": "IP6",
+          "metric": "0",
+          "parent": "r5(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:2:2::/64"
         },
         {
           "vertex": "r4"
         },
         {
-          "interface": "r3",
-          "next-hop": "10",
-          "parent": "r5-eth0",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r5-eth0",
+          "next-hop": "r3",
+          "parent": "r3(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:1:1::/64"
         },
         {
-          "interface": "r3",
-          "next-hop": "10",
-          "parent": "r5-eth0",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r5-eth0",
+          "next-hop": "r3",
+          "parent": "r3(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:f::3/128"
         },
         {
-          "interface": "r4",
-          "next-hop": "10",
-          "parent": "r5-eth1",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r5-eth1",
+          "next-hop": "r4",
+          "parent": "r4(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:1:2::/64"
         },
         {
-          "interface": "r4",
-          "next-hop": "10",
-          "parent": "r5-eth1",
-          "type": "IP6",
+          "metric": "10",
+          "interface": "r5-eth1",
+          "next-hop": "r4",
+          "parent": "r4(4)",
+          "type": "IP6 internal",
           "vertex": "2001:db8:f::4/128"
         }
       ]
index e7618c7bce7ebce7b495904624ff6886ec8526dc..083a8b1e8d659490edfa7287db464218bf259dcb 100644 (file)
@@ -47,6 +47,20 @@ from mininet.topo import Topo
 
 pytestmark = [pytest.mark.isisd]
 
+VERTEX_TYPE_LIST = [
+    "pseudo_IS",
+    "pseudo_TE-IS",
+    "IS",
+    "TE-IS",
+    "ES",
+    "IP internal",
+    "IP external",
+    "IP TE",
+    "IP6 internal",
+    "IP6 external",
+    "UNKNOWN",
+]
+
 
 class ISISTopo1(Topo):
     "Simple two layer ISIS topology"
@@ -263,6 +277,7 @@ def parse_topology(lines, level):
     areas = {}
     area = None
     ipv = None
+    vertex_type_regex = "|".join(VERTEX_TYPE_LIST)
 
     for line in lines:
         area_match = re.match(r"Area (.+):", line)
@@ -282,44 +297,57 @@ def parse_topology(lines, level):
             ipv = "ipv4"
             continue
 
-        item_match = re.match(r"([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+)", line)
-        if item_match is not None:
+        item_match = re.match(
+            r"([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+) ([^\s]+)", line
+        )
+        if (
+            item_match is not None
+            and item_match.group(1) == "Vertex"
+            and item_match.group(2) == "Type"
+            and item_match.group(3) == "Metric"
+            and item_match.group(4) == "Next-Hop"
+            and item_match.group(5) == "Interface"
+            and item_match.group(6) == "Parent"
+        ):
             # Skip header
-            if (
-                item_match.group(1) == "Vertex"
-                and item_match.group(2) == "Type"
-                and item_match.group(3) == "Metric"
-                and item_match.group(4) == "Next-Hop"
-                and item_match.group(5) == "Interface"
-                and item_match.group(6) == "Parent"
-            ):
-                continue
+            continue
 
+        item_match = re.match(
+            r"([^\s]+) ({}) ([0]|([1-9][0-9]*)) ([^\s]+) ([^\s]+) ([^\s]+)".format(
+                vertex_type_regex
+            ),
+            line,
+        )
+        if item_match is not None:
             areas[area][level][ipv].append(
                 {
                     "vertex": item_match.group(1),
                     "type": item_match.group(2),
                     "metric": item_match.group(3),
-                    "next-hop": item_match.group(4),
-                    "interface": item_match.group(5),
-                    "parent": item_match.group(6),
+                    "next-hop": item_match.group(5),
+                    "interface": item_match.group(6),
+                    "parent": item_match.group(7),
                 }
             )
             continue
 
-        item_match = re.match(r"([^ ]+) ([^ ]+) ([^ ]+) ([^ ]+)", line)
+        item_match = re.match(
+            r"([^\s]+) ({}) ([0]|([1-9][0-9]*)) ([^\s]+)".format(vertex_type_regex),
+            line,
+        )
+
         if item_match is not None:
             areas[area][level][ipv].append(
                 {
                     "vertex": item_match.group(1),
                     "type": item_match.group(2),
                     "metric": item_match.group(3),
-                    "parent": item_match.group(4),
+                    "parent": item_match.group(5),
                 }
             )
             continue
 
-        item_match = re.match(r"([^ ]+)", line)
+        item_match = re.match(r"([^\s]+)", line)
         if item_match is not None:
             areas[area][level][ipv].append({"vertex": item_match.group(1)})
             continue