Skip to content

Commit 460eb1e

Browse files
committed
poller/routes: added the vrf name management for sonic version 4.2
Added the code to manage correctly those routing table entries that have the vrf id instead of the vrf name Signed-off-by: AndryNick98 <[email protected]>
1 parent f331c54 commit 460eb1e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

suzieq/poller/worker/services/routes.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
from typing import Dict, List
23
import numpy as np
34

45
from suzieq.poller.worker.services.service import Service
@@ -56,9 +57,18 @@ def _clean_eos_data(self, processed_data, _):
5657

5758
def _clean_linux_data(self, processed_data, _):
5859
"""Clean Linux ip route data"""
60+
drop_indices: List[int] = []
61+
id_vrf_match: Dict[str, str] = {}
5962

60-
for entry in processed_data:
61-
entry["vrf"] = entry["vrf"] or "default"
63+
for i, entry in enumerate(processed_data):
64+
if table_id := entry.get('table_id'):
65+
id_vrf_match[table_id] = entry.get('vrf') or 'default'
66+
drop_indices.append(i)
67+
continue
68+
if vrf_id := entry.get('vrf_id'):
69+
entry["vrf"] = id_vrf_match.get(vrf_id) or 'default'
70+
else:
71+
entry["vrf"] = entry.get("vrf") or "default"
6272
entry["metric"] = entry["metric"] or 20
6373
entry['preference'] = entry['metric']
6474
for ele in ["nexthopIps", "oifs"]:
@@ -85,6 +95,10 @@ def _clean_linux_data(self, processed_data, _):
8595

8696
entry['inHardware'] = True # Till the offload flag is here
8797

98+
if drop_indices:
99+
processed_data = np.delete(
100+
processed_data, drop_indices).tolist() # type: ignore
101+
88102
return processed_data
89103

90104
def _clean_cumulus_data(self, processed_data, raw_data):

0 commit comments

Comments
 (0)