From 4d375004dd11b7ddc4dd3f211c06008d71626dcf Mon Sep 17 00:00:00 2001
From: Tomas Jelinek <tojeline@redhat.com>
Date: Tue, 30 Apr 2024 15:31:06 +0200
Subject: [PATCH] export rule constraints in a non-deprecated way

---
 pcs/cli/constraint/output/location.py    | 4 ++--
 pcs_test/tier1/constraint/test_config.py | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/pcs/cli/constraint/output/location.py b/pcs/cli/constraint/output/location.py
index 25ac646a..141959d5 100644
--- a/pcs/cli/constraint/output/location.py
+++ b/pcs/cli/constraint/output/location.py
@@ -190,7 +190,7 @@ def _add_rule_cmd(constraint_id: str, rule: CibRuleExpressionDto) -> list[str]:
         indent(
             [
                 pairs_to_cmd([("id", rule.id)] + _rule_to_cmd_pairs(rule)),
-                shlex.join(shlex.split(rule.as_string)),
+                shlex.quote(rule.as_string),
             ],
             indent_step=INDENT_STEP,
         )
@@ -221,7 +221,7 @@ def _plain_constraint_rule_to_cmd(
                     + _attributes_to_pairs(constraint_dto.attributes)
                     + _rule_to_cmd_pairs(first_rule)
                 ),
-                shlex.join(shlex.split(first_rule.as_string)),
+                shlex.quote(first_rule.as_string),
             ],
             indent_step=INDENT_STEP,
         )
diff --git a/pcs_test/tier1/constraint/test_config.py b/pcs_test/tier1/constraint/test_config.py
index 1ce5a2a5..de39b3a5 100644
--- a/pcs_test/tier1/constraint/test_config.py
+++ b/pcs_test/tier1/constraint/test_config.py
@@ -191,14 +191,14 @@ class ConstraintConfigCmdSpaceInDate(ConstraintConfigCmdMixin, TestCase):
             (
                 "pcs -- constraint location resource%R1 rule \\\n"
                 "  id=location-R1-rule constraint-id=location-R1 score=INFINITY \\\n"
-                "  '#uname' eq node1 and date gt 2023-01-01T12:00 and "
+                "  '#uname eq node1 and date gt 2023-01-01T12:00 and "
                 "date lt 2023-12-31T12:00 and date in_range 2023-01-01T12:00 "
-                "to 2023-12-31T12:00;\n"
+                "to 2023-12-31T12:00';\n"
                 "pcs -- constraint rule add location-R1 \\\n"
                 "  id=location-R1-rule-1 score=INFINITY \\\n"
-                "  '#uname' eq node1 and date gt 2023-01-01T12:00 and "
+                "  '#uname eq node1 and date gt 2023-01-01T12:00 and "
                 "date lt 2023-12-31T12:00 and date in_range 2023-01-01T12:00 "
-                "to 2023-12-31T12:00\n"
+                "to 2023-12-31T12:00'\n"
             ),
         )
 
-- 
2.25.1

