Use get_property instead of get-property
hacluster uses the command "crm configure get-property <CMD>" to obtain
a property of the cluster, although "get-property" has been deprecated
in favor of "get_property", since crmsh-4.2.1 a warning is printed to
stdout[0] breaking the parsing.
# crm configure get-property maintenance-mode 2>/dev/null
WARNING: This command 'get-property' is deprecated, please use 'get_property'
INFO: "get-property" is accepted as "get_property"
true
[0] 86282af8e5
Change-Id: Id0ee9ab1873d14dcd1c960001cdeb8318f599ef5
Closes-Bug: #2008704
This commit is contained in:
parent
f856ee25ff
commit
8446b38347
@ -289,9 +289,14 @@ def get_property(name):
|
||||
:returns: property value
|
||||
:rtype: str
|
||||
"""
|
||||
# get-property deprecated in favor of get_property (LP: #2008704)
|
||||
if crm_version() >= StrictVersion('4.2.1'):
|
||||
output = subprocess.check_output(
|
||||
['crm', 'configure', 'get_property', name],
|
||||
universal_newlines=True)
|
||||
# crmsh >= 2.3 renamed show-property to get-property, 2.3.x is
|
||||
# available since zesty
|
||||
if crm_version() >= StrictVersion('2.3.0'):
|
||||
elif crm_version() >= StrictVersion('2.3.0'):
|
||||
output = subprocess.check_output(
|
||||
['crm', 'configure', 'get-property', name],
|
||||
universal_newlines=True)
|
||||
|
@ -277,6 +277,14 @@ class TestPcmk(unittest.TestCase):
|
||||
'maintenance-mode'],
|
||||
universal_newlines=True)
|
||||
|
||||
mock_crm_version.return_value = StrictVersion('4.2.1') # >= jammy
|
||||
mock_check_output.reset_mock()
|
||||
self.assertEqual('false\n', pcmk.get_property('maintenance-mode'))
|
||||
mock_check_output.assert_called_with(['crm', 'configure',
|
||||
'get_property',
|
||||
'maintenance-mode'],
|
||||
universal_newlines=True)
|
||||
|
||||
@mock.patch('subprocess.check_output')
|
||||
@mock.patch.object(pcmk, 'crm_version')
|
||||
def test_get_property_from_xml(self, mock_crm_version, mock_check_output):
|
||||
|
Loading…
Reference in New Issue
Block a user