[PATCH] Be more careful when selecting a vg name.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



lvm allows metadata that lives in unused disks to interfere with its
behavior.  For example you can have an old VG name in an ignored disk
and if you are trying to create a new VG with the same name, lvm will
not let you do it.  The safest thing to do is just to avoid repeating
names.

* storage/__init__.py (createSuggestedVGName): call the new
  vgdetectednames function and put it in the names that cannot be
  repeated.
* storage/devicelibs/lvm.py (vgdetectednames): new function.  Returns
  the VG names that lvm has detected in the system.
---
 storage/__init__.py       |    2 ++
 storage/devicelibs/lvm.py |   14 ++++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/storage/__init__.py b/storage/__init__.py
index 8dda2a4..6e9dbf0 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -42,6 +42,7 @@ from formats import getFormat
 from formats import get_device_format_class
 from formats import get_default_filesystem_type
 from devicelibs.lvm import safeLvmName
+from devicelibs.lvm import vgdetectednames
 from devicelibs.mdraid import mdRaidBootArches
 from udev import udev_trigger
 import iscsi
@@ -611,6 +612,7 @@ class Storage(object):
         # try to create a volume group name incorporating the hostname
         hn = network.hostname
         vgnames = [vg.name for vg in self.vgs]
+        vgnames.extend(vgdetectednames())
         if hn is not None and hn != '':
             if hn == 'localhost' or hn == 'localhost.localdomain':
                 vgtemplate = "VolGroup"
diff --git a/storage/devicelibs/lvm.py b/storage/devicelibs/lvm.py
index bdb732a..e5b0bd9 100644
--- a/storage/devicelibs/lvm.py
+++ b/storage/devicelibs/lvm.py
@@ -236,6 +236,20 @@ def vginfo(vg_name):
      d['pe_count'],d['pe_free'],d['pv_count']) = info
     return d
 
+def vgdetectednames():
+    """ Will run vgs and return all the detected names.
+
+    There is a change that there are vgnames that are recognized by lvm.
+    It is important to know what these vgs are.
+    """
+    retval = []
+    names = iutil.execWithCapture("lvm",
+            ["vgs", "--noheadings", "-o", "vg_name"],
+            stderr="/dev/tty5")
+    for name in names.strip("\n").split("\n"):
+        retval.append(name.strip())
+    return retval
+
 def lvs(vg_name):
     buf = iutil.execWithCapture("lvm",
                                 ["lvs", "--noheadings", "--nosuffix",
-- 
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux