diff --git a/crmsh/bootstrap.py b/crmsh/bootstrap.py index a3782a298..707232174 100644 --- a/crmsh/bootstrap.py +++ b/crmsh/bootstrap.py @@ -215,6 +215,9 @@ def _validate_sbd_option(self): """ Validate sbd options """ + no_sbd_option = not self.sbd_devices and not self.diskless_sbd + if self.watchdog and no_sbd_option: + utils.fatal("-w option should be used with -s or -S option") if self.sbd_devices and self.diskless_sbd: utils.fatal("Can't use -s and -S options together") if self.sbd_devices: diff --git a/crmsh/ui_cluster.py b/crmsh/ui_cluster.py index f9230646d..6fa41ba1f 100644 --- a/crmsh/ui_cluster.py +++ b/crmsh/ui_cluster.py @@ -421,7 +421,7 @@ def do_init(self, context, *args): parser.add_argument("-S", "--enable-sbd", dest="diskless_sbd", action="store_true", help="Enable SBD even if no SBD device is configured (diskless mode)") parser.add_argument("-w", "--watchdog", dest="watchdog", metavar="WATCHDOG", - help="Use the given watchdog device or driver name") + help="Use the given watchdog device or driver name (only valid together with -s or -S option)") parser.add_argument("-x", "--skip-csync2-sync", dest="skip_csync2", action="store_true", help="Skip csync2 initialization (default, deprecated)") parser.add_argument('--use-ssh-agent', action=argparse.BooleanOptionalAction, dest='use_ssh_agent', default=True, diff --git a/crmsh/ui_sbd.py b/crmsh/ui_sbd.py index 3ddea9a60..b7d4b4c9b 100644 --- a/crmsh/ui_sbd.py +++ b/crmsh/ui_sbd.py @@ -175,7 +175,7 @@ def configure_usage(self) -> str: timeout_usage_str = " ".join([f"[{t}-timeout=]" for t in timeout_types]) show_usage = f"crm sbd configure show [{'|'.join(show_types)}]" - return f"Usage:\n{show_usage}\ncrm sbd configure {timeout_usage_str} [watchdog-device=]\n" + return f"Usage:\n{show_usage}\ncrm sbd configure {timeout_usage_str} [watchdog-device=]\n" def _show_sysconfig(self) -> None: ''' diff --git a/crmsh/watchdog.py b/crmsh/watchdog.py index cf21847ee..3c8604a03 100644 --- a/crmsh/watchdog.py +++ b/crmsh/watchdog.py @@ -167,7 +167,7 @@ def init_watchdog(self): # self._input is invalid, exit rc, _, _ = ShellUtils().get_stdout_stderr(f"modinfo {self._input}") if rc != 0: - utils.fatal("Should provide valid watchdog device or driver name by -w option") + utils.fatal("Should provide valid watchdog device or driver name") # self._input is a driver name, load it if it was unloaded if not self._driver_is_loaded(self._input): diff --git a/doc/crm.8.adoc b/doc/crm.8.adoc index dbf5434d3..f73bd0fbb 100644 --- a/doc/crm.8.adoc +++ b/doc/crm.8.adoc @@ -2218,11 +2218,11 @@ Usage: ............... # For disk-based SBD crm sbd configure show [disk_metadata|sysconfig|property] -crm sbd configure [watchdog-timeout=] [allocate-timeout=] [loop-timeout=] [msgwait-timeout=] [crashdump-watchdog-timeout=] [watchdog-device=] +crm sbd configure [watchdog-timeout=] [allocate-timeout=] [loop-timeout=] [msgwait-timeout=] [crashdump-watchdog-timeout=] [watchdog-device=] # For disk-less SBD crm sbd configure show [sysconfig|property] -crm sbd configure [watchdog-timeout=] [crashdump-watchdog-timeout=] [watchdog-device=] +crm sbd configure [watchdog-timeout=] [crashdump-watchdog-timeout=] [watchdog-device=] ............... example: diff --git a/test/features/steps/const.py b/test/features/steps/const.py index e3b5b5cce..6c97970d4 100644 --- a/test/features/steps/const.py +++ b/test/features/steps/const.py @@ -76,7 +76,8 @@ -S, --enable-sbd Enable SBD even if no SBD device is configured (diskless mode) -w, --watchdog WATCHDOG - Use the given watchdog device or driver name + Use the given watchdog device or driver name (only + valid together with -s or -S option) -x, --skip-csync2-sync Skip csync2 initialization (default, deprecated) --use-ssh-agent, --no-use-ssh-agent diff --git a/test/unittests/test_ui_sbd.py b/test/unittests/test_ui_sbd.py index 4580d74e2..e9095c796 100644 --- a/test/unittests/test_ui_sbd.py +++ b/test/unittests/test_ui_sbd.py @@ -155,7 +155,7 @@ def test_configure_usage_disk_diskbased(self, mock_is_using_disk_based_sbd, mock mock_is_using_disk_based_sbd.return_value = True timeout_usage_str = " ".join([f"[{t}-timeout=]" for t in ui_sbd.SBD.TIMEOUT_TYPES]) show_usage = f"crm sbd configure show [{'|'.join(ui_sbd.SBD.SHOW_TYPES)}]" - expected = f"Usage:\n{show_usage}\ncrm sbd configure {timeout_usage_str} [watchdog-device=]\n" + expected = f"Usage:\n{show_usage}\ncrm sbd configure {timeout_usage_str} [watchdog-device=]\n" self.assertEqual(self.sbd_instance_diskbased.configure_usage, expected) mock_is_using_disk_based_sbd.assert_called_once() mock_is_using_diskless_sbd.assert_not_called() @@ -167,7 +167,7 @@ def test_configure_usage_disk_diskless(self, mock_is_using_disk_based_sbd, mock_ mock_is_using_diskless_sbd.return_value = True timeout_usage_str = " ".join([f"[{t}-timeout=]" for t in ui_sbd.SBD.DISKLESS_TIMEOUT_TYPES]) show_usage = f"crm sbd configure show [{'|'.join(ui_sbd.SBD.DISKLESS_SHOW_TYPES)}]" - expected = f"Usage:\n{show_usage}\ncrm sbd configure {timeout_usage_str} [watchdog-device=]\n" + expected = f"Usage:\n{show_usage}\ncrm sbd configure {timeout_usage_str} [watchdog-device=]\n" self.assertEqual(self.sbd_instance_diskless.configure_usage, expected) mock_is_using_disk_based_sbd.assert_called_once() mock_is_using_diskless_sbd.assert_called_once() diff --git a/test/unittests/test_watchdog.py b/test/unittests/test_watchdog.py index 0c505a2e3..333281c6e 100644 --- a/test/unittests/test_watchdog.py +++ b/test/unittests/test_watchdog.py @@ -287,7 +287,7 @@ def test_init_watchdog_error(self, mock_set_info, mock_set_input, mock_valid, mo mock_valid.assert_called_once_with("test") mock_run.assert_called_once_with("modinfo test") - mock_error.assert_called_once_with("Should provide valid watchdog device or driver name by -w option") + mock_error.assert_called_once_with("Should provide valid watchdog device or driver name") @mock.patch('crmsh.watchdog.Watchdog._get_device_through_driver') @mock.patch('crmsh.watchdog.Watchdog._load_watchdog_driver')