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

Add an option 'add_advised_op_values' to disable adding advised op values #1494

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
8 changes: 4 additions & 4 deletions crmsh/cibconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,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 @@ -864,12 +864,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):
'ignore_missing_metadata': opt_boolean('no'),
'report_tool_options': opt_string(''),
'lock_timeout': opt_string('120'),
'add_advised_op_values': opt_boolean('yes'),
'OCF_1_1_SUPPORT': opt_boolean('yes'),
'obscure_pattern': opt_string('passw*')
},
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 @@ -1794,7 +1794,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 @@ -1840,7 +1840,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