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

9183b6
From 1edf85bdabadf10708f63c0767991c7f4150e842 Mon Sep 17 00:00:00 2001
a58e1c
From: Ondrej Mular <omular@redhat.com>
a58e1c
Date: Wed, 7 Dec 2022 15:53:25 +0100
9183b6
Subject: [PATCH 3/3] fix displaying bool and integer values in `pcs resource
a58e1c
 config` command
a58e1c
a58e1c
---
9183b6
 CHANGELOG.md                           |  4 ++++
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 ++--
9183b6
 5 files changed, 18 insertions(+), 13 deletions(-)
a58e1c
9183b6
diff --git a/CHANGELOG.md b/CHANGELOG.md
9183b6
index ed2083af..378cca50 100644
9183b6
--- a/CHANGELOG.md
9183b6
+++ b/CHANGELOG.md
9183b6
@@ -9,7 +9,11 @@
9183b6
 
9183b6
 ### Fixed
9183b6
 - Graceful stopping pcsd service using `systemctl stop pcsd` command
9183b6
+- Displaying bool and integer values in `pcs resource config` command
9183b6
+  ([rhbz#2151164], [ghissue#604])
9183b6
 
9183b6
+[ghissue#604]: https://github.com/ClusterLabs/pcs/issues/604
9183b6
+[rhbz#2151164]: https://bugzilla.redhat.com/show_bug.cgi?id=2151164
9183b6
 [rhbz#2151524]: https://bugzilla.redhat.com/show_bug.cgi?id=2151524
9183b6
 
9183b6
 
a58e1c
diff --git a/pcs/cli/resource/output.py b/pcs/cli/resource/output.py
9183b6
index daa713a0..dbdf009f 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
9183b6
index 1e256b42..9242fd4a 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
9183b6
index c097a937..3ba32ec7 100644
a58e1c
--- a/pcs_test/tier1/legacy/test_resource.py
a58e1c
+++ b/pcs_test/tier1/legacy/test_resource.py
9183b6
@@ -774,7 +774,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
9183b6
@@ -791,6 +791,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
9183b6
index e010037e..af0b4ac3 100644
a58e1c
--- a/pcs_test/tools/resources_dto.py
a58e1c
+++ b/pcs_test/tools/resources_dto.py
9183b6
@@ -236,8 +236,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