Blame SOURCES/bz2151166-01-fix-displaying-bool-and-integer-values.patch

3362d5
From 0da95a7f05ae7600eebe30df78a3d4622cd6b4f8 Mon Sep 17 00:00:00 2001
fdbcad
From: Ondrej Mular <omular@redhat.com>
fdbcad
Date: Wed, 7 Dec 2022 15:53:25 +0100
3362d5
Subject: [PATCH 2/5] fix displaying bool and integer values in `pcs resource
fdbcad
 config` command
fdbcad
fdbcad
---
fdbcad
 pcs/cli/resource/output.py             | 18 +++++++++---------
fdbcad
 pcs_test/resources/cib-resources.xml   |  2 +-
fdbcad
 pcs_test/tier1/legacy/test_resource.py |  3 ++-
fdbcad
 pcs_test/tools/resources_dto.py        |  4 ++--
fdbcad
 4 files changed, 14 insertions(+), 13 deletions(-)
fdbcad
fdbcad
diff --git a/pcs/cli/resource/output.py b/pcs/cli/resource/output.py
fdbcad
index 6d1fad16..0705d27b 100644
fdbcad
--- a/pcs/cli/resource/output.py
fdbcad
+++ b/pcs/cli/resource/output.py
fdbcad
@@ -69,9 +69,9 @@ def _resource_operation_to_pairs(
fdbcad
         pairs.append(("interval-origin", operation_dto.interval_origin))
fdbcad
     if operation_dto.timeout:
fdbcad
         pairs.append(("timeout", operation_dto.timeout))
fdbcad
-    if operation_dto.enabled:
fdbcad
+    if operation_dto.enabled is not None:
fdbcad
         pairs.append(("enabled", _bool_to_cli_value(operation_dto.enabled)))
fdbcad
-    if operation_dto.record_pending:
fdbcad
+    if operation_dto.record_pending is not None:
fdbcad
         pairs.append(
fdbcad
             ("record-pending", _bool_to_cli_value(operation_dto.record_pending))
fdbcad
         )
fdbcad
@@ -477,13 +477,13 @@ def _resource_bundle_container_options_to_pairs(
fdbcad
     options: CibResourceBundleContainerRuntimeOptionsDto,
fdbcad
 ) -> List[Tuple[str, str]]:
fdbcad
     option_list = [("image", options.image)]
fdbcad
-    if options.replicas:
fdbcad
+    if options.replicas is not None:
fdbcad
         option_list.append(("replicas", str(options.replicas)))
fdbcad
-    if options.replicas_per_host:
fdbcad
+    if options.replicas_per_host is not None:
fdbcad
         option_list.append(
fdbcad
             ("replicas-per-host", str(options.replicas_per_host))
fdbcad
         )
fdbcad
-    if options.promoted_max:
fdbcad
+    if options.promoted_max is not None:
fdbcad
         option_list.append(("promoted-max", str(options.promoted_max)))
fdbcad
     if options.run_command:
fdbcad
         option_list.append(("run-command", options.run_command))
fdbcad
@@ -508,7 +508,7 @@ def _resource_bundle_network_options_to_pairs(
fdbcad
         network_options.append(
fdbcad
             ("ip-range-start", bundle_network_dto.ip_range_start)
fdbcad
         )
fdbcad
-    if bundle_network_dto.control_port:
fdbcad
+    if bundle_network_dto.control_port is not None:
fdbcad
         network_options.append(
fdbcad
             ("control-port", str(bundle_network_dto.control_port))
fdbcad
         )
fdbcad
@@ -516,7 +516,7 @@ def _resource_bundle_network_options_to_pairs(
fdbcad
         network_options.append(
fdbcad
             ("host-interface", bundle_network_dto.host_interface)
fdbcad
         )
fdbcad
-    if bundle_network_dto.host_netmask:
fdbcad
+    if bundle_network_dto.host_netmask is not None:
fdbcad
         network_options.append(
fdbcad
             ("host-netmask", str(bundle_network_dto.host_netmask))
fdbcad
         )
fdbcad
@@ -531,9 +531,9 @@ def _resource_bundle_port_mapping_to_pairs(
fdbcad
     bundle_net_port_mapping_dto: CibResourceBundlePortMappingDto,
fdbcad
 ) -> List[Tuple[str, str]]:
fdbcad
     mapping = []
fdbcad
-    if bundle_net_port_mapping_dto.port:
fdbcad
+    if bundle_net_port_mapping_dto.port is not None:
fdbcad
         mapping.append(("port", str(bundle_net_port_mapping_dto.port)))
fdbcad
-    if bundle_net_port_mapping_dto.internal_port:
fdbcad
+    if bundle_net_port_mapping_dto.internal_port is not None:
fdbcad
         mapping.append(
fdbcad
             ("internal-port", str(bundle_net_port_mapping_dto.internal_port))
fdbcad
         )
fdbcad
diff --git a/pcs_test/resources/cib-resources.xml b/pcs_test/resources/cib-resources.xml
fdbcad
index 67cf5178..524b8fbb 100644
fdbcad
--- a/pcs_test/resources/cib-resources.xml
fdbcad
+++ b/pcs_test/resources/cib-resources.xml
fdbcad
@@ -53,7 +53,7 @@
fdbcad
             </instance_attributes>
fdbcad
         </op>
fdbcad
           <op name="migrate_from" timeout="20s" interval="0s" id="R7-migrate_from-interval-0s"/>
fdbcad
-          <op name="migrate_to" timeout="20s" interval="0s" id="R7-migrate_to-interval-0s"/>
fdbcad
+          <op name="migrate_to" timeout="20s" interval="0s" id="R7-migrate_to-interval-0s" enabled="false" record-pending="false"/>
fdbcad
           <op name="monitor" timeout="20s" interval="10s" id="R7-monitor-interval-10s"/>
fdbcad
           <op name="reload" timeout="20s" interval="0s" id="R7-reload-interval-0s"/>
fdbcad
           <op name="reload-agent" timeout="20s" interval="0s" id="R7-reload-agent-interval-0s"/>
fdbcad
diff --git a/pcs_test/tier1/legacy/test_resource.py b/pcs_test/tier1/legacy/test_resource.py
3362d5
index 2ea5c423..65ad1090 100644
fdbcad
--- a/pcs_test/tier1/legacy/test_resource.py
fdbcad
+++ b/pcs_test/tier1/legacy/test_resource.py
3362d5
@@ -753,7 +753,7 @@ Error: moni=tor does not appear to be a valid operation action
fdbcad
 
fdbcad
         o, r = pcs(
fdbcad
             self.temp_cib.name,
fdbcad
-            "resource create --no-default-ops OPTest ocf:heartbeat:Dummy op monitor interval=30s OCF_CHECK_LEVEL=1 op monitor interval=25s OCF_CHECK_LEVEL=1".split(),
fdbcad
+            "resource create --no-default-ops OPTest ocf:heartbeat:Dummy op monitor interval=30s OCF_CHECK_LEVEL=1 op monitor interval=25s OCF_CHECK_LEVEL=1 enabled=0".split(),
fdbcad
         )
fdbcad
         ac(o, "")
fdbcad
         assert r == 0
3362d5
@@ -770,6 +770,7 @@ Error: moni=tor does not appear to be a valid operation action
fdbcad
                   OCF_CHECK_LEVEL=1
fdbcad
                 monitor: OPTest-monitor-interval-25s
fdbcad
                   interval=25s
fdbcad
+                  enabled=0
fdbcad
                   OCF_CHECK_LEVEL=1
fdbcad
             """
fdbcad
             ),
fdbcad
diff --git a/pcs_test/tools/resources_dto.py b/pcs_test/tools/resources_dto.py
fdbcad
index 8f46f6dd..a980ec80 100644
fdbcad
--- a/pcs_test/tools/resources_dto.py
fdbcad
+++ b/pcs_test/tools/resources_dto.py
fdbcad
@@ -233,8 +233,8 @@ PRIMITIVE_R7 = CibResourcePrimitiveDto(
fdbcad
             start_delay=None,
fdbcad
             interval_origin=None,
fdbcad
             timeout="20s",
fdbcad
-            enabled=None,
fdbcad
-            record_pending=None,
fdbcad
+            enabled=False,
fdbcad
+            record_pending=False,
fdbcad
             role=None,
fdbcad
             on_fail=None,
fdbcad
             meta_attributes=[],
fdbcad
-- 
3362d5
2.39.0
fdbcad