From b010ad04bf7b940464cfeebb4eb614934955e8fc Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 21 Jan 2025 09:04:16 +0100 Subject: [PATCH] cli: fix "show ntp" command when ntp is not enabled Instead of 'show ntp' => Error, top level "ietf-system:system-state" missing Try something nicer: NTP client not enabled. Signed-off-by: Joachim Wiberg --- src/klish-plugin-infix/xml/infix.xml | 5 ++--- src/statd/python/cli_pretty/cli_pretty.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/klish-plugin-infix/xml/infix.xml b/src/klish-plugin-infix/xml/infix.xml index 7873180c..7191cbe4 100644 --- a/src/klish-plugin-infix/xml/infix.xml +++ b/src/klish-plugin-infix/xml/infix.xml @@ -286,9 +286,8 @@ - sysrepocfg -d operational -X -f json -x \ - /ietf-system:system-state/infix-system:ntp | \ - /usr/libexec/statd/cli-pretty "show-ntp" + sysrepocfg -d operational -X -f json -x /system-state/ntp | \ + /usr/libexec/statd/cli-pretty "show-ntp" diff --git a/src/statd/python/cli_pretty/cli_pretty.py b/src/statd/python/cli_pretty/cli_pretty.py index ec34da38..25e5e92e 100755 --- a/src/statd/python/cli_pretty/cli_pretty.py +++ b/src/statd/python/cli_pretty/cli_pretty.py @@ -1020,8 +1020,8 @@ def show_hardware(json): def show_ntp(json): if not json.get("ietf-system:system-state"): - print(f"Error, top level \"ietf-system:system-state\" missing") - sys.exit(1) + print("NTP client not enabled.") + return hdr = (f"{'ADDRESS':<{PadNtpSource.address}}" f"{'MODE':<{PadNtpSource.mode}}" f"{'STATE':<{PadNtpSource.state}}"