Skip to content

Commit

Permalink
Check that specified CPC exists
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Maier <[email protected]>
  • Loading branch information
andy-maier committed Feb 4, 2024
1 parent 5094e9e commit 98eaf64
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions zhmccli/_cmd_lpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def find_lpar(cmd_ctx, client, cpc_name, lpar_name):
"""
Find an LPAR by name and return its resource object.
"""
if isinstance(cpc_or_name, zhmcclient.Cpc):
cpc_name = cpc_or_name.name
cpc = cpc_or_name
else:
cpc_name = cpc_or_name
cpc = find_cpc(cmd_ctx, client, cpc_name)

if client.version_info() >= API_VERSION_HMC_2_14_0:
# This approach is faster than going through the CPC.
# In addition, starting with HMC API version 3.6 (an update to
Expand All @@ -51,9 +58,8 @@ def find_lpar(cmd_ctx, client, cpc_name, lpar_name):
format(p=lpar_name, c=cpc_name),
cmd_ctx.error_format)
lpar = lpars[0]
else:
cpc = find_cpc(cmd_ctx, client, cpc_name)

else:
# The CPC must not be in DPM mode. We don't check that because it would
# cause a GET to the CPC resource that we otherwise don't need.
try:
Expand Down

0 comments on commit 98eaf64

Please sign in to comment.