Skip to content

Commit 7179b6e

Browse files
authored
Merge pull request #1416 from liangxin1300/20240506_show_info_adding_property_crmsh45
[crmsh-4.5] Dev: utils: Add info when property is newly added
2 parents 91dbee7 + 90c13b3 commit 7179b6e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

crmsh/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3352,11 +3352,12 @@ def set_property(property_name, property_value, property_type="crm_config", cond
33523352
origin_value = get_property(property_name, property_type)
33533353
if origin_value and str(origin_value) == str(property_value):
33543354
return
3355-
if conditional:
3356-
if crm_msec(origin_value) >= crm_msec(property_value):
3357-
return
3355+
if conditional and crm_msec(origin_value) >= crm_msec(property_value):
3356+
return
3357+
if not origin_value and property_value:
3358+
logger.info("Set property \"%s\" in %s to %s", property_name, property_type, property_value)
33583359
if origin_value and str(origin_value) != str(property_value):
3359-
logger.warning("\"{}\" in {} is set to {}, it was {}".format(property_name, property_type, property_value, origin_value))
3360+
logger.warning("\"%s\" in %s is set to %s, it was %s", property_name, property_type, property_value, origin_value)
33603361
property_sub_cmd = "property" if property_type == "crm_config" else property_type
33613362
cmd = "crm configure {} {}={}".format(property_sub_cmd, property_name, property_value)
33623363
get_stdout_or_raise_error(cmd)

test/unittests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,7 @@ def test_set_property(mock_get, mock_run, mock_warn):
17331733
mock_get.return_value = "start"
17341734
utils.set_property("no-quorum-policy", "stop")
17351735
mock_run.assert_called_once_with("crm configure property no-quorum-policy=stop")
1736-
mock_warn.assert_called_once_with('"no-quorum-policy" in crm_config is set to stop, it was start')
1736+
mock_warn.assert_called_once_with('"%s" in %s is set to %s, it was %s', 'no-quorum-policy', 'crm_config', 'stop', 'start')
17371737

17381738

17391739
@mock.patch('crmsh.utils.get_property')

0 commit comments

Comments
 (0)