Skip to content
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

[crmsh-4.6] Fix: Don't add time units to values for existing CIB (bsc#1228817) #1506

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/cibconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,8 @@ def parse_cli_to_xml(cli, oldnode=None):
output: XML, obj_type, obj_id
"""
node = None
advised_op_values = False
# Flag to auto add adviced operation values and time units
auto_add = False
default_promotable_meta = False
comments = []
if isinstance(cli, str):
Expand All @@ -865,12 +866,12 @@ def parse_cli_to_xml(cli, oldnode=None):
else: # should be a pre-tokenized list
utils.auto_convert_role = True
if len(cli) >= 3 and cli[0] == "primitive" and cli[2].startswith("@"):
advised_op_values = False
auto_add = False
default_promotable_meta = False
else:
advised_op_values = config.core.add_advised_op_values
auto_add = config.core.add_advised_op_values
default_promotable_meta = True
node = parse.parse(cli, comments=comments, ignore_empty=False, add_advised_op_values=advised_op_values)
node = parse.parse(cli, comments=comments, ignore_empty=False, auto_add=auto_add)
if node is False:
return None, None, None
elif node is None:
Expand Down
14 changes: 7 additions & 7 deletions crmsh/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ def begin_dispatch(self, cmd, min_args=-1):
self.begin(cmd, min_args=min_args)
return self.match_dispatch(errmsg="Unknown command")

def do_parse(self, cmd, ignore_empty, add_advised_op_values):
def do_parse(self, cmd, ignore_empty, auto_add):
"""
Called by CliParser. Calls parse()
Parsers should pass their return value through this method.
"""
self.ignore_empty = ignore_empty
self.add_advised_op_values = add_advised_op_values
self.auto_add = auto_add
out = self.parse(cmd)
if self.has_tokens():
self.err("Unknown arguments: " + ' '.join(self._cmd[self._currtok:]))
Expand Down Expand Up @@ -661,7 +661,7 @@ def add_default_advised_ops(self, out):
"""
Add default operation actions advised values
"""
if not self.add_advised_op_values or out.tag != "primitive":
if not self.auto_add or out.tag != "primitive":
return
ra_inst = ra.RAInfo(out.get('class'), out.get('type'), out.get('provider'))
ra_actions_dict = ra_inst.actions()
Expand Down Expand Up @@ -753,7 +753,7 @@ def match_container(self, out, _type):
inst_attrs = xmlutil.child(container_node, name)
# set meaningful id for port-mapping and storage-mapping
# when the bundle is newly created
if self.add_advised_op_values:
if self.auto_add:
id_str = f"{bundle_id}_{name.replace('-', '_')}_{index}"
inst_attrs.set('id', id_str)
child_flag = True
Expand Down Expand Up @@ -794,7 +794,7 @@ def match_op(self, out, pfx='op'):
if inst_attrs is not None:
self.err(f"Attribute order error: {name} must appear before any instance attribute")
value = nvp.get('value')
if name in ('interval', 'timeout'):
if name in ('interval', 'timeout') and self.auto_add:
value = add_time_unit_if_needed(value)
node.set(name, value)
else:
Expand Down Expand Up @@ -1795,7 +1795,7 @@ def parse(self):
return ret


def parse(s, comments=None, ignore_empty=True, add_advised_op_values=False):
def parse(s, comments=None, ignore_empty=True, auto_add=False):
'''
Input: a list of tokens (or a CLI format string).
Return: a cibobject
Expand Down Expand Up @@ -1841,7 +1841,7 @@ def parse(s, comments=None, ignore_empty=True, add_advised_op_values=False):
return False

try:
ret = parser.do_parse(s, ignore_empty, add_advised_op_values)
ret = parser.do_parse(s, ignore_empty, auto_add)
if ret is not None and len(comments) > 0:
if ret.tag in constants.defaults_tags:
xmlutil.stuff_comments(ret[0], comments)
Expand Down
8 changes: 8 additions & 0 deletions test/features/resource_set.feature
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,11 @@ Feature: Use "crm configure set" to update attributes and operations
When Run "crm configure rsc_template dummy_template ocf:pacemaker:Dummy op monitor interval=12s" on "hanode1"
And Try "crm configure primitive d8 @dummy_template params passwd=123" on "hanode1"
Then Expected "got no meta-data, does this RA exist" not in stderr

@clean
Scenario: Don't add time units to values for existing CIB (bsc#1228817)
When Run "crm configure show xml d > /tmp/d.xml" on "hanode1"
And Run "sed -i '/<op name="monitor"/s/timeout="20s"/timeout="20"/' /tmp/d.xml" on "hanode1"
And Run "crm configure load xml update /tmp/d.xml" on "hanode1"
And Try "crm configure show|grep -E "^xml <primitive""
Then Expected return code is "1"
Loading