Skip to content

Commit

Permalink
fix displaying bool and integer values in pcs resource config command
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmular committed Dec 8, 2022
1 parent 3776ab1 commit f9de2cb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
self-validation feature when the resource is already misconfigured
([rhbz#2151511])

### Fixed
- Displaying bool and integer values in `pcs resource config` command
([rhbz#2151166], [ghissue#604])

[ghissue#604]: https://github.com/ClusterLabs/pcs/issues/604
[rhbz#2151166]: https://bugzilla.redhat.com/show_bug.cgi?id=2151166
[rhbz#2151511]: https://bugzilla.redhat.com/show_bug.cgi?id=2151511


Expand Down
18 changes: 9 additions & 9 deletions pcs/cli/resource/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def _resource_operation_to_pairs(
pairs.append(("interval-origin", operation_dto.interval_origin))
if operation_dto.timeout:
pairs.append(("timeout", operation_dto.timeout))
if operation_dto.enabled:
if operation_dto.enabled is not None:
pairs.append(("enabled", _bool_to_cli_value(operation_dto.enabled)))
if operation_dto.record_pending:
if operation_dto.record_pending is not None:
pairs.append(
("record-pending", _bool_to_cli_value(operation_dto.record_pending))
)
Expand Down Expand Up @@ -477,13 +477,13 @@ def _resource_bundle_container_options_to_pairs(
options: CibResourceBundleContainerRuntimeOptionsDto,
) -> List[Tuple[str, str]]:
option_list = [("image", options.image)]
if options.replicas:
if options.replicas is not None:
option_list.append(("replicas", str(options.replicas)))
if options.replicas_per_host:
if options.replicas_per_host is not None:
option_list.append(
("replicas-per-host", str(options.replicas_per_host))
)
if options.promoted_max:
if options.promoted_max is not None:
option_list.append(("promoted-max", str(options.promoted_max)))
if options.run_command:
option_list.append(("run-command", options.run_command))
Expand All @@ -508,15 +508,15 @@ def _resource_bundle_network_options_to_pairs(
network_options.append(
("ip-range-start", bundle_network_dto.ip_range_start)
)
if bundle_network_dto.control_port:
if bundle_network_dto.control_port is not None:
network_options.append(
("control-port", str(bundle_network_dto.control_port))
)
if bundle_network_dto.host_interface:
network_options.append(
("host-interface", bundle_network_dto.host_interface)
)
if bundle_network_dto.host_netmask:
if bundle_network_dto.host_netmask is not None:
network_options.append(
("host-netmask", str(bundle_network_dto.host_netmask))
)
Expand All @@ -531,9 +531,9 @@ def _resource_bundle_port_mapping_to_pairs(
bundle_net_port_mapping_dto: CibResourceBundlePortMappingDto,
) -> List[Tuple[str, str]]:
mapping = []
if bundle_net_port_mapping_dto.port:
if bundle_net_port_mapping_dto.port is not None:
mapping.append(("port", str(bundle_net_port_mapping_dto.port)))
if bundle_net_port_mapping_dto.internal_port:
if bundle_net_port_mapping_dto.internal_port is not None:
mapping.append(
("internal-port", str(bundle_net_port_mapping_dto.internal_port))
)
Expand Down
2 changes: 1 addition & 1 deletion pcs_test/resources/cib-resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</instance_attributes>
</op>
<op name="migrate_from" timeout="20s" interval="0s" id="R7-migrate_from-interval-0s"/>
<op name="migrate_to" timeout="20s" interval="0s" id="R7-migrate_to-interval-0s"/>
<op name="migrate_to" timeout="20s" interval="0s" id="R7-migrate_to-interval-0s" enabled="false" record-pending="false"/>
<op name="monitor" timeout="20s" interval="10s" id="R7-monitor-interval-10s"/>
<op name="reload" timeout="20s" interval="0s" id="R7-reload-interval-0s"/>
<op name="reload-agent" timeout="20s" interval="0s" id="R7-reload-agent-interval-0s"/>
Expand Down
3 changes: 2 additions & 1 deletion pcs_test/tier1/legacy/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def testAddOperation(self):

o, r = pcs(
self.temp_cib.name,
"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(),
"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(),
)
ac(o, "")
assert r == 0
Expand All @@ -770,6 +770,7 @@ def testAddOperation(self):
OCF_CHECK_LEVEL=1
monitor: OPTest-monitor-interval-25s
interval=25s
enabled=0
OCF_CHECK_LEVEL=1
"""
),
Expand Down
4 changes: 2 additions & 2 deletions pcs_test/tools/resources_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ def _primitive_fixture(primitive_id, agent_name=DUMMY_AGENT_NAME):
start_delay=None,
interval_origin=None,
timeout="20s",
enabled=None,
record_pending=None,
enabled=False,
record_pending=False,
role=None,
on_fail=None,
meta_attributes=[],
Expand Down

0 comments on commit f9de2cb

Please sign in to comment.