[PATCH 1/5] Improve the mechanism for VG completeness.

David Lehman dlehman at redhat.com
Mon Mar 24 18:50:48 UTC 2014


Do not modify self.pvCount -- that makes it meaningless as it was
obtained by lvm.

Do not worry about completeness if no pvCount was passed in for an
existing VG.

Because we instantiate all Device classes with exists=False when unit
testing, add a hack to StorageTestCase.newDevice to set completeness
appropriately for existing VGs.
---
 blivet/devices.py        | 14 +++++++++++---
 tests/storagetestcase.py |  2 ++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/blivet/devices.py b/blivet/devices.py
index f1c2ffc..ddd9f77 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -2220,7 +2220,10 @@ class LVMVolumeGroupDevice(ContainerDevice):
         # prior to instantiating the superclass.
         self._lvs = []
         self.hasDuplicate = False
+        self._complete = False
         self.pvCount = util.numeric_type(pvCount)
+        if exists and not pvCount:
+            self._complete = True
 
         super(LVMVolumeGroupDevice, self).__init__(name, parents=parents,
                                             exists=exists, sysfsPath=sysfsPath)
@@ -2350,6 +2353,10 @@ class LVMVolumeGroupDevice(ContainerDevice):
         pv_list = [pv.path for pv in self.parents]
         lvm.vgcreate(self.name, pv_list, self.peSize)
 
+    def _postCreate(self):
+        self._complete = True
+        super(LVMVolumeGroupDevice, self)._postCreate()
+
     def _preDestroy(self):
         StorageDevice._preDestroy(self)
         # set up the pvs since lvm needs access to them to do the vgremove
@@ -2423,8 +2430,9 @@ class LVMVolumeGroupDevice(ContainerDevice):
            flags.installer_mode:
             self.setup()
 
-        # and update our pv count
-        self.pvCount = len(self.parents)
+        if (self.exists and member.format.exists and
+            len(self.parents) == self.pvCount):
+            self._complete = True
 
     def _removeMember(self, member):
         # XXX It would be nice to raise an exception if removing this member
@@ -2559,7 +2567,7 @@ class LVMVolumeGroupDevice(ContainerDevice):
         if self.hasDuplicate:
             return False
 
-        return len(self.pvs) == self.pvCount or not self.exists
+        return self._complete or not self.exists
 
     def populateKSData(self, data):
         super(LVMVolumeGroupDevice, self).populateKSData(data)
diff --git a/tests/storagetestcase.py b/tests/storagetestcase.py
index 4afc50a..386fd8b 100644
--- a/tests/storagetestcase.py
+++ b/tests/storagetestcase.py
@@ -101,6 +101,8 @@ class StorageTestCase(unittest.TestCase):
                     pass
 
             device._partedPartition = partedPartition
+        elif isinstance(device, blivet.devices.LVMVolumeGroupDevice) and exists:
+            device._complete = True
 
         device.exists = exists
         device.format.exists = exists
-- 
1.8.5.3



More information about the anaconda-patches mailing list