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

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