From b1706264848ab935dad3f9c4f58299c97ada96dd Mon Sep 17 00:00:00 2001
From: xin liang <xliang@suse.com>
Date: Thu, 10 Oct 2024 15:05:11 +0800
Subject: [PATCH 1/3] Dev: cibconfig: Use another variables to distinguish the
 concept of adding default

operation values from the concept of adding promotable default advised meta attributes
---
 crmsh/cibconfig.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/crmsh/cibconfig.py b/crmsh/cibconfig.py
index da7137fb26..723de87eb0 100644
--- a/crmsh/cibconfig.py
+++ b/crmsh/cibconfig.py
@@ -793,7 +793,7 @@ def id_for_node(node, id_hint=None):
     return obj_id
 
 
-def postprocess_cli(node, oldnode=None, id_hint=None, complete_advised=False):
+def postprocess_cli(node, oldnode=None, id_hint=None, promotable_default_meta=False):
     """
     input: unprocessed but parsed XML
     output: XML, obj_type, obj_id
@@ -816,14 +816,14 @@ def postprocess_cli(node, oldnode=None, id_hint=None, complete_advised=False):
     resolve_references(node)
     if oldnode is not None:
         remove_id_used_attributes(oldnode)
-    if complete_advised:
-        complete_advised_meta(node)
+    if promotable_default_meta:
+        add_promotable_default_meta_attr(node)
     return node, obj_type, obj_id
 
 
-def complete_advised_meta(node):
+def add_promotable_default_meta_attr(node):
     """
-    Complete advised meta attributes
+    Add promotable default advised meta attributes
     """
     if node.tag != "clone":
         return
@@ -856,18 +856,20 @@ def parse_cli_to_xml(cli, oldnode=None):
     """
     node = None
     complete = False
+    default_promotable_meta = False
     comments = []
     if isinstance(cli, str):
         for s in lines2cli(cli):
             node = parse.parse(s, comments=comments)
     else:  # should be a pre-tokenized list
         complete = True
+        default_promotable_meta = True
         node = parse.parse(cli, comments=comments, ignore_empty=False, complete_advised=complete)
     if node is False:
         return None, None, None
     elif node is None:
         return None, None, None
-    return postprocess_cli(node, oldnode, complete_advised=complete)
+    return postprocess_cli(node, oldnode, promotable_default_meta=default_promotable_meta)
 
 #
 # cib element classes (CibObject the parent class)

From b39e1b3468b43220882e77dcd8fc67ca037c6888 Mon Sep 17 00:00:00 2001
From: xin liang <xliang@suse.com>
Date: Thu, 10 Oct 2024 15:09:03 +0800
Subject: [PATCH 2/3] Fix: cibconfig: Disable auto add advise values for
 operations (bsc#1231386)

- Dev: Add option core.has_ra_advised_op;
- Since this auto-add feature might surprise users, we should disable it
  by setting the option 'has_ra_advised_op' value to 'no'.
---
 crmsh/cibconfig.py | 6 +++---
 crmsh/config.py    | 1 +
 etc/crm.conf.in    | 1 +
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/crmsh/cibconfig.py b/crmsh/cibconfig.py
index 723de87eb0..fafbb01fd5 100644
--- a/crmsh/cibconfig.py
+++ b/crmsh/cibconfig.py
@@ -855,16 +855,16 @@ def parse_cli_to_xml(cli, oldnode=None):
     output: XML, obj_type, obj_id
     """
     node = None
-    complete = False
+    has_ra_advised_op = False
     default_promotable_meta = False
     comments = []
     if isinstance(cli, str):
         for s in lines2cli(cli):
             node = parse.parse(s, comments=comments)
     else:  # should be a pre-tokenized list
-        complete = True
+        has_ra_advised_op = config.core.has_ra_advised_op
         default_promotable_meta = True
-        node = parse.parse(cli, comments=comments, ignore_empty=False, complete_advised=complete)
+        node = parse.parse(cli, comments=comments, ignore_empty=False, complete_advised=has_ra_advised_op)
     if node is False:
         return None, None, None
     elif node is None:
diff --git a/crmsh/config.py b/crmsh/config.py
index 20dbfd5572..fae4032239 100644
--- a/crmsh/config.py
+++ b/crmsh/config.py
@@ -253,6 +253,7 @@ def get(self, value):
         'report_tool_options': opt_string(''),
         'lock_timeout': opt_string('120'),
         'OCF_1_1_SUPPORT': opt_boolean('no'),
+        'has_ra_advised_op': opt_boolean('no'),
         'obscure_pattern': opt_string('passw*')
     },
     'path': {
diff --git a/etc/crm.conf.in b/etc/crm.conf.in
index 39f8d5c199..807f5f61ba 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
+; has_ra_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

From c3318ca0ac1c87d0416e00900b54fb6e3a492a57 Mon Sep 17 00:00:00 2001
From: xin liang <xliang@suse.com>
Date: Thu, 10 Oct 2024 15:20:07 +0800
Subject: [PATCH 3/3] Dev: behave: Adjust functional test for previous commit

---
 test/run-functional-tests | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/run-functional-tests b/test/run-functional-tests
index 579bbfae51..db436aa3a1 100755
--- a/test/run-functional-tests
+++ b/test/run-functional-tests
@@ -337,6 +337,7 @@ adjust_test_case() {
 run_origin_regression_test() {
 	CONFIG_COROSYNC_FLAG=0
 	setup_cluster "hanode1"
+        docker_exec "hanode1" "echo -e '[core]\nhas_ra_advised_op = yes' > /etc/crm/crm.conf"
 	docker_exec "hanode1" "sh /usr/share/crmsh/tests/regression.sh"
 	return $?
 }
