Skip to content

Commit

Permalink
Add a NVMe-FC tab to the Advanced Storage screen
Browse files Browse the repository at this point in the history
Resolves: rhbz#2107346
(cherry picked from commit bd0c061)
  • Loading branch information
VladimirSlavik committed Jan 25, 2023
1 parent b5bd977 commit 8e8627e
Show file tree
Hide file tree
Showing 5 changed files with 753 additions and 28 deletions.
9 changes: 9 additions & 0 deletions pyanaconda/modules/common/structures/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ def attrs(self) -> Dict[Str, Str]:
namespace
path-id
Attributes for NVMe Fabrics:
nsid
eui64
nguid
controllers-id
transports-type
transports-address
subsystems-nqn
Attributes for ZFCP:
fcp-lun
wwpn
Expand Down
34 changes: 34 additions & 0 deletions pyanaconda/modules/storage/devicetree/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Red Hat, Inc.
#
from abc import abstractmethod, ABC
from functools import partial

from blivet.formats import get_format
from blivet.size import Size
Expand Down Expand Up @@ -104,6 +105,8 @@ def get_device_data(self, name):
self._set_device_data_iscsi(device, data)
elif device.type == "nvdimm":
self._set_device_data_nvdimm(device, data)
elif device.type == "nvme-fabrics":
self._set_device_data_nvme_fabrics(device, data)
elif device.type == "zfcp":
self._set_device_data_zfcp(device, data)

Expand Down Expand Up @@ -155,6 +158,18 @@ def _set_device_data_nvdimm(self, device, data):
data.attrs["namespace"] = self._get_attribute(device, "devname")
data.attrs["path-id"] = self._get_attribute(device, "id_path")

def _set_device_data_nvme_fabrics(self, device, data):
"""Set data for an NVMe Fabrics device."""
data.attrs["nsid"] = self._get_attribute(device, "nsid")
data.attrs["eui64"] = self._get_attribute(device, "eui64")
data.attrs["nguid"] = self._get_attribute(device, "nguid")

get_attrs = partial(self._get_attribute_list, device.controllers)
data.attrs["controllers-id"] = get_attrs("id")
data.attrs["transports-type"] = get_attrs("transport")
data.attrs["transports-address"] = get_attrs("transport_address")
data.attrs["subsystems-nqn"] = get_attrs("subsysnqn")

def _set_device_data_zfcp(self, device, data):
"""Set data for a ZFCP device."""
data.attrs["fcp-lun"] = self._get_attribute(device, "fcp_lun")
Expand Down Expand Up @@ -273,6 +288,25 @@ def _get_attribute(self, obj, name):

return str(value)

def _get_attribute_list(self, iterable, name):
"""Get a list of attributes of the given objects.
Create a comma-separated list of sorted unique attribute values.
See the _get_attribute method for more info.
:param iterable: a list of objects
:param name: an attribute name
:return: a string or None
"""
# Collect values.
values = [self._get_attribute(obj, name) for obj in iterable]

# Skip duplicates and unset values.
values = set(filter(None, values))

# Format sorted values if any.
return ", ".join(sorted(values)) or None

def _prune_attributes(self, attrs):
"""Prune the unset values of attributes.
Expand Down
Loading

0 comments on commit 8e8627e

Please sign in to comment.