Skip to content

Dev: utils: Add info when property is newly added #1414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions crmsh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2795,11 +2795,12 @@
origin_value = get_property(property_name, property_type)
if origin_value and str(origin_value) == str(property_value):
return
if conditional:
if crm_msec(origin_value) >= crm_msec(property_value):
return
if conditional and crm_msec(origin_value) >= crm_msec(property_value):
return

Check warning on line 2799 in crmsh/utils.py

View check run for this annotation

Codecov / codecov/patch

crmsh/utils.py#L2799

Added line #L2799 was not covered by tests
if not origin_value and property_value:
logger.info("Set property \"%s\" in %s to %s", property_name, property_type, property_value)
if origin_value and str(origin_value) != str(property_value):
logger.warning("\"{}\" in {} is set to {}, it was {}".format(property_name, property_type, property_value, origin_value))
logger.warning("\"%s\" in %s is set to %s, it was %s", property_name, property_type, property_value, origin_value)
property_sub_cmd = "property" if property_type == "crm_config" else property_type
cmd = "crm configure {} {}={}".format(property_sub_cmd, property_name, property_value)
sh.cluster_shell().get_stdout_or_raise_error(cmd)
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ def test_set_property(mock_get, mock_run, mock_warn):
mock_get.return_value = "start"
utils.set_property("no-quorum-policy", "stop")
mock_run.assert_called_once_with("crm configure property no-quorum-policy=stop")
mock_warn.assert_called_once_with('"no-quorum-policy" in crm_config is set to stop, it was start')
mock_warn.assert_called_once_with('"%s" in %s is set to %s, it was %s', 'no-quorum-policy', 'crm_config', 'stop', 'start')


@mock.patch('crmsh.utils.get_property')
Expand Down
Loading