Skip to content

Commit

Permalink
[crmsh-4.6] Add an option 'add_advised_op_values' to disable adding a…
Browse files Browse the repository at this point in the history
…dvised op values (#1514)

backport #1494
  • Loading branch information
liangxin1300 authored Aug 13, 2024
2 parents 7df9094 + 80a1d0d commit 0b74214
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions crmsh/cibconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ def parse_cli_to_xml(cli, oldnode=None):
output: XML, obj_type, obj_id
"""
node = None
default_op_values = False
advised_op_values = False
default_promotable_meta = False
comments = []
if isinstance(cli, str):
Expand All @@ -865,12 +865,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("@"):
default_op_values = False
advised_op_values = False
default_promotable_meta = False
else:
default_op_values = True
advised_op_values = config.core.add_advised_op_values
default_promotable_meta = True
node = parse.parse(cli, comments=comments, ignore_empty=False, add_default_op_values=default_op_values)
node = parse.parse(cli, comments=comments, ignore_empty=False, add_advised_op_values=advised_op_values)
if node is False:
return None, None, None
elif node is None:
Expand Down
1 change: 1 addition & 0 deletions crmsh/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def get(self, value):
'report_tool_options': opt_string(''),
'lock_timeout': opt_string('120'),
'OCF_1_1_SUPPORT': opt_boolean('no'),
'add_advised_op_values': opt_boolean('yes'),
'obscure_pattern': opt_string('passw*')
},
'path': {
Expand Down
12 changes: 6 additions & 6 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_default_op_values):
def do_parse(self, cmd, ignore_empty, add_advised_op_values):
"""
Called by CliParser. Calls parse()
Parsers should pass their return value through this method.
"""
self.ignore_empty = ignore_empty
self.add_default_op_values = add_default_op_values
self.add_advised_op_values = add_advised_op_values
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_default_op_values or out.tag != "primitive":
if not self.add_advised_op_values 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_default_op_values:
if self.add_advised_op_values:
id_str = f"{bundle_id}_{name.replace('-', '_')}_{index}"
inst_attrs.set('id', id_str)
child_flag = True
Expand Down Expand Up @@ -1795,7 +1795,7 @@ def parse(self):
return ret


def parse(s, comments=None, ignore_empty=True, add_default_op_values=False):
def parse(s, comments=None, ignore_empty=True, add_advised_op_values=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_default_op_values=False):
return False

try:
ret = parser.do_parse(s, ignore_empty, add_default_op_values)
ret = parser.do_parse(s, ignore_empty, add_advised_op_values)
if ret is not None and len(comments) > 0:
if ret.tag in constants.defaults_tags:
xmlutil.stuff_comments(ret[0], comments)
Expand Down
1 change: 1 addition & 0 deletions etc/crm.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
; ignore_missing_metadata = no
; report_tool_options =
; lock_timeout = 120
; add_advised_op_values = yes

; set OCF_1_1_SUPPORT to yes is to fully turn on OCF 1.1 feature once the corresponding CIB detected.
; OCF_1_1_SUPPORT = yes
Expand Down

0 comments on commit 0b74214

Please sign in to comment.