From 347467d3fa6fb239f917c05c4cf7f6c3fe7f9b30 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 16 Jun 2023 13:03:18 +0200 Subject: Adding upstream version 2.3~rc1. Signed-off-by: Daniel Baumann --- staslib/nbft.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 staslib/nbft.py (limited to 'staslib/nbft.py') diff --git a/staslib/nbft.py b/staslib/nbft.py new file mode 100644 index 0000000..c643c9c --- /dev/null +++ b/staslib/nbft.py @@ -0,0 +1,28 @@ +# Copyright (c) 2023, Dell Inc. or its subsidiaries. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# See the LICENSE file for details. +# +# This file is part of NVMe STorage Appliance Services (nvme-stas). +# +# Authors: Martin Belanger +# +'''Code used to access the NVMe Boot Firmware Tables''' + +import os +import glob +import logging +from libnvme import nvme +from staslib import defs + + +def get_nbft_files(root_dir=defs.NBFT_SYSFS_PATH): + """Return a dictionary containing the NBFT data for all the NBFT binary files located in @root_dir""" + if not defs.HAS_NBFT_SUPPORT: + logging.warning( + "libnvme-%s does not have NBFT support. Please upgrade libnvme.", + defs.LIBNVME_VERSION, + ) + return {} + + pathname = os.path.join(root_dir, defs.NBFT_SYSFS_FILENAME) + return {fname: nvme.nbft_get(fname) or {} for fname in glob.iglob(pathname=pathname)} # pylint: disable=no-member -- cgit v1.2.3