Skip to content

Commit

Permalink
poller/routes: added the vrf name management for sonic version 4.2
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
AndryNick98 committed May 21, 2024
1 parent f331c54 commit 460eb1e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions suzieq/poller/worker/services/routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
from typing import Dict, List
import numpy as np

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

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

for entry in processed_data:
entry["vrf"] = entry["vrf"] or "default"
for i, entry in enumerate(processed_data):
if table_id := entry.get('table_id'):
id_vrf_match[table_id] = entry.get('vrf') or 'default'
drop_indices.append(i)
continue
if vrf_id := entry.get('vrf_id'):
entry["vrf"] = id_vrf_match.get(vrf_id) or 'default'
else:
entry["vrf"] = entry.get("vrf") or "default"
entry["metric"] = entry["metric"] or 20
entry['preference'] = entry['metric']
for ele in ["nexthopIps", "oifs"]:
Expand All @@ -85,6 +95,10 @@ def _clean_linux_data(self, processed_data, _):

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

if drop_indices:
processed_data = np.delete(
processed_data, drop_indices).tolist() # type: ignore

return processed_data

def _clean_cumulus_data(self, processed_data, raw_data):
Expand Down

0 comments on commit 460eb1e

Please sign in to comment.