Skip to content

Commit

Permalink
Add a simple NVMe module for NVMe Fabrics support
Browse files Browse the repository at this point in the history
For now we want to support only NVMe Fabrics devices that don't
require manual configuration so we need to just make sure the
config files in /etc/nvme are fully populated before the installer
starts and after the installation copied to the installed system.
This is covered by calling the 'startup' and 'write' functions of
the Blivet's NVMe module.
  • Loading branch information
vojtechtrefny committed Nov 16, 2023
1 parent 1c1cce6 commit 9d3fa03
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pyanaconda/modules/common/constants/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
basename="NVDIMM"
)

NVME = DBusObjectIdentifier(
namespace=STORAGE_NAMESPACE,
basename="NVMe"
)

SNAPSHOT = DBusObjectIdentifier(
namespace=STORAGE_NAMESPACE,
basename="Snapshot"
Expand Down
5 changes: 4 additions & 1 deletion pyanaconda/modules/storage/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from pyanaconda.core.util import join_paths
from pyanaconda.core.path import make_directories
from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.modules.common.constants.objects import ISCSI, FCOE, ZFCP
from pyanaconda.modules.common.constants.objects import ISCSI, FCOE, ZFCP, NVME
from pyanaconda.modules.common.constants.services import STORAGE
from pyanaconda.modules.common.errors.installation import StorageInstallationError
from pyanaconda.modules.common.task import Task
Expand Down Expand Up @@ -293,6 +293,9 @@ def _write_storage_configuration(self, storage, sysroot=None):
zfcp_proxy = STORAGE.get_proxy(ZFCP)
zfcp_proxy.WriteConfiguration()

nvme_proxy = STORAGE.get_proxy(NVME)
nvme_proxy.WriteConfiguration()

self._write_dasd_conf(storage, sysroot)

def _write_escrow_packets(self, storage, sysroot):
Expand Down
21 changes: 21 additions & 0 deletions pyanaconda/modules/storage/nvme/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright (C) 2023 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME)
nvme_moduledir = $(pkgpyexecdir)/modules/storage/nvme
nvme_module_PYTHON = $(srcdir)/*.py

MAINTAINERCLEANFILES = Makefile.in
20 changes: 20 additions & 0 deletions pyanaconda/modules/storage/nvme/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (C) 2023 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
from pyanaconda.modules.storage.nvme.nvme import NVMEModule

__all__ = ["NVMEModule"]
54 changes: 54 additions & 0 deletions pyanaconda/modules/storage/nvme/nvme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# The NVMe module
#
# Copyright (C) 2023 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
from blivet.nvme import nvme

from pyanaconda.anaconda_loggers import get_module_logger
from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.core.signal import Signal
from pyanaconda.core.dbus import DBus
from pyanaconda.modules.common.base import KickstartBaseModule
from pyanaconda.modules.common.constants.objects import NVME
from pyanaconda.modules.storage.nvme.nvme_interface import NVMEInterface

log = get_module_logger(__name__)


class NVMEModule(KickstartBaseModule):
"""The NVMe module."""

def __init__(self):
super().__init__()
self.reload_module()

self.initiator_changed = Signal()

def publish(self):
"""Publish the module."""
DBus.publish_object(NVME.object_path, NVMEInterface(self))

def reload_module(self):
"""Reload the NVMe module."""
log.debug("Start up the NVMe module.")
nvme.startup()

def write_configuration(self):
"""Write the configuration to sysroot."""
log.debug("Write NVMe configuration.")
nvme.write(conf.target.system_root)
35 changes: 35 additions & 0 deletions pyanaconda/modules/storage/nvme/nvme_interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# DBus interface for the iSCSI module.
#
# Copyright (C) 2023 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
from dasbus.server.interface import dbus_interface
from dasbus.typing import * # pylint: disable=wildcard-import
from pyanaconda.modules.common.base import KickstartModuleInterfaceTemplate
from pyanaconda.modules.common.constants.objects import NVME


@dbus_interface(NVME.interface_name)
class NVMEInterface(KickstartModuleInterfaceTemplate):
"""DBus interface for the NVMe module."""

def WriteConfiguration(self):
"""Write the configuration to sysroot.
FIXME: This is just a temporary method.
"""
self.implementation.write_configuration()
2 changes: 2 additions & 0 deletions pyanaconda/modules/storage/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from blivet.fcoe import fcoe
from blivet.i18n import _
from blivet.iscsi import iscsi
from blivet.nvme import nvme
from blivet.zfcp import zfcp

from pyanaconda.anaconda_loggers import get_module_logger
Expand Down Expand Up @@ -73,6 +74,7 @@ def _reload_modules(self):

iscsi.startup()
fcoe.startup()
nvme.startup()

if arch.is_s390():
zfcp.startup()
Expand Down
4 changes: 4 additions & 0 deletions pyanaconda/modules/storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from pyanaconda.modules.storage.iscsi import ISCSIModule
from pyanaconda.modules.storage.kickstart import StorageKickstartSpecification
from pyanaconda.modules.storage.nvdimm import NVDIMMModule
from pyanaconda.modules.storage.nvme import NVMEModule
from pyanaconda.modules.storage.partitioning.constants import PartitioningMethod
from pyanaconda.modules.storage.partitioning.factory import PartitioningFactory
from pyanaconda.modules.storage.partitioning.validate import StorageValidateTask
Expand Down Expand Up @@ -102,6 +103,9 @@ def __init__(self):
self._nvdimm_module = NVDIMMModule()
self._modules.add_module(self._nvdimm_module)

self._nvme_module = NVMEModule()
self._modules.add_module(self._nvme_module)

self._dasd_module = DASDModule()
self._modules.add_module(self._dasd_module)

Expand Down

0 comments on commit 9d3fa03

Please sign in to comment.