Skip to content

Commit 42ad4f1

Browse files
authored
Merge pull request #1381 from liangxin1300/20240407_corosync_status_cpg
Dev: corosync: Show corosync cpg status in `crm corosync status cpg`
2 parents c840652 + 7598036 commit 42ad4f1

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

crmsh/constants.py

+2
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,8 @@
516516
If a nic name is provided, the first IP of that nic will be used.
517517
Use multiple -i for more links. Note: Only one link is allowed for the non knet transport type
518518
"""
519+
519520
NON_FUNCTIONAL_COMMANDS = {'help', 'cd', 'ls', 'quit', 'up'}
520521
NON_FUNCTIONAL_OPTIONS = {'--help', '--help-without-redirect'}
522+
COROSYNC_STATUS_TYPES = ("ring", "quorum", "qdevice", "qnetd", "cpg")
521523
# vim:ts=4:sw=4:et:

crmsh/corosync.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,14 @@ def query_status(status_type):
9696
"""
9797
Query status of corosync
9898
99-
Possible types could be ring/quorum/qdevice/qnetd
99+
Possible types could be ring/quorum/qdevice/qnetd/cpg
100100
"""
101101
status_func_dict = {
102102
"ring": query_ring_status,
103103
"quorum": query_quorum_status,
104104
"qdevice": query_qdevice_status,
105-
"qnetd": query_qnetd_status
105+
"qnetd": query_qnetd_status,
106+
"cpg": query_cpg_status
106107
}
107108
if status_type in status_func_dict:
108109
out = sh.cluster_shell().get_stdout_or_raise_error("crm_node -l")
@@ -168,6 +169,14 @@ def query_qnetd_status():
168169
return utils.to_ascii(qnetd_result_stdout)
169170

170171

172+
def query_cpg_status():
173+
"""
174+
Query corosync cpg status
175+
"""
176+
cmd = "corosync-cpgtool -e"
177+
return sh.cluster_shell().get_stdout_or_raise_error(cmd)
178+
179+
171180
def push_configuration(nodes):
172181
'''
173182
Push the local configuration to the list of remote nodes

crmsh/ui_corosync.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from . import parallax
1010
from . import bootstrap
1111
from . import log
12+
from . import constants
1213
from .service_manager import ServiceManager
1314

1415
logger = log.setup_logger(__name__)
@@ -57,7 +58,7 @@ class Corosync(command.UI):
5758
def requires(self):
5859
return corosync.check_tools()
5960

60-
@command.completers(completers.choice(['ring', 'quorum', 'qdevice', 'qnetd']))
61+
@command.completers(completers.choice(constants.COROSYNC_STATUS_TYPES))
6162
def do_status(self, context, status_type="ring"):
6263
'''
6364
Quick cluster health status. Corosync status or QNetd status

doc/crm.8.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1372,11 +1372,11 @@ show
13721372
[[cmdhelp_corosync_status,Display the corosync status]]
13731373
==== `status`
13741374

1375-
Displays the corosync ring status(default), also can display quorum/qdevice/qnetd status.
1375+
Displays the corosync ring status(default), also can display quorum/qdevice/qnetd/cpg status.
13761376

13771377
Usage:
13781378
.........
1379-
status [ring|quorum|qdevice|qnetd]
1379+
status [ring|quorum|qdevice|qnetd|cpg]
13801380
.........
13811381

13821382
[[cmdhelp_cib,CIB shadow management]]

0 commit comments

Comments
 (0)