Skip to content

Commit 3858c03

Browse files
committed
Dev: ui_sbd: Validate purge option first
And give error if the option is not crashdump
1 parent 75f3954 commit 3858c03

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

crmsh/ui_sbd.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,16 +604,25 @@ def do_purge(self, context, *args) -> bool:
604604
if not self._service_is_active(constants.SBD_SERVICE):
605605
return False
606606

607+
purge_crashdump = False
608+
if args:
609+
if args[0] == "crashdump":
610+
if not self._is_crashdump_configured():
611+
logger.error("SBD crashdump is not configured")
612+
return False
613+
purge_crashdump = True
614+
else:
615+
logger.error("Invalid argument: %s", ' '.join(args))
616+
logger.info("Usage: crm sbd purge [crashdump]")
617+
return False
618+
607619
utils.check_all_nodes_reachable("purging SBD")
608620

609621
with utils.leverage_maintenance_mode() as enabled:
610622
if not utils.able_to_restart_cluster(enabled):
611623
return False
612624

613-
if args and args[0] == "crashdump":
614-
if not self._is_crashdump_configured():
615-
logger.error("SBD crashdump is not configured")
616-
return False
625+
if purge_crashdump:
617626
self._set_crashdump_option(delete=True)
618627
update_dict = self._set_crashdump_in_sysconfig(restore=True)
619628
if update_dict:

0 commit comments

Comments
 (0)