Skip to content

Commit

Permalink
Fix: ui_node: clearstate command needs adjustment (bsc#1219831)
Browse files Browse the repository at this point in the history
"crm node show" and "clearstate" commands need adjustments.
The format of the output in the //node_state has little changed in
ClusterLabs/pacemaker#3031
This PR enables the crmsh understand both the new and the old format.
  • Loading branch information
Aleksei Burlakov committed Feb 20, 2024
1 parent e3d1170 commit b54b83b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crmsh/ui_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ def do_print(uname):
xml = find(uname, cfg_nodes)
state = find(uname, node_states)
if xml is not None or state is not None:
is_offline = state is not None and state.get("crmd") == "offline"
is_offline = state is not None and \
(state.get("crmd") == "offline" or \
(state.get("crmd").isdigit() and int(state.get("crmd")) == 0))
print_node(*unpack_node_xmldata(xml if xml is not None else state, is_offline))

if node is not None:
Expand Down Expand Up @@ -501,13 +503,14 @@ def do_clearstate(self, context, node=None):
cib_elem = xmlutil.cibdump2elem()
if cib_elem is None:
return False
if cib_elem.xpath("//node_state[@uname=\"%s\"]/@crmd" % node) == ["online"]:
crmd = cib_elem.xpath("//node_state[@uname=\"%s\"]/@crmd" % node)
if crmd == ["online"] or (crmd[0].isdigit() and int(crmd[0]) != 0):
return utils.ext_cmd(self.node_cleanup_resources % node) == 0
elif cib_elem.xpath("//node_state[@uname=\"%s\"]/@in_ccm" % node) == ["true"]:
in_ccm = cib_elem.xpath("//node_state[@uname=\"%s\"]/@in_ccm" % node)
if in_ccm == ["true"] or (in_ccm[0].isdigit() and int(in_ccm[0]) != 0):
logger.warning("Node is offline according to Pacemaker, but online according to corosync. First shut down node '%s'", node)
return False
else:
return utils.ext_cmd(self.node_clear_state_118 % node) == 0
return utils.ext_cmd(self.node_clear_state_118 % node) == 0
else:
return utils.ext_cmd(self.node_clear_state % ("-M -c", node, node)) == 0 and \
utils.ext_cmd(self.node_clear_state % ("-R", node, node)) == 0
Expand Down

0 comments on commit b54b83b

Please sign in to comment.