The actual limit is a combined length of 126, but snapshots &c can require extra characters and dashes get escaped, taking up more space. We go with 50, which allows for up to six dashes in each of lv and vg name. --- partIntfHelpers.py | 9 +++++---- storage/devicelibs/lvm.py | 13 ++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/partIntfHelpers.py b/partIntfHelpers.py index 8dd5a0f..624c445 100644 --- a/partIntfHelpers.py +++ b/partIntfHelpers.py @@ -31,6 +31,7 @@ import parted import iutil import network from storage.formats import getFormat +from storage.devicelibs.lvm import LVM_MAX_NAME_LEN import gettext _ = lambda x: gettext.ldgettext("anaconda", x) @@ -47,8 +48,8 @@ def sanityCheckVolumeGroupName(volname): return _("Please enter a volume group name.") # ripped the value for this out of linux/include/lvm.h - if len(volname) > 128: - return _("Volume Group Names must be less than 128 characters") + if len(volname) > LVM_MAX_NAME_LEN: + return _("Volume Group Names must be less than %d characters") % LVM_MAX_NAME_LEN if volname in badNames: return _("Error - the volume group name %s is not valid." % (volname,)) @@ -69,8 +70,8 @@ def sanityCheckLogicalVolumeName(logvolname): return _("Please enter a logical volume name.") # ripped the value for this out of linux/include/lvm.h - if len(logvolname) > 128: - return _("Logical Volume Names must be less than 128 characters") + if len(logvolname) > LVM_MAX_NAME_LEN: + return _("Logical Volume Names must be less than %d characters") % LVM_MAX_NAME_LEN if logvolname in badNames: diff --git a/storage/devicelibs/lvm.py b/storage/devicelibs/lvm.py index 22dab68..2b34da3 100644 --- a/storage/devicelibs/lvm.py +++ b/storage/devicelibs/lvm.py @@ -136,11 +136,14 @@ def getMaxLVSize(): else: return (16*1024*1024) #Max is 16TiB -# 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): +# apparently lvm has a limit of 126 chars for combined vg-lv names: +# https://bugzilla.redhat.com/show_bug.cgi?id=747278#c6 +# https://bugzilla.redhat.com/show_bug.cgi?id=747278#c7 +# since dashes get escaped they count double -- allow for six of them since +# a dhcp-provided hostname could easily contain five dashes ("dhcp-xx-xx-xx-xx") +LVM_MAX_NAME_LEN = 50 + +def safeLvmName(name, maxlen=LVM_MAX_NAME_LEN): tmp = name.strip() tmp = tmp.replace("/", "_") tmp = re.sub("[^0-9a-zA-Z._]", "", tmp) -- 1.7.7.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list