From e6d4e2443e95eff54cb36adc2b794381cf22e2cd Mon Sep 17 00:00:00 2001 From: xin liang Date: Wed, 24 Jul 2024 14:43:00 +0800 Subject: [PATCH 1/2] Dev: Rename variable 'add_default_op_values' to 'add_advised_op_values' --- crmsh/cibconfig.py | 8 ++++---- crmsh/parse.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crmsh/cibconfig.py b/crmsh/cibconfig.py index fa19b9d79..3221b323a 100644 --- a/crmsh/cibconfig.py +++ b/crmsh/cibconfig.py @@ -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): @@ -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 = True 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: diff --git a/crmsh/parse.py b/crmsh/parse.py index 276d076e0..602b972f7 100644 --- a/crmsh/parse.py +++ b/crmsh/parse.py @@ -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:])) @@ -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() @@ -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 @@ -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 @@ -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) From 80a1d0d1b6dc179fded837cefb564eeb2c0b39a2 Mon Sep 17 00:00:00 2001 From: xin liang Date: Wed, 24 Jul 2024 14:45:27 +0800 Subject: [PATCH 2/2] Dev: Add option core.add_advised_op_values, default value is 'yes' --- crmsh/cibconfig.py | 2 +- crmsh/config.py | 1 + etc/crm.conf.in | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crmsh/cibconfig.py b/crmsh/cibconfig.py index 3221b323a..c17881763 100644 --- a/crmsh/cibconfig.py +++ b/crmsh/cibconfig.py @@ -868,7 +868,7 @@ def parse_cli_to_xml(cli, oldnode=None): advised_op_values = False default_promotable_meta = False else: - advised_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_advised_op_values=advised_op_values) if node is False: diff --git a/crmsh/config.py b/crmsh/config.py index 0530ef0ef..52e4bbc62 100644 --- a/crmsh/config.py +++ b/crmsh/config.py @@ -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': { diff --git a/etc/crm.conf.in b/etc/crm.conf.in index 39f8d5c19..7c1f81cbc 100644 --- a/etc/crm.conf.in +++ b/etc/crm.conf.in @@ -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