Skip to content

Commit 9ffb095

Browse files
authored
Merge pull request #949 from netenglabs/fix-route-action-protocol
Fix route action protocol
2 parents 00153e5 + 9db881d commit 9ffb095

File tree

21 files changed

+10110
-9366
lines changed

21 files changed

+10110
-9366
lines changed

suzieq/engines/pandas/routes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def _cons_addnl_fields(self, columns: List[str], addnl_fields: List[str],
3535

3636
return addnl_fields
3737

38+
# pylint: disable=too-many-statements
3839
def get(self, **kwargs):
3940
'''Return the routes table for the given filters'''
4041

@@ -95,9 +96,12 @@ def get(self, **kwargs):
9596
query_str = f'prefixlen != {prefixlen[1:]}'
9697
else:
9798
query_str = f'prefixlen == {prefixlen}'
98-
9999
# drop in reset_index to not add an additional index col
100100
df = df.query(query_str).reset_index(drop=True)
101+
if 'protocol' in df:
102+
df['protocol'] = df.protocol.replace('direct', 'connected')
103+
if 'action' in df:
104+
df['action'] = df.action.replace('local', 'forward')
101105

102106
if 'numNexthops' in columns or (columns == ['*']):
103107
srs_oif = df['oifs'].str.len()

suzieq/poller/worker/services/routes.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ def _clean_junos_data(self, processed_data, raw_data):
133133
drop_entries_idx.append(i)
134134
continue
135135

136+
if entry.get('protocol', '') == 'direct':
137+
entry['protocol'] = 'connected'
136138
vrf = entry.pop("vrf")[0]['data']
137139
if vrf == "inet.0":
138140
vrf = "default"
@@ -253,6 +255,17 @@ def _clean_nxos_data(self, processed_data, raw_data):
253255
else:
254256
entry['statusChangeTimestamp'] = 0
255257

258+
if (protocol := entry.get('protocol', '')) == 'bgp':
259+
rt_tag = entry.get('routeTag', [])
260+
if isinstance(rt_tag, str):
261+
# This is for older versions of NXOS
262+
entry['asPathList'] = re.findall(r'\d+', rt_tag)
263+
else:
264+
entry['asPathList'] = rt_tag or []
265+
266+
if protocol == 'direct':
267+
entry['protocol'] = 'connected'
268+
256269
self._fix_ipvers(entry)
257270

258271
processed_data = np.delete(processed_data, drop_indices).tolist()

tests/integration/sqcmds/common-samples/all.yml

Lines changed: 1247 additions & 1238 deletions
Large diffs are not rendered by default.

tests/integration/sqcmds/common-samples/not.yml

Lines changed: 2848 additions & 2817 deletions
Large diffs are not rendered by default.

tests/integration/sqcmds/eos-samples/all.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6063,8 +6063,8 @@ tests:
60636063
1, "routeTag": "", "asPathList": [], "validState": "", "hardwareProgrammed": "unknown",
60646064
"metric": 20, "statusChangeTimestamp": 0, "active": true}, {"namespace": "eos",
60656065
"hostname": "dcedge01", "vrf": "default", "prefix": "10.0.0.41/32", "nexthopIps":
6066-
[], "oifs": ["lo0.0"], "protocol": "direct", "source": "", "preference": 0, "ipvers":
6067-
4, "action": "forward", "timestamp": 1623025176627, "weights": [], "prefixlen":
6066+
[], "oifs": ["lo0.0"], "protocol": "connected", "source": "", "preference": 0,
6067+
"ipvers": 4, "action": "forward", "timestamp": 1623025176627, "weights": [], "prefixlen":
60686068
32, "numNexthops": 1, "routeTag": "", "asPathList": [], "validState": "", "hardwareProgrammed":
60696069
"unknown", "metric": 0, "statusChangeTimestamp": 1620676278627, "active": true},
60706070
{"namespace": "eos", "hostname": "dcedge01", "vrf": "default", "prefix": "10.0.0.200/32",
@@ -6074,28 +6074,28 @@ tests:
60746074
["65522", "65533", "?"], "validState": "unverified", "hardwareProgrammed": "unknown",
60756075
"metric": 0, "statusChangeTimestamp": 1620677002627, "active": true}, {"namespace":
60766076
"eos", "hostname": "dcedge01", "vrf": "default", "prefix": "10.255.2.0/24", "nexthopIps":
6077-
[], "oifs": ["em0.0"], "protocol": "direct", "source": "", "preference": 0, "ipvers":
6078-
4, "action": "forward", "timestamp": 1623025176627, "weights": [], "prefixlen":
6077+
[], "oifs": ["em0.0"], "protocol": "connected", "source": "", "preference": 0,
6078+
"ipvers": 4, "action": "forward", "timestamp": 1623025176627, "weights": [], "prefixlen":
60796079
24, "numNexthops": 1, "routeTag": "", "asPathList": [], "validState": "", "hardwareProgrammed":
60806080
"unknown", "metric": 0, "statusChangeTimestamp": 1620675831627, "active": true},
60816081
{"namespace": "eos", "hostname": "dcedge01", "vrf": "default", "prefix": "10.255.2.250/32",
60826082
"nexthopIps": [], "oifs": ["em0.0"], "protocol": "local", "source": "", "preference":
6083-
0, "ipvers": 4, "action": "local", "timestamp": 1623025176627, "weights": [],
6083+
0, "ipvers": 4, "action": "forward", "timestamp": 1623025176627, "weights": [],
60846084
"prefixlen": 32, "numNexthops": 1, "routeTag": "", "asPathList": [], "validState":
60856085
"", "hardwareProgrammed": "unknown", "metric": 0, "statusChangeTimestamp": 1620675831627,
60866086
"active": true}, {"namespace": "eos", "hostname": "dcedge01", "vrf": "default",
6087-
"prefix": "169.254.0.0/24", "nexthopIps": [], "oifs": ["em1.0"], "protocol": "direct",
6087+
"prefix": "169.254.0.0/24", "nexthopIps": [], "oifs": ["em1.0"], "protocol": "connected",
60886088
"source": "", "preference": 0, "ipvers": 4, "action": "forward", "timestamp":
60896089
1623025176627, "weights": [], "prefixlen": 24, "numNexthops": 1, "routeTag": "",
60906090
"asPathList": [], "validState": "", "hardwareProgrammed": "unknown", "metric":
60916091
0, "statusChangeTimestamp": 1620675821627, "active": true}, {"namespace": "eos",
60926092
"hostname": "dcedge01", "vrf": "default", "prefix": "169.254.0.2/32", "nexthopIps":
60936093
[], "oifs": ["em1.0"], "protocol": "local", "source": "", "preference": 0, "ipvers":
6094-
4, "action": "local", "timestamp": 1623025176627, "weights": [], "prefixlen":
6094+
4, "action": "forward", "timestamp": 1623025176627, "weights": [], "prefixlen":
60956095
32, "numNexthops": 1, "routeTag": "", "asPathList": [], "validState": "", "hardwareProgrammed":
60966096
"unknown", "metric": 0, "statusChangeTimestamp": 1620675821627, "active": true},
60976097
{"namespace": "eos", "hostname": "dcedge01", "vrf": "default", "prefix": "169.254.127.0/31",
6098-
"nexthopIps": [], "oifs": ["xe-0/0/0.0"], "protocol": "direct", "source": "",
6098+
"nexthopIps": [], "oifs": ["xe-0/0/0.0"], "protocol": "connected", "source": "",
60996099
"preference": 0, "ipvers": 4, "action": "forward", "timestamp": 1623025176627,
61006100
"weights": [], "prefixlen": 31, "numNexthops": 1, "routeTag": "", "asPathList":
61016101
[], "validState": "", "hardwareProgrammed": "unknown", "metric": 0, "statusChangeTimestamp":
@@ -6107,13 +6107,13 @@ tests:
61076107
"I"], "validState": "unverified", "hardwareProgrammed": "unknown", "metric": 0,
61086108
"statusChangeTimestamp": 1620699310627, "active": true}, {"namespace": "eos",
61096109
"hostname": "dcedge01", "vrf": "default", "prefix": "169.254.127.2/31", "nexthopIps":
6110-
[], "oifs": ["xe-0/0/1.0"], "protocol": "direct", "source": "", "preference":
6110+
[], "oifs": ["xe-0/0/1.0"], "protocol": "connected", "source": "", "preference":
61116111
0, "ipvers": 4, "action": "forward", "timestamp": 1623025176627, "weights": [],
61126112
"prefixlen": 31, "numNexthops": 1, "routeTag": "", "asPathList": [], "validState":
61136113
"", "hardwareProgrammed": "unknown", "metric": 0, "statusChangeTimestamp": 1620676707627,
61146114
"active": true}, {"namespace": "eos", "hostname": "dcedge01", "vrf": "default",
61156115
"prefix": "169.254.127.2/32", "nexthopIps": [], "oifs": ["xe-0/0/1.0"], "protocol":
6116-
"local", "source": "", "preference": 0, "ipvers": 4, "action": "local", "timestamp":
6116+
"local", "source": "", "preference": 0, "ipvers": 4, "action": "forward", "timestamp":
61176117
1623025176627, "weights": [], "prefixlen": 32, "numNexthops": 1, "routeTag": "",
61186118
"asPathList": [], "validState": "", "hardwareProgrammed": "unknown", "metric":
61196119
0, "statusChangeTimestamp": 1620676707627, "active": true}, {"namespace": "eos",
@@ -6130,7 +6130,7 @@ tests:
61306130
"65533", "65521", "I"], "validState": "unverified", "hardwareProgrammed": "unknown",
61316131
"metric": 0, "statusChangeTimestamp": 1620700001627, "active": true}, {"namespace":
61326132
"eos", "hostname": "dcedge01", "vrf": "default", "prefix": "fe80::205:860f:fc71:f000/128",
6133-
"nexthopIps": [], "oifs": ["lo0.0"], "protocol": "direct", "source": "", "preference":
6133+
"nexthopIps": [], "oifs": ["lo0.0"], "protocol": "connected", "source": "", "preference":
61346134
0, "ipvers": 6, "action": "forward", "timestamp": 1623025176627, "weights": [],
61356135
"prefixlen": 128, "numNexthops": 1, "routeTag": "", "asPathList": [], "validState":
61366136
"", "hardwareProgrammed": "unknown", "metric": 0, "statusChangeTimestamp": 1620675822627,
@@ -6141,7 +6141,7 @@ tests:
61416141
[], "validState": "", "hardwareProgrammed": "unknown", "metric": 0, "statusChangeTimestamp":
61426142
1620675816627, "active": true}, {"namespace": "eos", "hostname": "dcedge01", "vrf":
61436143
"default", "prefix": "169.254.127.0/32", "nexthopIps": [], "oifs": ["xe-0/0/0.0"],
6144-
"protocol": "local", "source": "", "preference": 0, "ipvers": 4, "action": "local",
6144+
"protocol": "local", "source": "", "preference": 0, "ipvers": 4, "action": "forward",
61456145
"timestamp": 1623025176627, "weights": [], "prefixlen": 32, "numNexthops": 1,
61466146
"routeTag": "", "asPathList": [], "validState": "", "hardwareProgrammed": "unknown",
61476147
"metric": 0, "statusChangeTimestamp": 1620676700627, "active": true}, {"namespace":

tests/integration/sqcmds/eos-samples/path.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,9 @@ tests:
916916
- command: path summarize --dest=172.16.3.202 --src=172.16.1.101 --format=json --namespace=eos
917917
data-directory: tests/data/parquet/
918918
marks: path summarize eos
919-
output: '[{"eos": 8}, {"eos": [2, 2, 2, 1]}, {"eos": 4}, {"eos": 4.0}, {"eos": 8},
920-
{"eos": 1500}, {"eos": true}, {"eos": true}]'
919+
output: '{"eos": {"totalPaths": 8, "perHopEcmp": [2, 2, 2, 1], "maxPathLength":
920+
4, "avgPathLength": 4.0, "uniqueDevices": 8, "pathMtu": 1500, "usesOverlay": true,
921+
"mtuMismatch": true}}'
921922
- command: path summarize --dest=10.0.0.11 --src=10.0.0.14 --format=json --namespace=eos
922923
data-directory: tests/data/parquet/
923924
marks: path summarize eos

0 commit comments

Comments
 (0)