Blame 0004-Add-NVDIMMNamespaceDevice-device-representing-NVDIMM.patch

b04db7f
From 6ae475fb80cdf1dd7f527ed0b952c613a5825ec3 Mon Sep 17 00:00:00 2001
b04db7f
From: Vojtech Trefny <vtrefny@redhat.com>
b04db7f
Date: Wed, 7 Feb 2018 14:58:12 +0100
b04db7f
Subject: [PATCH 4/7] Add 'NVDIMMNamespaceDevice' device representing NVDIMM
b04db7f
 namespaces
b04db7f
b04db7f
---
b04db7f
 blivet/devices/__init__.py |  2 +-
b04db7f
 blivet/devices/disk.py     | 51 ++++++++++++++++++++++++++++++++++++++++++++--
b04db7f
 2 files changed, 50 insertions(+), 3 deletions(-)
b04db7f
b04db7f
diff --git a/blivet/devices/__init__.py b/blivet/devices/__init__.py
b04db7f
index 5bae1cbe..aaad30c3 100644
b04db7f
--- a/blivet/devices/__init__.py
b04db7f
+++ b/blivet/devices/__init__.py
b04db7f
@@ -22,7 +22,7 @@
b04db7f
 from .lib import device_path_to_name, device_name_to_disk_by_path, ParentList
b04db7f
 from .device import Device
b04db7f
 from .storage import StorageDevice
b04db7f
-from .disk import DiskDevice, DiskFile, DMRaidArrayDevice, MultipathDevice, iScsiDiskDevice, FcoeDiskDevice, DASDDevice, ZFCPDiskDevice
b04db7f
+from .disk import DiskDevice, DiskFile, DMRaidArrayDevice, MultipathDevice, iScsiDiskDevice, FcoeDiskDevice, DASDDevice, ZFCPDiskDevice, NVDIMMNamespaceDevice
b04db7f
 from .partition import PartitionDevice
b04db7f
 from .dm import DMDevice, DMLinearDevice, DMCryptDevice, DM_MAJORS
b04db7f
 from .luks import LUKSDevice
b04db7f
diff --git a/blivet/devices/disk.py b/blivet/devices/disk.py
b04db7f
index 26448640..dc796cf0 100644
b04db7f
--- a/blivet/devices/disk.py
b04db7f
+++ b/blivet/devices/disk.py
b04db7f
@@ -63,7 +63,7 @@ class DiskDevice(StorageDevice):
b04db7f
     def __init__(self, name, fmt=None,
b04db7f
                  size=None, major=None, minor=None, sysfs_path='',
b04db7f
                  parents=None, serial=None, vendor="", model="", bus="", wwn=None,
b04db7f
-                 exists=True):
b04db7f
+                 uuid=None, exists=True):
b04db7f
         """
b04db7f
             :param name: the device name (generally a device node's basename)
b04db7f
             :type name: str
b04db7f
@@ -96,7 +96,7 @@ class DiskDevice(StorageDevice):
b04db7f
                                major=major, minor=minor, exists=exists,
b04db7f
                                sysfs_path=sysfs_path, parents=parents,
b04db7f
                                serial=serial, model=model,
b04db7f
-                               vendor=vendor, bus=bus)
b04db7f
+                               vendor=vendor, bus=bus, uuid=uuid)
b04db7f
 
b04db7f
         self.wwn = wwn or None
b04db7f
 
b04db7f
@@ -660,3 +660,50 @@ class DASDDevice(DiskDevice):
b04db7f
                                             ":".join(opts))])
b04db7f
         else:
b04db7f
             return set(["rd.dasd=%s" % self.busid])
b04db7f
+
b04db7f
+
b04db7f
+class NVDIMMNamespaceDevice(DiskDevice):
b04db7f
+
b04db7f
+    """ Non-volatile memory namespace """
b04db7f
+    _type = "nvdimm"
b04db7f
+
b04db7f
+    def __init__(self, device, **kwargs):
b04db7f
+        """
b04db7f
+            :param name: the device name (generally a device node's basename)
b04db7f
+            :type name: str
b04db7f
+            :keyword exists: does this device exist?
b04db7f
+            :type exists: bool
b04db7f
+            :keyword size: the device's size
b04db7f
+            :type size: :class:`~.size.Size`
b04db7f
+            :keyword parents: a list of parent devices
b04db7f
+            :type parents: list of :class:`StorageDevice`
b04db7f
+            :keyword format: this device's formatting
b04db7f
+            :type format: :class:`~.formats.DeviceFormat` or a subclass of it
b04db7f
+            :keyword mode: mode of the namespace
b04db7f
+            :type mode: str
b04db7f
+            :keyword devname: name of the namespace (e.g. 'namespace0.0')
b04db7f
+            :type devname: str
b04db7f
+            :keyword sector_size: sector size of the namespace in sector mode
b04db7f
+            :type sector_size: str
b04db7f
+        """
b04db7f
+        self.mode = kwargs.pop("mode")
b04db7f
+        self.devname = kwargs.pop("devname")
b04db7f
+        self.sector_size = kwargs.pop("sector_size")
b04db7f
+
b04db7f
+        DiskDevice.__init__(self, device, **kwargs)
b04db7f
+
b04db7f
+    def __repr__(self):
b04db7f
+        s = DiskDevice.__repr__(self)
b04db7f
+        s += ("  mode = %(mode)s  devname = %(devname)s" %
b04db7f
+              {"mode": self.mode,
b04db7f
+               "devname": self.devname})
b04db7f
+        if self.sector_size:
b04db7f
+            s += ("  sector size = %(sector_size)s" % {"sector_size": self.sector_size})
b04db7f
+        return s
b04db7f
+
b04db7f
+    @property
b04db7f
+    def description(self):
b04db7f
+        return "NVDIMM namespace %(devname)s in %(mode)s mode exported as %(path)s" \
b04db7f
+               % {'devname': self.devname,
b04db7f
+                  'mode': self.mode,
b04db7f
+                  'path': self.path}
b04db7f
-- 
b04db7f
2.14.3
b04db7f