From 6d00dc9cecdcd50b24cd00317566b8c01d65436c Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Fri, 23 Jun 2023 12:13:32 +0200 Subject: [PATCH] Fixed zhmc_nic_list Details: * Fixed issue in the new zhmc_nic_list module that resulted in TypeError. This was caused by list_permitted_partitions() not working with filter arguments, and the error handling of that had the issue: Fixed the error handling, and fell back to using the traditional partition find approach via the CPC to circumvent the issue in list_permitted_partitions(). Signed-off-by: Andreas Maier --- docs/source/release_notes.rst | 2 ++ plugins/modules/zhmc_nic_list.py | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/source/release_notes.rst b/docs/source/release_notes.rst index f370108e9..401fe1ba8 100644 --- a/docs/source/release_notes.rst +++ b/docs/source/release_notes.rst @@ -36,6 +36,8 @@ Availability: `AutomationHub`_, `Galaxy`_, `GitHub`_ * Addressed safety issues from 6/23, by increasing 'requests' to 2.31.0 on Python >=3.7. +* Fixed issue in the new zhmc_nic_list module that resulted in TypeError. + **Enhancements:** **Cleanup:** diff --git a/plugins/modules/zhmc_nic_list.py b/plugins/modules/zhmc_nic_list.py index a8f76dd5e..88e462918 100644 --- a/plugins/modules/zhmc_nic_list.py +++ b/plugins/modules/zhmc_nic_list.py @@ -220,7 +220,9 @@ def perform_list(params): # a z13 CPC. hmc_version = client.query_api_version()['hmc-version'] hmc_version_info = [int(x) for x in hmc_version.split('.')] - if hmc_version_info < [2, 14, 0]: + # TODO: Filtering with list_permitted_partitions() does not work. + # Using traditional approach for the time being. + if hmc_version_info < [2, 14, 0] or True: # Find the partition via the CPC (traditional way) LOGGER.debug("Finding partition %s via CPC %s", partition_name, cpc_name) @@ -232,17 +234,18 @@ def perform_list(params): "partitions of CPC %s", partition_name, cpc_name) filter_args = { 'cpc-name': cpc_name, - 'partition-name': partition_name + 'name': partition_name } partitions = client.consoles.console.list_permitted_partitions( filter_args=filter_args) if len(partitions) == 0: - raise zhmcclient.NotFound( + raise Error( "Partition {0!r} does not exist in CPC {1!r}". format(partition_name, cpc_name)) partition = partitions[0] # The default exception handling is sufficient for the above. + LOGGER.debug("Listing NICs of partition %s", partition.name) nics = partition.nics.list() nic_list = []