Skip to content

Commit

Permalink
Dev: ui_ra: Give warning when running crm ra info with deprecated o…
Browse files Browse the repository at this point in the history
…ptions

Like `ra info cib`, `ra info crmd`, `ra info pengine` and `ra info
stonithd`.
  • Loading branch information
liangxin1300 committed Dec 31, 2024
1 parent 2719773 commit a802e6e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crmsh/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,8 @@
RSC_ROLE_PROMOTED_LEGACY = "Master"
RSC_ROLE_UNPROMOTED_LEGACY = "Slave"
PCMK_VERSION_DEFAULT = "2.0.0"
# pacemaker 2.1.8 introduced `crm_attribute --list-options`
PCMK_MIN_VERSION_SUPPORT_LIST_OPTIONS = "2.1.8"

COROSYNC_STATUS_TYPES = ("ring", "quorum", "qdevice", "qnetd", "cpg")

Expand Down
11 changes: 11 additions & 0 deletions crmsh/ui_ra.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
from . import ra
from . import constants
from . import options
from . import log


logger = log.setup_logger(__name__)


def complete_class_provider_type(args):
Expand Down Expand Up @@ -120,6 +124,13 @@ def do_info(self, context, *args):
else:
ra_type, ra_class, ra_provider = args[0], args[1], args[2]
elif args[0] in constants.meta_progs:
if utils.is_min_pcmk_ver(constants.PCMK_MIN_VERSION_SUPPORT_LIST_OPTIONS):
if args[0] == "stonithd":
alternative = r"`crm ra info pacemaker-fenced`"

Check warning on line 129 in crmsh/ui_ra.py

View check run for this annotation

Codecov / codecov/patch

crmsh/ui_ra.py#L127-L129

Added lines #L127 - L129 were not covered by tests
else:
alternative = r"`crm configure property <property_name> --help`"
warning_msg = f"`crm ra info {args[0]}` is deprecated and is replaced by {alternative} going forward."
logger.warning(warning_msg)

Check warning on line 133 in crmsh/ui_ra.py

View check run for this annotation

Codecov / codecov/patch

crmsh/ui_ra.py#L131-L133

Added lines #L131 - L133 were not covered by tests
ra_class, ra_provider, ra_type = args[0], None, None
elif args[0] in constants.meta_progs_20:
ra_class, ra_provider, ra_type = args[0], None, None
Expand Down

0 comments on commit a802e6e

Please sign in to comment.