Skip to content

Commit fe92eec

Browse files
authored
Merge pull request #886 from netenglabs/device-namespace-fixes
Device namespace fixes
2 parents 4a57879 + 9aa9176 commit fe92eec

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

suzieq/config/schema/namespace.avsc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@
6161
"display": 7,
6262
"description": "Is MLAG used in this namespace"
6363
},
64+
{
65+
"name": "lastUpdate",
66+
"type": "timestamp",
67+
"display": 8,
68+
"description": "The last time the poller updated this namespace"
69+
},
6470
{
6571
"name": "namespace",
6672
"type": "string",

suzieq/engines/pandas/device.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ def get(self, **kwargs):
5252
if view == 'latest' and 'status' in df.columns:
5353
df['status'] = np.where(df.active, df['status'], 'dead')
5454

55-
poller_df = pd.DataFrame()
55+
poller_df: pd.DataFrame = pd.DataFrame()
56+
57+
# Retrieve the devices that have possibly not made it into the device
58+
# list because they never could connect due to any reason
5659
if not ignore_neverpoll:
5760
poller_df = self._get_table_sqobj('sqPoller').get(
5861
namespace=kwargs.get('namespace', []),
5962
hostname=kwargs.get('hostname', []),
60-
service='device',
63+
service='device', status='fail',
6164
columns='namespace hostname status timestamp'.split())
6265

6366
if not poller_df.empty:
@@ -77,7 +80,7 @@ def get(self, **kwargs):
7780
.reset_index(drop=True)
7881

7982
df = df.merge(poller_df, on=['namespace', 'hostname'],
80-
how='outer', suffixes=['', '_y']) \
83+
how='outer', suffixes=('', '_y')) \
8184
.fillna({'bootupTimestamp': 0,
8285
'active': True})
8386

@@ -121,6 +124,7 @@ def get(self, **kwargs):
121124
# The poller merge kills the filtering we did earlier, so redo:
122125
if status:
123126
df = df.loc[df.status.isin(status)]
127+
124128
if os_version:
125129
opdict = {'>': operator.gt, '<': operator.lt, '>=': operator.ge,
126130
'<=': operator.le, '=': operator.eq, '!': operator.ne}

suzieq/engines/pandas/namespace.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ def get(self, **kwargs):
9292
if 'sqvers' in fields:
9393
newdf['sqvers'] = self.schema.version
9494
newdf['active'] = True
95-
newdf = self._handle_user_query_str(newdf, user_query)
9695

9796
# Look for the rest of info only in selected namepaces
9897
newdf['lastUpdate'] = nsgrp['timestamp'].max() \

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,14 @@ tests:
405405
{"name": "hasOspf", "type": "boolean", "key": "", "display": 4, "description":
406406
"Is OSPF used in this namespace"}, {"name": "hasVxlan", "type": "boolean", "key":
407407
"", "display": 6, "description": "Is VXLAN used in this namespace"}, {"name":
408-
"lastUpdate", "type": "timestamp", "key": "", "display": 8, "description": "Time
409-
when any service was last polled"}, {"name": "namespace", "type": "string", "key":
410-
0, "display": 0, "description": "Namespace associated with this record"}, {"name":
411-
"serviceCnt", "type": "long", "key": "", "display": 2, "description": "Number
412-
of services polled in this namespace"}, {"name": "sqvers", "type": "string", "key":
413-
"", "display": "", "description": "Schema version, not selectable"}]'
408+
"lastUpdate", "type": "timestamp", "key": "", "display": 8, "description": "The
409+
last time the poller updated this namespace"}, {"name": "lastUpdate", "type":
410+
"timestamp", "key": "", "display": 8, "description": "Time when any service was
411+
last polled"}, {"name": "namespace", "type": "string", "key": 0, "display": 0,
412+
"description": "Namespace associated with this record"}, {"name": "serviceCnt",
413+
"type": "long", "key": "", "display": 2, "description": "Number of services polled
414+
in this namespace"}, {"name": "sqvers", "type": "string", "key": "", "display":
415+
"", "description": "Schema version, not selectable"}]'
414416
- command: path describe --format=json
415417
data-directory: tests/data/parquet
416418
marks: path describe

0 commit comments

Comments
 (0)