summaryrefslogtreecommitdiffstats
path: root/staslib
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-06 07:52:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-06 07:52:00 +0000
commit9a81a6cf9f75a764ad8b32bd1fc4ee64e200f172 (patch)
treebffae7d405fb77e945d668d2269b2359686ceb3e /staslib
parentReleasing debian version 2.3~rc2-1. (diff)
downloadnvme-stas-9a81a6cf9f75a764ad8b32bd1fc4ee64e200f172.tar.xz
nvme-stas-9a81a6cf9f75a764ad8b32bd1fc4ee64e200f172.zip
Merging upstream version 2.3~rc3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'staslib')
-rw-r--r--staslib/avahi.py8
-rw-r--r--staslib/conf.py17
-rw-r--r--staslib/service.py20
-rw-r--r--staslib/stacd.idl3
-rw-r--r--staslib/stafd.idl9
-rw-r--r--staslib/stas.py16
-rw-r--r--staslib/trid.py62
-rw-r--r--staslib/udev.py10
8 files changed, 90 insertions, 55 deletions
diff --git a/staslib/avahi.py b/staslib/avahi.py
index f29f89d..84a0b2a 100644
--- a/staslib/avahi.py
+++ b/staslib/avahi.py
@@ -333,15 +333,19 @@ class Avahi: # pylint: disable=too-many-instance-attributes
'transport': tcp,
'traddr': str(),
'trsvcid': str(),
- 'host-iface': str(),
'subsysnqn': 'nqn.2014-08.org.nvmexpress.discovery',
+ 'host-traddr': str(),
+ 'host-iface': str(),
+ 'host-nqn': str(),
},
{
'transport': tcp,
'traddr': str(),
'trsvcid': str(),
- 'host-iface': str(),
'subsysnqn': 'nqn.2014-08.org.nvmexpress.discovery',
+ 'host-traddr': str(),
+ 'host-iface': str(),
+ 'host-nqn': str(),
},
[...]
]
diff --git a/staslib/conf.py b/staslib/conf.py
index e5c038b..4497698 100644
--- a/staslib/conf.py
+++ b/staslib/conf.py
@@ -334,9 +334,10 @@ class SvcConf(metaclass=singleton.Singleton): # pylint: disable=too-many-public
'transport': [TRANSPORT],
'traddr': [TRADDR],
'trsvcid': [TRSVCID],
+ 'subsysnqn': [NQN],
'host-traddr': [TRADDR],
'host-iface': [IFACE],
- 'subsysnqn': [NQN],
+ 'host-nqn': [NQN],
'dhchap-ctrl-secret': [KEY],
'hdr-digest': [BOOL]
'data-digest': [BOOL]
@@ -721,9 +722,11 @@ class NbftConf(metaclass=singleton.Singleton):
hfis = data.get('hfi', [])
discovery = data.get('discovery', [])
subsystem = data.get('subsystem', [])
+ host = data.get('host', {})
+ hostnqn = host.get('nqn', None) if host.get('host_nqn_configured', False) else None
- self._disc_ctrls.extend(NbftConf.__nbft_disc_to_cids(discovery, hfis))
- self._subs_ctrls.extend(NbftConf.__nbft_subs_to_cids(subsystem, hfis))
+ self._disc_ctrls.extend(NbftConf.__nbft_disc_to_cids(hostnqn, discovery, hfis))
+ self._subs_ctrls.extend(NbftConf.__nbft_subs_to_cids(hostnqn, subsystem, hfis))
dcs = property(lambda self: self._disc_ctrls)
iocs = property(lambda self: self._subs_ctrls)
@@ -738,12 +741,14 @@ class NbftConf(metaclass=singleton.Singleton):
return self.dcs if defs.PROG_NAME == 'stafd' else []
@staticmethod
- def __nbft_disc_to_cids(discovery, hfis):
+ def __nbft_disc_to_cids(hostnqn, discovery, hfis):
cids = []
for ctrl in discovery:
cid = NbftConf.__uri2cid(ctrl['uri'])
cid['subsysnqn'] = ctrl['nqn']
+ if hostnqn:
+ cid['host-nqn'] = hostnqn
host_iface = NbftConf.__get_host_iface(ctrl.get('hfi_index'), hfis)
if host_iface:
@@ -754,7 +759,7 @@ class NbftConf(metaclass=singleton.Singleton):
return cids
@staticmethod
- def __nbft_subs_to_cids(subsystem, hfis):
+ def __nbft_subs_to_cids(hostnqn, subsystem, hfis):
cids = []
for ctrl in subsystem:
@@ -766,6 +771,8 @@ class NbftConf(metaclass=singleton.Singleton):
'hdr-digest': ctrl['pdu_header_digest_required'],
'data-digest': ctrl['data_digest_required'],
}
+ if hostnqn:
+ cid['host-nqn'] = hostnqn
indexes = ctrl.get('hfi_indexes')
if isinstance(indexes, list) and len(indexes) > 0:
diff --git a/staslib/service.py b/staslib/service.py
index e681f3a..08a775a 100644
--- a/staslib/service.py
+++ b/staslib/service.py
@@ -393,9 +393,10 @@ class Stac(Service):
for staf_data in self._get_log_pages_from_stafd():
host_traddr = staf_data['discovery-controller']['host-traddr']
host_iface = staf_data['discovery-controller']['host-iface']
+ host_nqn = staf_data['discovery-controller']['host-nqn']
for dlpe in staf_data['log-pages']:
if dlpe.get('subtype') == 'nvme': # eliminate discovery controllers
- tid = stas.tid_from_dlpe(dlpe, host_traddr, host_iface)
+ tid = stas.tid_from_dlpe(dlpe, host_traddr, host_iface, host_nqn)
discovered_ctrls[tid] = dlpe
discovered_ctrl_list = list(discovered_ctrls.keys())
@@ -476,19 +477,20 @@ class Stac(Service):
logging.debug('Stac._disconnect_from_staf() - Disconnected from staf')
def _log_pages_changed( # pylint: disable=too-many-arguments
- self, transport, traddr, trsvcid, host_traddr, host_iface, subsysnqn, device
+ self, transport, traddr, trsvcid, subsysnqn, host_traddr, host_iface, host_nqn, device
):
if not self._alive():
return
logging.debug(
- 'Stac._log_pages_changed() - transport=%s, traddr=%s, trsvcid=%s, host_traddr=%s, host_iface=%s, subsysnqn=%s, device=%s',
+ 'Stac._log_pages_changed() - transport=%s, traddr=%s, trsvcid=%s, subsysnqn=%s, host_traddr=%s, host_iface=%s, host_nqn=%s, device=%s',
transport,
traddr,
trsvcid,
+ subsysnqn,
host_traddr,
host_iface,
- subsysnqn,
+ host_nqn,
device,
)
if self._cfg_soak_tmr:
@@ -693,9 +695,10 @@ class Staf(Service):
controller.tid.transport,
controller.tid.traddr,
controller.tid.trsvcid,
+ controller.tid.subsysnqn,
controller.tid.host_traddr,
controller.tid.host_iface,
- controller.tid.subsysnqn,
+ controller.tid.host_nqn,
device,
)
@@ -708,7 +711,12 @@ class Staf(Service):
def _referrals(self) -> list:
return [
- stas.tid_from_dlpe(dlpe, controller.tid.host_traddr, controller.tid.host_iface)
+ stas.tid_from_dlpe(
+ dlpe,
+ controller.tid.host_traddr,
+ controller.tid.host_iface,
+ controller.tid.host_nqn,
+ )
for controller in self.get_controllers()
for dlpe in controller.referrals()
]
diff --git a/staslib/stacd.idl b/staslib/stacd.idl
index efefbbe..d609742 100644
--- a/staslib/stacd.idl
+++ b/staslib/stacd.idl
@@ -9,9 +9,10 @@
<arg direction="in" type="s" name="transport"/>
<arg direction="in" type="s" name="traddr"/>
<arg direction="in" type="s" name="trsvcid"/>
+ <arg direction="in" type="s" name="subsysnqn"/>
<arg direction="in" type="s" name="host_traddr"/>
<arg direction="in" type="s" name="host_iface"/>
- <arg direction="in" type="s" name="subsysnqn"/>
+ <arg direction="in" type="s" name="host_nqn"/>
<arg direction="out" type="s" name="info_json"/>
</method>
</interface>
diff --git a/staslib/stafd.idl b/staslib/stafd.idl
index 8c98ffe..a494751 100644
--- a/staslib/stafd.idl
+++ b/staslib/stafd.idl
@@ -9,9 +9,10 @@
<arg direction="in" type="s" name="transport"/>
<arg direction="in" type="s" name="traddr"/>
<arg direction="in" type="s" name="trsvcid"/>
+ <arg direction="in" type="s" name="subsysnqn"/>
<arg direction="in" type="s" name="host_traddr"/>
<arg direction="in" type="s" name="host_iface"/>
- <arg direction="in" type="s" name="subsysnqn"/>
+ <arg direction="in" type="s" name="host_nqn"/>
<arg direction="out" type="s" name="info_json"/>
</method>
</interface>
@@ -25,9 +26,10 @@
<arg direction="in" type="s" name="transport"/>
<arg direction="in" type="s" name="traddr"/>
<arg direction="in" type="s" name="trsvcid"/>
+ <arg direction="in" type="s" name="subsysnqn"/>
<arg direction="in" type="s" name="host_traddr"/>
<arg direction="in" type="s" name="host_iface"/>
- <arg direction="in" type="s" name="subsysnqn"/>
+ <arg direction="in" type="s" name="host_nqn"/>
<arg direction="out" type="aa{ss}" name="log_pages"/>
</method>
<method name="get_all_log_pages">
@@ -38,9 +40,10 @@
<arg direction="out" type="s" name="transport"/>
<arg direction="out" type="s" name="traddr"/>
<arg direction="out" type="s" name="trsvcid"/>
+ <arg direction="out" type="s" name="subsysnqn"/>
<arg direction="out" type="s" name="host_traddr"/>
<arg direction="out" type="s" name="host_iface"/>
- <arg direction="out" type="s" name="subsysnqn"/>
+ <arg direction="out" type="s" name="host_nqn"/>
<arg direction="out" type="s" name="device"/>
</signal>
<signal name="dc_removed"></signal>
diff --git a/staslib/stas.py b/staslib/stas.py
index e333b90..47ce5de 100644
--- a/staslib/stas.py
+++ b/staslib/stas.py
@@ -125,7 +125,7 @@ def remove_invalid_addresses(controllers: list):
# ******************************************************************************
-def tid_from_dlpe(dlpe, host_traddr, host_iface):
+def tid_from_dlpe(dlpe, host_traddr, host_iface, host_nqn):
'''@brief Take a Discovery Log Page Entry and return a Controller ID as a dict.'''
cid = {
'transport': dlpe['trtype'],
@@ -135,6 +135,8 @@ def tid_from_dlpe(dlpe, host_traddr, host_iface):
'host-iface': host_iface,
'subsysnqn': dlpe['subnqn'],
}
+ if host_nqn:
+ cid['host-nqn'] = host_nqn
return trid.TID(cid)
@@ -416,16 +418,24 @@ class ServiceABC(abc.ABC): # pylint: disable=too-many-instance-attributes
return self._controllers.values()
def get_controller(
- self, transport: str, traddr: str, trsvcid: str, host_traddr: str, host_iface: str, subsysnqn: str
+ self,
+ transport: str,
+ traddr: str,
+ trsvcid: str,
+ subsysnqn: str,
+ host_traddr: str,
+ host_iface: str,
+ host_nqn: str,
): # pylint: disable=too-many-arguments
'''@brief get the specified controller object from the list of controllers'''
cid = {
'transport': transport,
'traddr': traddr,
'trsvcid': trsvcid,
+ 'subsysnqn': subsysnqn,
'host-traddr': host_traddr,
'host-iface': host_iface,
- 'subsysnqn': subsysnqn,
+ 'host-nqn': host_nqn,
}
return self._controllers.get(trid.TID(cid))
diff --git a/staslib/trid.py b/staslib/trid.py
index 11065ea..e814f4e 100644
--- a/staslib/trid.py
+++ b/staslib/trid.py
@@ -30,6 +30,7 @@ class TID: # pylint: disable=too-many-instance-attributes
'trsvcid': str, # [optional]
'host-traddr': str, # [optional]
'host-iface': str, # [optional]
+ 'host-nqn': str, # [optional]
# Connection parameters
'dhchap-ctrl-secret': str, # [optional]
@@ -58,59 +59,54 @@ class TID: # pylint: disable=too-many-instance-attributes
self._trsvcid = (
trsvcid if trsvcid else (TID.RDMA_IP_PORT if self._transport == 'rdma' else TID.DISC_IP_PORT)
)
+ sysconf = conf.SysConf()
self._host_traddr = cid.get('host-traddr', '')
self._host_iface = '' if conf.SvcConf().ignore_iface else cid.get('host-iface', '')
+ self._host_nqn = cid.get('host-nqn', sysconf.hostnqn)
self._subsysnqn = cid.get('subsysnqn', '')
- self._key = (self._transport, self._traddr, self._trsvcid, self._subsysnqn, self._host_traddr, self._host_iface)
+ self._key = (
+ self._transport,
+ self._traddr,
+ self._trsvcid,
+ self._subsysnqn,
+ self._host_traddr,
+ self._host_iface,
+ self._host_nqn,
+ )
self._hash = int.from_bytes(
hashlib.md5(''.join(self._key).encode('utf-8')).digest(), 'big'
) # We need a consistent hash between restarts
self._id = f'({self._transport}, {self._traddr}, {self._trsvcid}{", " + self._subsysnqn if self._subsysnqn else ""}{", " + self._host_iface if self._host_iface else ""}{", " + self._host_traddr if self._host_traddr else ""})' # pylint: disable=line-too-long
- @property
- def transport(self): # pylint: disable=missing-function-docstring
- return self._transport
-
- @property
- def traddr(self): # pylint: disable=missing-function-docstring
- return self._traddr
-
- @property
- def trsvcid(self): # pylint: disable=missing-function-docstring
- return self._trsvcid
-
- @property
- def host_traddr(self): # pylint: disable=missing-function-docstring
- return self._host_traddr
-
- @property
- def host_iface(self): # pylint: disable=missing-function-docstring
- return self._host_iface
-
- @property
- def subsysnqn(self): # pylint: disable=missing-function-docstring
- return self._subsysnqn
-
- @property
- def cfg(self): # pylint: disable=missing-function-docstring
- return self._cfg
+ host_traddr = property(lambda self: self._host_traddr)
+ host_iface = property(lambda self: self._host_iface)
+ subsysnqn = property(lambda self: self._subsysnqn)
+ transport = property(lambda self: self._transport)
+ host_nqn = property(lambda self: self._host_nqn)
+ trsvcid = property(lambda self: self._trsvcid)
+ traddr = property(lambda self: self._traddr)
+ cfg = property(lambda self: self._cfg)
def as_dict(self):
'''Return object members as a dictionary'''
data = {
- 'transport': self.transport,
'traddr': self.traddr,
- 'subsysnqn': self.subsysnqn,
'trsvcid': self.trsvcid,
- 'host-traddr': self.host_traddr,
+ 'transport': self.transport,
+ 'subsysnqn': self.subsysnqn,
'host-iface': self.host_iface,
+ 'host-traddr': self.host_traddr,
}
- # When migrating an old last known config, the "_cfg" member may
- # not exist. Therefor retrive it with getattr() to avoid a crash.
+ # When migrating an old last known config, some members may not
+ # exist. Therefore retrieve them with getattr() to avoid a crash.
cfg = getattr(self, '_cfg', None)
if cfg:
data.update(cfg)
+
+ sysconf = conf.SysConf()
+ data['host-nqn'] = getattr(self, '_host_nqn', sysconf.hostnqn)
+
return data
def __str__(self):
diff --git a/staslib/udev.py b/staslib/udev.py
index 80555dd..b9bd258 100644
--- a/staslib/udev.py
+++ b/staslib/udev.py
@@ -259,8 +259,13 @@ class Udev:
cid.src_addr can only be read from the sysfs starting with kernel
6.1.
'''
- # 'transport', 'traddr', 'trsvcid', and 'subsysnqn' must exactly match.
- if cid['transport'] != tid.transport or cid['trsvcid'] != tid.trsvcid or cid['subsysnqn'] != tid.subsysnqn:
+ # 'transport', 'traddr', 'trsvcid', 'subsysnqn', and 'host-nqn' must exactly match.
+ if (
+ cid['transport'] != tid.transport
+ or cid['trsvcid'] != tid.trsvcid
+ or cid['subsysnqn'] != tid.subsysnqn
+ or cid['host-nqn'] != tid.host_nqn
+ ):
return False
if tid.transport in ('tcp', 'rdma'):
@@ -489,6 +494,7 @@ class Udev:
'host-iface': Udev._get_property(device, 'NVME_HOST_IFACE'),
'subsysnqn': Udev._get_attribute(device, 'subsysnqn'),
'src-addr': Udev.get_key_from_attr(device, 'address', 'src_addr='),
+ 'host-nqn': Udev._get_attribute(device, 'hostnqn'),
}
return cid