From d0dc577bbc4f183086f8b39432b326d9f73413af Mon Sep 17 00:00:00 2001 From: themylogin Date: Fri, 12 Jun 2026 10:09:07 +0200 Subject: [PATCH] Do not ask for reboot or shutdown reason on non-enterprise systems (cherry picked from commit a45959cee79b8deed6fe62cb9d2102c60aef01d6) --- midcli/menu/items.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/midcli/menu/items.py b/midcli/menu/items.py index ca3d180..c051517 100644 --- a/midcli/menu/items.py +++ b/midcli/menu/items.py @@ -107,13 +107,25 @@ def generate_onetime_password(context): def reboot(context): - if reason := input("Please enter the reason for the system reboot: ").strip(): - context.process_input(f"system reboot {json.dumps(reason)}") + reason = "Unknown Reason" + with context.get_client() as c: + if c.call("system.product_type") == "ENTERPRISE": + reason = input("Please enter the reason for the system reboot: ").strip() + if not reason: + return + + context.process_input(f"system reboot {json.dumps(reason)}") def shutdown(context): - if reason := input("Please enter the reason for the system shutdown: ").strip(): - context.process_input(f"system shutdown {json.dumps(reason)}") + reason = "Unknown Reason" + with context.get_client() as c: + if c.call("system.product_type") == "ENTERPRISE": + reason = input("Please enter the reason for the system shutdown: ").strip() + if not reason: + return + + context.process_input(f"system shutdown {json.dumps(reason)}") def get_menu_items(context):