neil / rpms / python-blivet

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