Skip to content

Commit

Permalink
Fixed Keyrror when accessing se-version in list_permitted_xxx()
Browse files Browse the repository at this point in the history
Details:

* Fixed a bug where 'Console.list_permitted_partitions()' and
  'Console.list_permitted_lpars()' when run on HMC/SE version 2.14.0 failed
  when accessing the 'se-version' property of the partition unconditionally.
  That property was introduced only in HMC/SE version 2.14.1. (issue #816)

Signed-off-by: Andreas Maier <[email protected]>
  • Loading branch information
andy-maier committed Aug 2, 2021
1 parent 4bc4da8 commit 8b72f2b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ Released: not yet

**Bug fixes:**

* Fixed a bug where 'Console.list_permitted_partitions()' and
'Console.list_permitted_lpars()' when run on HMC/SE version 2.14.0 failed
when accessing the 'se-version' property of the partition unconditionally.
That property was introduced only in HMC/SE version 2.14.1. (issue #816)

**Enhancements:**

**Cleanup:**
Expand Down
22 changes: 13 additions & 9 deletions zhmcclient/_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ def list_permitted_partitions(
"""
List the permitted partitions of CPCs in DPM mode managed by this HMC.
*Added in version 1.0; requires HMC 2.14.0 or later*
*Added in version 1.0; requires HMC 2.14.0 or later and otherwise
raises HTTPError(404.4).*
Any CPCs in classic mode managed by the HMC will be ignored for this
operation.
Expand Down Expand Up @@ -635,6 +636,7 @@ def list_permitted_partitions(

# Perform the operation with the HMC, including any server-side
# filtering.
# Note: "List Permitted Partitions" was introduced in HMC/SE 2.14.0.
uri = self.uri + '/operations/list-permitted-partitions' + query_parms
result = self.manager.session.get(uri)

Expand All @@ -648,18 +650,19 @@ def list_permitted_partitions(
# And the following properties for their parent CPC:
# * cpc-name (CPC property 'name')
# * cpc-object-uri (CPC property 'object-uri')
# * se-version (CPC property 'se-version')
# * se-version (CPC property 'se-version') (if >=2.14.1)

# Create a 'skeleton' local Cpc object we can hang the
# Partition objects off of, even if the user does not have
# access permissions to these CPCs. Note that different
# partitions can have different parent CPCs.
cpc_props = {}
if 'se-version' in partition_item:
cpc_props['se-version'] = partition_item['se-version']
cpc = self.manager.client.cpcs.find_local(
partition_item['cpc-name'],
partition_item['cpc-object-uri'],
{
'se-version': partition_item['se-version'],
},
cpc_props,
)

partition_obj = cpc.partitions.resource_object(
Expand Down Expand Up @@ -765,18 +768,19 @@ def list_permitted_lpars(
# And the following properties for their parent CPC:
# * cpc-name (CPC property 'name')
# * cpc-object-uri (CPC property 'object-uri')
# * se-version (CPC property 'se-version')
# * se-version (CPC property 'se-version') (if >=2.14.1)

# Create a 'skeleton' local Cpc object we can hang the
# Partition objects off of, even if the user does not have
# access permissions to these CPCs. Note that different
# partitions can have different parent CPCs.
cpc_props = {}
if 'se-version' in lpar_item:
cpc_props['se-version'] = lpar_item['se-version']
cpc = self.manager.client.cpcs.find_local(
lpar_item['cpc-name'],
lpar_item['cpc-object-uri'],
{
'se-version': lpar_item['se-version'],
},
cpc_props,
)

lpar_obj = cpc.lpars.resource_object(
Expand Down

0 comments on commit 8b72f2b

Please sign in to comment.