Skip to content

Commit

Permalink
Fixed zhmc_nic_list
Browse files Browse the repository at this point in the history
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 <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Jun 23, 2023
1 parent 1588456 commit 6d00dc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
Expand Down
9 changes: 6 additions & 3 deletions plugins/modules/zhmc_nic_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 = []
Expand Down

0 comments on commit 6d00dc9

Please sign in to comment.