LVM code limits name lengths to 128 characters, so enforce that limit in our automatic name generation code. --- storage/__init__.py | 12 ++++++------ storage/devicelibs/lvm.py | 9 ++++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/storage/__init__.py b/storage/__init__.py index e30182b..de34051 100644 --- a/storage/__init__.py +++ b/storage/__init__.py @@ -710,11 +710,11 @@ class Storage(object): if hn == 'localhost' or hn == 'localhost.localdomain': vgtemplate = "VolGroup" elif hn.find('.') != -1: - hn = safeLvmName(hn) - vgtemplate = "vg_%s" % (hn.split('.')[0].lower(),) + template = "vg_%s" % (hn.split('.')[0].lower(),) + vgtemplate = safeLvmName(template) else: - hn = safeLvmName(hn) - vgtemplate = "vg_%s" % (hn.lower(),) + template = "vg_%s" % (hn.lower(),) + vgtemplate = safeLvmName(template) else: vgtemplate = "VolGroup" @@ -743,8 +743,8 @@ class Storage(object): if mountpoint == '/': lvtemplate = 'lv_root' else: - tmp = safeLvmName(mountpoint) - lvtemplate = "lv_%s" % (tmp,) + template = "lv_%s" % (mountpoint,) + lvtemplate = safeLvmName(template) else: if swap: if len([s for s in self.swaps if s in vg.lvs]): diff --git a/storage/devicelibs/lvm.py b/storage/devicelibs/lvm.py index 671113a..f3814a4 100644 --- a/storage/devicelibs/lvm.py +++ b/storage/devicelibs/lvm.py @@ -134,12 +134,19 @@ def getMaxLVSize(): else: return (16*1024*1024) #Max is 16TiB -def safeLvmName(name): +# LVM sources set the maximum length limit on VG and LV names at 128. Set +# our default to 2 below that to account for 0 through 99 entries we may +# make with this name as a prefix. LVM doesn't seem to impose a limit of +# 99, but we do in anaconda. +def safeLvmName(name, maxlen=126): tmp = name.strip() tmp = tmp.replace("/", "_") tmp = re.sub("[^0-9a-zA-Z._]", "", tmp) tmp = tmp.lstrip("_") + if len(tmp) > maxlen: + tmp = tmp[:maxlen] + return tmp def clampSize(size, pesize, roundup=None): -- 1.6.2.5 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list