Only return hacluster nodes from list_nodes()

list_nodes() recently had some changes to run 'crm node show'
in jammy+ instead of 'crm node status'. The difference is that
'crm node show' returns the pacemaker-remote nodes in addition
 to the hacluster nodes. This change limits the nodes returned
by list_nodes() to the hacluster nodes (ie. the nodes that
have a node ID).

Closes-Bug: #1995295
Change-Id: Ia405d4270f56c949f79167f8b75c1304b598b918
This commit is contained in:
Corey Bryant 2022-11-01 11:53:21 +01:00
parent 45310a2270
commit a03b0b2a87
2 changed files with 2 additions and 3 deletions

View File

@ -192,7 +192,7 @@ def list_nodes():
cmd = ['crm', 'node', 'show']
out = subprocess.check_output(cmd).decode('utf-8')
for line in out.strip().split('\n'):
if re.match(r'^\S+', line):
if re.match(r'^\S+\(\d+\)', line):
line = line.split('(')[0]
line = line.split(':')[0]
nodes.append(line)

View File

@ -379,8 +379,7 @@ class TestPcmk(unittest.TestCase):
self.assertSequenceEqual(
pcmk.list_nodes(),
['juju-3f6cb6-zaza-4135aa8b2509-8.project.serverstack',
'juju-c1-zaza-3', 'juju-c1-zaza-5']
['juju-c1-zaza-3', 'juju-c1-zaza-5']
)
check_output.assert_called_with(['crm', 'node', 'show'])