summaryrefslogtreecommitdiffstats
path: root/storage/devicelibs
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2009-08-18 16:05:23 -1000
committerDavid Cantrell <dcantrell@redhat.com>2009-08-19 15:09:23 -1000
commit1f35d93ff2be6930ae1662f72ddc3efcb7e3d95e (patch)
tree61bdf32884136d8dd5966ab97aaea9a8902a6e99 /storage/devicelibs
parent0893244dbdb3e2faada5224bf49458b61389ba34 (diff)
downloadanaconda-1f35d93ff2be6930ae1662f72ddc3efcb7e3d95e.tar.gz
anaconda-1f35d93ff2be6930ae1662f72ddc3efcb7e3d95e.tar.xz
anaconda-1f35d93ff2be6930ae1662f72ddc3efcb7e3d95e.zip
Make sure LV and VG names fit within LVM limits (#517483)
LVM code limits name lengths to 128 characters, so enforce that limit in our automatic name generation code.
Diffstat (limited to 'storage/devicelibs')
-rw-r--r--storage/devicelibs/lvm.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/storage/devicelibs/lvm.py b/storage/devicelibs/lvm.py
index 671113a92..f3814a4d3 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):