[blivet 13/13] Adjust currentSize methods slightly.
mulhern
amulhern at redhat.com
Fri Dec 6 16:50:13 UTC 2013
Add some comments that I believe are correct to StorageDevice.currentSize.
Have BTRFSDevice.currentSize return 0 if the device does not exist, to bring
it in line with the other currentSize methods.
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/devices.py | 15 ++++++++++-----
tests/devices_test.py | 6 +-----
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/blivet/devices.py b/blivet/devices.py
index 23f3a8b..8875f4e 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -874,7 +874,12 @@ class StorageDevice(Device):
@property
def currentSize(self):
- """ The device's actual size. """
+ """ The device's actual size, generally the size discovered by using
+ system tools. May use a cached value if the information is
+ currently unavailable.
+
+ If the device does not exist, then the actual size is 0.
+ """
size = 0
if self.exists and self.partedDevice:
size = self.partedDevice.getSize()
@@ -1738,7 +1743,6 @@ class PartitionDevice(StorageDevice):
@property
def currentSize(self):
- """ The device's actual size. """
if self.exists:
return self._currentSize
else:
@@ -4282,9 +4286,10 @@ class BTRFSDevice(StorageDevice):
@property
def currentSize(self):
- # at some point we'll want to make this a bit more realistic, but the
- # btrfs tools don't provide much of this type of information
- return self.size
+ if self.exists:
+ return self.size
+ else:
+ return 0
@property
def status(self):
diff --git a/tests/devices_test.py b/tests/devices_test.py
index bbbc6dd..1d73de6 100644
--- a/tests/devices_test.py
+++ b/tests/devices_test.py
@@ -439,8 +439,7 @@ class BTRFSDeviceTestCase(DeviceStateTestCase):
format=blivet.formats.getFormat("btrfs"),
size=32)
self.dev3 = BTRFSVolumeDevice("dev3",
- parents=[dev],
- exists=True)
+ parents=[dev])
def testBTRFSDeviceInit(self, *args, **kwargs):
"""Tests the state of a BTRFSDevice after initialization.
@@ -453,9 +452,6 @@ class BTRFSDeviceTestCase(DeviceStateTestCase):
type=lambda x, m: self.assertEqual(x, "btrfs volume", m))
self.stateCheck(self.dev3,
- currentSize=lambda x, m: self.assertEqual(x, 32, m),
- exists=self.assertTrue,
- maxSize=lambda x, m: self.assertEqual(x, 32, m),
parents=lambda x, m: self.assertEqual(len(x), 1, m),
size=lambda x, m: self.assertEqual(x, 32, m),
type=lambda x, m: self.assertEqual(x, "btrfs volume", m))
--
1.8.3.1
More information about the anaconda-patches
mailing list