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