[master 2/5] Make sure subclasses size setters use the base setter as appropriate.

dwlehman installerbot-noreply at redhat.com
Wed Jul 8 21:13:16 UTC 2015


From: David Lehman <dlehman at redhat.com>

All classes should be using the same code to actually set the size.
---
 blivet/devices/lvm.py       | 12 +++++-------
 blivet/devices/partition.py |  6 ++----
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index 2e0aa80..605165e 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -606,13 +606,12 @@ def _setSize(self, size):
 
         size = self.vg.align(size)
         log.debug("trying to set lv %s size to %s", self.name, size)
-        if size <= self.vg.freeSpace + self.vgSpaceUsed:
-            self._size = size
-            self.targetSize = size
-        else:
-            log.debug("failed to set size: %s short", size - (self.vg.freeSpace + self.vgSpaceUsed))
+        if size > self.vg.freeSpace + self.vgSpaceUsed:
+            log.error("failed to set size: %s short", size - (self.vg.freeSpace + self.vgSpaceUsed))
             raise ValueError("not enough free space in volume group")
 
+        super(LVMLogicalVolumeDevice, self)._setSize(size)
+
     size = property(StorageDevice._getSize, _setSize)
 
     @property
@@ -1500,8 +1499,7 @@ def _setSize(self, size):
 
         size = self.vg.align(size)
         size = self.vg.align(util.numeric_type(size))
-        self._size = size
-        self.targetSize = size
+        super(LVMThinLogicalVolumeDevice, self)._setSize(size)
 
     size = property(StorageDevice._getSize, _setSize)
 
diff --git a/blivet/devices/partition.py b/blivet/devices/partition.py
index cd81363..0742643 100644
--- a/blivet/devices/partition.py
+++ b/blivet/devices/partition.py
@@ -714,13 +714,11 @@ def _setSize(self, newsize):
         if not isinstance(newsize, Size):
             raise ValueError("new size must of type Size")
 
+        super(PartitionDevice, self)._setSize(newsize)
         if not self.exists:
-            # device does not exist (a partition request), just set basic value
-            self._size = newsize
+            # also update size fields used for partition allocation
             self.req_size = newsize
             self.req_base_size = newsize
-        else:
-            super(PartitionDevice, self)._setSize(newsize)
 
     def _getDisk(self):
         """ The disk that contains this partition."""


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/1554673768112db46ba3a339338d6cf1e2bd60db


More information about the anaconda-patches mailing list