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

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