Skip to content

Commit b3bb719

Browse files
authored
Merge pull request #792 from netenglabs/path-query-str
Add query_str to path
2 parents af0abc6 + 71976f4 commit b3bb719

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

suzieq/cli/sqcmds/PathCmd.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(
2525
src: str = "",
2626
dest: str = "",
2727
vrf: str = "",
28+
query_str: str = ' ',
2829
) -> None:
2930
super().__init__(
3031
engine=engine,
@@ -34,6 +35,7 @@ def __init__(
3435
view=view,
3536
namespace=namespace,
3637
columns=columns,
38+
query_str=query_str,
3739
format=format,
3840
sqobj=PathObj
3941
)

suzieq/engines/pandas/path.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ def get(self, **kwargs) -> pd.DataFrame:
752752
src = kwargs.get("src", None)
753753
dest = kwargs.get("dest", None)
754754
dvrf = kwargs.get("vrf", "")
755+
query_str = kwargs.pop('query_str', "")
755756

756757
if not src or not dest:
757758
raise AttributeError("Must specify trace source and dest")
@@ -1120,7 +1121,9 @@ def get(self, **kwargs) -> pd.DataFrame:
11201121
# This occurs when a path traversal terminates due to an error such
11211122
# as loop detected
11221123
final_paths = paths
1123-
return self._path_cons_result(final_paths)
1124+
return self._handle_user_query_str(
1125+
self._path_cons_result(final_paths), query_str)\
1126+
.reset_index(drop=True)
11241127

11251128
def _path_cons_result(self, paths):
11261129
df_plist = []

tests/integration/sqcmds/cumulus-samples/badquery.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ tests:
7575
- command: path show --src='172.16.1.101' --dest='172.16.3.202' --namespace='ospf-ibgp'
7676
--query-str='vendor == "Cisco" and mtu==1500' --format=json
7777
data-directory: tests/data/parquet/
78+
error:
79+
error: '[{"error": "ERROR: UserQueryError: name ''vendor'' is not defined"}]'
7880
marks: path show badquery cumulus
79-
output: '[]'
8081
- command: topology show --query-str='vendor == "Cisco" and mtu==1500' --format=json
8182
--namespace='ospf-single dual-evpn ospf-ibgp'
8283
data-directory: tests/data/parquet/
@@ -158,8 +159,9 @@ tests:
158159
- command: path summarize --src='172.16.1.101' --dest='172.16.3.202' --namespace='ospf-ibgp'
159160
--query-str='vendor == "Cisco" and mtu==1500' --format=json
160161
data-directory: tests/data/parquet/
162+
error:
163+
error: '{"error": {"0": "ERROR: UserQueryError: name ''vendor'' is not defined"}}'
161164
marks: path summarize badquery cumulus
162-
output: '[]'
163165
- command: topology summarize --query-str='vendor == "Cisco" and mtu==1500' --format=json
164166
--namespace='ospf-single dual-evpn ospf-ibgp' --columns='hostname'
165167
data-directory: tests/data/parquet/
@@ -241,8 +243,9 @@ tests:
241243
- command: path unique --src='172.16.1.101' --dest='172.16.3.202' --namespace='ospf-ibgp'
242244
--query-str='vendor == "Cisco" and mtu==1500' --format=json --columns='hostname'
243245
data-directory: tests/data/parquet/
246+
error:
247+
error: '[{"error": "ERROR: UserQueryError: name ''vendor'' is not defined"}]'
244248
marks: path unique badquery cumulus
245-
output: '[]'
246249
- command: topology unique --query-str='vendor == "Cisco" and mtu==1500' --format=json
247250
--namespace='ospf-single dual-evpn ospf-ibgp' --columns='hostname'
248251
data-directory: tests/data/parquet/

0 commit comments

Comments
 (0)