Fix suggestDeviceName to correctly avoid in-use lv names. (#812528)
There are two things the method was doing wrong:
1. not avoiding the names of lvs in the dialog's temporary vg
2. not using the full device name when checking numbered lv names
(lv device names are of the form "%s-%s" % (vgname, lvname))
There is another change here as well: if no distinguishing info is
passed in (eg: mountpoint, swap), default to numbered names from
the start. For the first three lvs you create, instead of lv, lv00,
lv01 you'll get lv00, lv01, lv02. Consistency.
---
pyanaconda/storage/__init__.py | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index 89dfc67..8f46af8 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -1109,10 +1109,16 @@ class Storage(object):
full += name
return full
- if full_name(name, parent) in names:
+ # also include names of any lvs in the parent for the case of the
+ # temporary vg in the lvm dialogs, which can contain lvs that are
+ # not yet in the devicetree and therefore not in self.names
+ if hasattr(parent, "lvs"):
+ names.extend([full_name(d.lvname, parent) for d in parent.lvs])
+
+ if full_name(name, parent) in names or not body:
for i in range(100):
name = "%s%02d" % (template, i)
- if name not in names:
+ if full_name(name, parent) not in names:
break
else:
name = ""
--
1.7.6
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list