From dc085fc9b8fe9b61b3d2c5c0bc88b145c049e5b4 Mon Sep 17 00:00:00 2001
From: David Lehman <dlehman@redhat.com>
Date: Fri, 7 Nov 2014 09:26:48 -0600
Subject: [PATCH 04/18] Move mediaPresent out of Device and into StorageDevice.

mediaPresent indicates whether a device node is backed by
readable/writeable media. It is generally only meaningful for root devices
(devices with no parents). There are only a few instances in which this
is relevant: cdrom/dvd, card readers, md containers, and some goofy raid
hardware that creates a zero-size block device node.
---
 blivet/devices/device.py  | 5 -----
 blivet/devices/storage.py | 5 +++++
 tests/devices_test.py     | 6 ++----
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/blivet/devices/device.py b/blivet/devices/device.py
index 58dad62..1109b3d 100644
--- a/blivet/devices/device.py
+++ b/blivet/devices/device.py
@@ -303,11 +303,6 @@ class Device(util.ObjectID):
 
         return services
 
-    @property
-    def mediaPresent(self):
-        """ True if this device contains usable media. """
-        return True
-
     @classmethod
     def isNameValid(cls, name): # pylint: disable=unused-argument
         """Is the device name valid for the device type?"""
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index 6c66a2f..bf458a0 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -600,6 +600,11 @@ class StorageDevice(Device):
         return self.alignTargetSize(self.format.maxSize) if self.resizable else self.currentSize
 
     @property
+    def mediaPresent(self):
+        """ True if this device contains usable media. """
+        return True
+
+    @property
     def status(self):
         """ This device's status.
 
diff --git a/tests/devices_test.py b/tests/devices_test.py
index 84cbe6c..6e5206e 100644
--- a/tests/devices_test.py
+++ b/tests/devices_test.py
@@ -67,7 +67,7 @@ class DeviceStateTestCase(unittest.TestCase):
            "isleaf" : xform(self.assertTrue),
            "major" : xform(lambda x, m: self.assertEqual(x, 0, m)),
            "maxSize" : xform(lambda x, m: self.assertEqual(x, Size(0), m)),
-           "mediaPresent" : xform(self.assertFalse),
+           "mediaPresent" : xform(self.assertTrue),
            "minor" : xform(lambda x, m: self.assertEqual(x, 0, m)),
            "parents" : xform(lambda x, m: self.assertEqual(len(x), 0, m) and
                                     self.assertIsInstance(x, ParentList, m)),
@@ -376,6 +376,7 @@ class MDRaidArrayDeviceTestCase(DeviceStateTestCase):
            devices=xform(lambda x, m: self.assertEqual(len(x), 1, m)),
            level=xform(lambda x, m: self.assertEqual(x.name, "container", m)),
            parents=xform(lambda x, m: self.assertEqual(len(x), 1, m)),
+           mediaPresent=xform(self.assertFalse),
            type=xform(lambda x, m: self.assertEqual(x, "mdcontainer", m)))
         self.stateCheck(self.dev2,
            createBitmap=xform(self.assertFalse),
@@ -420,7 +421,6 @@ class MDRaidArrayDeviceTestCase(DeviceStateTestCase):
            devices=xform(lambda x, m: self.assertEqual(len(x), 2, m)),
            isDisk=xform(self.assertTrue),
            level=xform(lambda x, m: self.assertEqual(x.number, 0, m)),
-           mediaPresent=xform(self.assertTrue),
            memberDevices=xform(lambda x, m: self.assertEqual(x, 2, m)),
            parents=xform(lambda x, m: self.assertNotEqual(x, [], m)),
            partitionable=xform(self.assertTrue),
@@ -441,7 +441,6 @@ class MDRaidArrayDeviceTestCase(DeviceStateTestCase):
            devices=xform(lambda x, m: self.assertEqual(len(x), 2, m)),
            isDisk=xform(self.assertTrue),
            level=xform(lambda x, m: self.assertEqual(x.number, 1, m)),
-           mediaPresent=xform(self.assertTrue),
            memberDevices=xform(lambda x, m: self.assertEqual(x, 2, m)),
            parents=xform(lambda x, m: self.assertNotEqual(x, [], m)),
            partitionable=xform(self.assertTrue),
@@ -453,7 +452,6 @@ class MDRaidArrayDeviceTestCase(DeviceStateTestCase):
            devices=xform(lambda x, m: self.assertEqual(len(x), 2, m)),
            isDisk=xform(self.assertTrue),
            level=xform(lambda x, m: self.assertEqual(x.number, 1, m)),
-           mediaPresent=xform(self.assertTrue),
            memberDevices=xform(lambda x, m: self.assertEqual(x, 2, m)),
            parents=xform(lambda x, m: self.assertNotEqual(x, [], m)),
            partitionable=xform(self.assertTrue),
-- 
1.9.3

