Skip to content

Commit 37a1c4e

Browse files
authored
Merge pull request #1417 from liangxin1300/20240506_show_info_adding_property_crmsh46
[crmsh-4.6] Dev: utils: Add info when property is newly added
2 parents 5d7136c + 2ddd571 commit 37a1c4e

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
@@ -2859,11 +2859,12 @@ def set_property(property_name, property_value, property_type="crm_config", cond
28592859
origin_value = get_property(property_name, property_type)
28602860
if origin_value and str(origin_value) == str(property_value):
28612861
return
2862-
if conditional:
2863-
if crm_msec(origin_value) >= crm_msec(property_value):
2864-
return
2862+
if conditional and crm_msec(origin_value) >= crm_msec(property_value):
2863+
return
2864+
if not origin_value and property_value:
2865+
logger.info("Set property \"%s\" in %s to %s", property_name, property_type, property_value)
28652866
if origin_value and str(origin_value) != str(property_value):
2866-
logger.warning("\"{}\" in {} is set to {}, it was {}".format(property_name, property_type, property_value, origin_value))
2867+
logger.warning("\"%s\" in %s is set to %s, it was %s", property_name, property_type, property_value, origin_value)
28672868
property_sub_cmd = "property" if property_type == "crm_config" else property_type
28682869
cmd = "crm configure {} {}={}".format(property_sub_cmd, property_name, property_value)
28692870
sh.cluster_shell().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
@@ -1267,7 +1267,7 @@ def test_set_property(mock_get, mock_run, mock_warn):
12671267
mock_get.return_value = "start"
12681268
utils.set_property("no-quorum-policy", "stop")
12691269
mock_run.assert_called_once_with("crm configure property no-quorum-policy=stop")
1270-
mock_warn.assert_called_once_with('"no-quorum-policy" in crm_config is set to stop, it was start')
1270+
mock_warn.assert_called_once_with('"%s" in %s is set to %s, it was %s', 'no-quorum-policy', 'crm_config', 'stop', 'start')
12711271

12721272

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

0 commit comments

Comments
 (0)