diff options
author | Donald Sharp <donaldsharp72@gmail.com> | 2025-01-07 19:15:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-07 19:15:40 +0100 |
commit | 0a52c233d366b6c97bafe941cbee37890fab7e93 (patch) | |
tree | 06802aac3d88c6e5d9bb8fd4cdddb8500bb7952c /tests | |
parent | Merge pull request #17783 from LabNConsulting/chopps/new-oper-get-callback (diff) | |
parent | tests: fe-client: only pick mgmtd FE notify selectors once (diff) | |
download | frr-0a52c233d366b6c97bafe941cbee37890fab7e93.tar.xz frr-0a52c233d366b6c97bafe941cbee37890fab7e93.zip |
Merge pull request #17782 from LabNConsulting/chopps/new-notify-msg-fmt
New YANG notify msg fmt
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/topotests/lib/fe_client.py | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/tests/topotests/lib/fe_client.py b/tests/topotests/lib/fe_client.py index 784f7d17e..078df8cb3 100755 --- a/tests/topotests/lib/fe_client.py +++ b/tests/topotests/lib/fe_client.py @@ -78,8 +78,13 @@ GET_DATA_FLAG_STATE = 0x1 GET_DATA_FLAG_CONFIG = 0x2 GET_DATA_FLAG_EXACT = 0x4 -MSG_NOTIFY_FMT = "=B7x" +MSG_NOTIFY_FMT = "=BB6x" NOTIFY_FIELD_RESULT_TYPE = 0 +NOTIFY_FIELD_OP = 1 +NOTIFY_OP_NOTIFICATION = 0 +NOTIFY_OP_REPLACE = 1 +NOTIFY_OP_DELETE = 2 +NOTIFY_OP_PATCH = 3 MSG_NOTIFY_SELECT_FMT = "=B7x" @@ -363,10 +368,12 @@ class Session: raise Exception(f"Received NON-NOTIFY Message: {mfixed}: {mdata}") vsplit = mhdr[HDR_FIELD_VSPLIT] + result_type = mfixed[0] + op = mfixed[1] assert mdata[vsplit - 1] == 0 assert mdata[-1] == 0 - # xpath = mdata[: vsplit - 1].decode("utf-8") - return mdata[vsplit:-1].decode("utf-8") + xpath = mdata[: vsplit - 1].decode("utf-8") + return result_type, op, xpath, mdata[vsplit:-1].decode("utf-8") else: raise TimeoutError("Timeout waiting for notifications") @@ -390,6 +397,9 @@ def __parse_args(): "-c", "--config-only", action="store_true", help="return config only" ) parser.add_argument( + "--datastore", action="store_true", help="listen for datastore notifications" + ) + parser.add_argument( "-q", "--query", nargs="+", metavar="XPATH", help="xpath[s] to query" ) parser.add_argument("-s", "--server", default=MPATH, help="path to server socket") @@ -434,9 +444,31 @@ def __main(): if args.listen is not None: i = args.notify_count + if args.listen: + sess.add_notify_select(True, args.listen) while i > 0 or args.notify_count == 0: - notif = sess.recv_notify(args.listen) - print(notif) + result_type, op, xpath, notif = sess.recv_notify() + if op == NOTIFY_OP_NOTIFICATION: + if args.datastore: + logging.warning("ignoring non-datastore notification: %s", notif) + else: + print(notif) + elif not args.datastore: + logging.warning( + "ignoring datastore notification op: %s xpath: %s data: %s", + op, + xpath, + notif, + ) + elif op == NOTIFY_OP_PATCH: + print(f"#OP=PATCH: {xpath}") + print(notif) + elif op == NOTIFY_OP_REPLACE: + print(f"#OP=REPLACE: {xpath}") + print(notif) + elif op == NOTIFY_OP_DELETE: + print(f"#OP=DELETE: {xpath}") + assert len(notif) == 0 i -= 1 |