Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changes/2239.incompatible.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FC-type storage groups do not have a property "candidate-adapter-port-uris".
The :meth:`zhmcclient.StorageGroup.list_candidate_adapter_ports` method
raised ``KeyError`` when called for FC-type storage groups. However, this was
not documented. Changed the method to return `None` when called for
FC-type storage groups and documented that. This is an incompatible change
for users that handle that ``KeyError`` exception. If you have such code,
it needs to be changed to test for `None` instead.
40 changes: 22 additions & 18 deletions zhmcclient/_storage_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,9 @@ def list_candidate_adapter_ports(self, full_properties=False):
Return the current candidate storage adapter port list of this FCP
storage group.

This operation only applies to storage groups of type "fcp".
This operation only returns candicate adapter ports for storage groups
of type "fcp".
When called for storage groups of type "fc", it returns `None`.

The result reflects the actual list of ports used by the CPC, including
any changes that have been made during discovery. The source for this
Expand All @@ -693,12 +695,12 @@ def list_candidate_adapter_ports(self, full_properties=False):
following short set: "element-uri", "element-id", "class",
"parent".

TODO: Verify short list of properties.

Returns:

List of :class:`~zhmcclient.Port` objects representing the
current candidate storage adapter ports of this storage group.
List of :class:`~zhmcclient.Port` objects representing the current
candidate storage adapter ports of this FCP-type storage group.

`None` for FC-type storage groups.

Raises:

Expand All @@ -709,20 +711,22 @@ def list_candidate_adapter_ports(self, full_properties=False):
"""
sg_cpc = self.cpc
adapter_mgr = sg_cpc.adapters
port_uris = self.prop('candidate-adapter-port-uris', None)
if port_uris is None:
# FC-type storage group
return None
port_list = []
port_uris = self.get_property('candidate-adapter-port-uris')
if port_uris:
for port_uri in port_uris:
m = re.match(r'^(/api/adapters/[^/]*)/.*', port_uri)

adapter_uri = m.group(1)
adapter = adapter_mgr.resource_object(adapter_uri)

port_mgr = adapter.ports
port = port_mgr.resource_object(port_uri)
port_list.append(port)
if full_properties:
port.pull_full_properties()
for port_uri in port_uris:
m = re.match(r'^(/api/adapters/[^/]*)/.*', port_uri)

adapter_uri = m.group(1)
adapter = adapter_mgr.resource_object(adapter_uri)

port_mgr = adapter.ports
port = port_mgr.resource_object(port_uri)
port_list.append(port)
if full_properties:
port.pull_full_properties()

return port_list

Expand Down