diff --git a/crmsh/cibconfig.py b/crmsh/cibconfig.py index c78db229d..d3f12b038 100644 --- a/crmsh/cibconfig.py +++ b/crmsh/cibconfig.py @@ -854,8 +854,12 @@ def parse_cli_to_xml(cli, oldnode=None): output: XML, obj_type, obj_id """ node = None - # Flag to auto add adviced operation values and time units - auto_add = False + # Flag to auto add advised operation values for resource agents + has_ra_advised_op = False + # Flag to auto add adviced operation values for fence agents + has_fa_advised_op = False + # Flag to auto add time units for operations + auto_add_time_units = False default_promotable_meta = False comments = [] if isinstance(cli, str): @@ -865,12 +869,22 @@ 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("@"): - auto_add = False + has_ra_advised_op = False + has_fa_advised_op = False + auto_add_time_units = False default_promotable_meta = False else: - auto_add = config.core.add_advised_op_values + has_ra_advised_op = config.core.has_ra_advised_op + has_fa_advised_op = config.core.has_fa_advised_op + auto_add_time_units = True default_promotable_meta = True - node = parse.parse(cli, comments=comments, ignore_empty=False, auto_add=auto_add) + node = parse.parse( + cli, + comments=comments, + ignore_empty=False, + has_ra_advised_op=has_ra_advised_op, + has_fa_advised_op=has_fa_advised_op, + auto_add_time_units=auto_add_time_units) if node is False: return None, None, None elif node is None: diff --git a/crmsh/config.py b/crmsh/config.py index 21f86e299..fd361f161 100644 --- a/crmsh/config.py +++ b/crmsh/config.py @@ -256,9 +256,10 @@ 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'), 'no_ssh': opt_boolean('no'), + 'has_ra_advised_op': opt_boolean('yes'), + 'has_fa_advised_op': opt_boolean('no'), 'obscure_pattern': opt_string('passw*') }, 'path': { diff --git a/crmsh/parse.py b/crmsh/parse.py index b46305457..2c3c2438e 100644 --- a/crmsh/parse.py +++ b/crmsh/parse.py @@ -170,13 +170,15 @@ 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, auto_add): + def do_parse(self, cmd, ignore_empty, has_ra_advised_op, has_fa_advised_op, auto_add_time_unit): """ Called by CliParser. Calls parse() Parsers should pass their return value through this method. """ self.ignore_empty = ignore_empty - self.auto_add = auto_add + self.has_ra_advised_op = has_ra_advised_op + self.has_fa_advised_op = has_fa_advised_op + self.auto_add_time_unit = auto_add_time_unit out = self.parse(cmd) if self.has_tokens(): self.err("Unknown arguments: " + ' '.join(self._cmd[self._currtok:])) @@ -661,9 +663,12 @@ def add_default_advised_ops(self, out): """ Add default operation actions advised values """ - if not self.auto_add or out.tag != "primitive": + if not self.has_ra_advised_op or out.tag != "primitive": return - ra_inst = ra.RAInfo(out.get('class'), out.get('type'), out.get('provider')) + ra_class = out.get('class') + if ra_class == "stonith" and not self.has_fa_advised_op: + return + ra_inst = ra.RAInfo(ra_class, out.get('type'), out.get('provider')) ra_actions_dict = ra_inst.actions() if not ra_actions_dict: return @@ -753,7 +758,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.auto_add: + if self.has_ra_advised_op: id_str = f"{bundle_id}_{name.replace('-', '_')}_{index}" inst_attrs.set('id', id_str) child_flag = True @@ -794,7 +799,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') and self.auto_add: + if name in ('interval', 'timeout') and self.auto_add_time_unit: value = add_time_unit_if_needed(value) node.set(name, value) else: @@ -1794,7 +1799,12 @@ def parse(self): return ret -def parse(s, comments=None, ignore_empty=True, auto_add=False): +def parse(s, + comments=None, + ignore_empty=True, + has_ra_advised_op=False, + has_fa_advised_op=False, + auto_add_time_units=False): ''' Input: a list of tokens (or a CLI format string). Return: a cibobject @@ -1840,7 +1850,7 @@ def parse(s, comments=None, ignore_empty=True, auto_add=False): return False try: - ret = parser.do_parse(s, ignore_empty, auto_add) + ret = parser.do_parse(s, ignore_empty, has_ra_advised_op, has_fa_advised_op, auto_add_time_units) if ret is not None and len(comments) > 0: if ret.tag in constants.defaults_tags: xmlutil.stuff_comments(ret[0], comments) diff --git a/etc/crm.conf.in b/etc/crm.conf.in index 1bbf6a18a..74cec7521 100644 --- a/etc/crm.conf.in +++ b/etc/crm.conf.in @@ -20,9 +20,14 @@ ; ignore_missing_metadata = no ; report_tool_options = ; lock_timeout = 120 -; add_advised_op_values = yes ; no_ssh = no +; For resource agent, automatically add the advised values, default is yes. +; has_ra_advised_op = yes + +; For fence agent, automatically add the advised values, default is no. +; has_fa_advised_op = no + ; 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 diff --git a/test/run-functional-tests b/test/run-functional-tests index 8d8d8b5bd..37afc158a 100755 --- a/test/run-functional-tests +++ b/test/run-functional-tests @@ -404,6 +404,7 @@ adjust_test_case() { run_origin_regression_test() { CONFIG_COROSYNC_FLAG=0 setup_cluster "hanode1" + docker_exec "hanode1" "echo -e '[core]\nhas_fa_advised_op = yes' > /etc/crm/crm.conf" docker_exec "hanode1" "sh /usr/share/crmsh/tests/regression.sh" return $? }