Skip to content

Commit

Permalink
pandas/ospf: Added default columns to ospf table
Browse files Browse the repository at this point in the history
Added default columns to ospfIf in case of missing
ospfNbr data, to avoid bad behavior in GUI.

Signed-off-by: rickstardust <[email protected]>
  • Loading branch information
rickstardust committed Apr 5, 2024
1 parent b22700e commit 52c0396
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions suzieq/engines/pandas/ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def _get_combined_df(self, **kwargs):

ifschema = SchemaForTable('ospfIf', schema=self.all_schemas)
nbrschema = SchemaForTable('ospfNbr', schema=self.all_schemas)
ospfschema = SchemaForTable('ospf', schema=self.all_schemas)

if columns not in [['default'], ['*']]:
ifkeys = ifschema.key_fields()
Expand Down Expand Up @@ -102,6 +103,11 @@ def _get_combined_df(self, **kwargs):
nbr_df = self._get_table_sqobj('ospfNbr') \
.get(columns=nbrcols, **kwargs)
if nbr_df.empty:
missing_cols = set(ospfschema.get_display_fields(['default'])) - set(df.columns)
for col in missing_cols:
df[col] = np.nan
df = df.fillna({'peerIP': '-', 'peerHostname': '',
'lastChangeTime': 0, 'numChanges': 0, 'ifState': '', 'adjState': ''})
return df

merge_cols = [x for x in ['namespace', 'hostname', 'ifname']
Expand Down

0 comments on commit 52c0396

Please sign in to comment.