neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone
bda387
From 6528bb0149720b336c9da7b57eaea048d693871c Mon Sep 17 00:00:00 2001
bda387
From: David Lehman <dlehman@redhat.com>
bda387
Date: Wed, 20 Jun 2018 16:37:24 -0400
bda387
Subject: [PATCH] Deactivate incomplete VGs along with everything else.
bda387
bda387
(cherry picked from commit 39637796ca1aa2f03c89b5ec86ac246eecca1570)
bda387
---
bda387
 blivet/devices/lvm.py | 18 ++++++++++++++----
bda387
 1 file changed, 14 insertions(+), 4 deletions(-)
bda387
bda387
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
bda387
index 0cb1a2ac..1e9da2a8 100644
bda387
--- a/blivet/devices/lvm.py
bda387
+++ b/blivet/devices/lvm.py
bda387
@@ -216,15 +216,25 @@ class LVMVolumeGroupDevice(ContainerDevice):
bda387
             if lv.status:
bda387
                 return True
bda387
 
bda387
+        # special handling for incomplete VGs
bda387
+        if not self.complete:
bda387
+            try:
bda387
+                lvs_info = blockdev.lvm.lvs(vg_name=self.name)
bda387
+            except blockdev.LVMError:
bda387
+                lvs_info = dict()
bda387
+
bda387
+            for lv_info in lvs_info.values():
bda387
+                lv_attr = udev.device_get_lv_attr(lv_info)
bda387
+                if lv_attr and lv_attr[4] == 'a':
bda387
+                    return True
bda387
+
bda387
+            return False
bda387
+
bda387
         # if any of our PVs are not active then we cannot be
bda387
         for pv in self.pvs:
bda387
             if not pv.status:
bda387
                 return False
bda387
 
bda387
-        # if we are missing some of our PVs we cannot be active
bda387
-        if not self.complete:
bda387
-            return False
bda387
-
bda387
         return True
bda387
 
bda387
     def _pre_setup(self, orig=False):
bda387
-- 
bda387
2.20.1
bda387