From 5251f696f0bd8a68efde2df7c4dc948c4494ac60 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Wed, 7 Feb 2018 15:00:25 +0100 Subject: [PATCH 5/7] Add populator helper for NVDIMM namespaces Helper for adding block-like NVDIMM namespaces to the devicetree. --- blivet/populator/helpers/__init__.py | 2 +- blivet/populator/helpers/disk.py | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/blivet/populator/helpers/__init__.py b/blivet/populator/helpers/__init__.py index 861426c6..dd23475a 100644 --- a/blivet/populator/helpers/__init__.py +++ b/blivet/populator/helpers/__init__.py @@ -6,7 +6,7 @@ from .formatpopulator import FormatPopulator from .btrfs import BTRFSFormatPopulator from .boot import AppleBootFormatPopulator, EFIFormatPopulator, MacEFIFormatPopulator -from .disk import DiskDevicePopulator, iScsiDevicePopulator, FCoEDevicePopulator, MDBiosRaidDevicePopulator, DASDDevicePopulator, ZFCPDevicePopulator +from .disk import DiskDevicePopulator, iScsiDevicePopulator, FCoEDevicePopulator, MDBiosRaidDevicePopulator, DASDDevicePopulator, ZFCPDevicePopulator, NVDIMMNamespaceDevicePopulator from .disklabel import DiskLabelFormatPopulator from .dm import DMDevicePopulator from .dmraid import DMRaidFormatPopulator diff --git a/blivet/populator/helpers/disk.py b/blivet/populator/helpers/disk.py index e2757b12..ae4a7d28 100644 --- a/blivet/populator/helpers/disk.py +++ b/blivet/populator/helpers/disk.py @@ -28,7 +28,7 @@ from gi.repository import BlockDev as blockdev from ... import udev from ... import util from ...devices import DASDDevice, DiskDevice, FcoeDiskDevice, iScsiDiskDevice -from ...devices import MDBiosRaidArrayDevice, ZFCPDiskDevice +from ...devices import MDBiosRaidArrayDevice, ZFCPDiskDevice, NVDIMMNamespaceDevice from ...devices import device_path_to_name from ...storage_log import log_method_call from .devicepopulator import DevicePopulator @@ -214,3 +214,28 @@ class ZFCPDevicePopulator(DiskDevicePopulator): log.info("%s is a zfcp device", udev.device_get_name(self.data)) return kwargs + + +class NVDIMMNamespaceDevicePopulator(DiskDevicePopulator): + priority = 20 + + _device_class = NVDIMMNamespaceDevice + + @classmethod + def match(cls, data): + return (super(NVDIMMNamespaceDevicePopulator, NVDIMMNamespaceDevicePopulator).match(data) and + udev.device_is_nvdimm_namespace(data)) + + def _get_kwargs(self): + kwargs = super(NVDIMMNamespaceDevicePopulator, self)._get_kwargs() + + from ...static_data import nvdimm + ninfo = nvdimm.get_namespace_info(self.data.get("DEVNAME")) + + kwargs["mode"] = blockdev.nvdimm_namespace_get_mode_str(ninfo.mode) + kwargs["devname"] = ninfo.dev + kwargs["uuid"] = ninfo.uuid + kwargs["sector_size"] = ninfo.sector_size + + log.info("%s is an NVDIMM namespace device", udev.device_get_name(self.data)) + return kwargs -- 2.14.3