export rule constraints in a non-deprecated way

This commit is contained in:
bixiaoyan 2024-05-11 16:25:59 +08:00
parent 7e652e5cb3
commit 044696c383
2 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,58 @@
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 node2 and date gt 2023-01-01T12:00 and "
+ " '#uname eq node2 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

View File

@ -1,6 +1,6 @@
Name: pcs
Version: 0.11.7
Release: 11
Release: 12
License: GPL-2.0-only AND Apache-2.0 AND MIT AND BSD-3-Clause AND (BSD-2-Clause OR Ruby) AND (BSD-2-Clause OR GPL-2.0-or-later)
URL: https://github.com/ClusterLabs/pcs
Group: System Environment/Base
@ -406,6 +406,9 @@ run_all_tests
%license pyagentx_LICENSE.txt
%changelog
* Sat May 11 2024 bixiaoyan <bixiaoyan@kylinos.cn> - 0.11.7-12
- export rule constraints in a non-deprecated way
* Wed Apr 24 2024 bizhiyuan <bizhiyuan@kylinos.cn> - 0.11.7-11
- increase a timeout in a test