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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-01-31 13:55:35 +01:00
parent 4458e03cd2
commit b010ad04bf
2 changed files with 4 additions and 5 deletions
+2 -3
View File
@@ -286,9 +286,8 @@
<COMMAND name="ntp" help="Show NTP (client) status">
<ACTION sym="script">
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"
</ACTION>
<SWITCH name="optional" min="0">
<COMMAND name="tracking" help="Show NTP tracking">
+2 -2
View File
@@ -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}}"