2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-11-15 05:18:04 +00:00

Install recaptured images of LVM installed nodes to disk

image2disk.py puts the volumes of a node it installs into the volume
group localstorage. Capturing such a node and installing the profile to
disk again failed with 'No mapping defined to create volume group
localstorage': volumes named localstorage-root were taken for volumes of
an extra volume group that needs volumegroupmap.yml.

Treat volumes of a volume group named like the target one as main volume
group volumes, and split device mapper names into volume group and
logical volume names correctly, including hyphens that device mapper
doubles inside either name.
This commit is contained in:
Markus Hilger
2026-11-03 16:51:59 +01:00
parent 734ea9811a
commit 3bd3ebeadb
@@ -20,6 +20,12 @@ bootuuid = None
vgname = 'localstorage'
oldvgname = None
def split_mapper_name(devname):
# device mapper joins VG and LV name with a hyphen and doubles hyphens
# inside either name
names = re.split(r'(?<!-)-(?!-)', devname, 1) + ['']
return names[0].replace('--', '-'), names[1].replace('--', '-')
def convert_lv(oldlvname):
if oldvgname is None:
return None
@@ -409,8 +415,8 @@ def install_to_disk(imgpath):
osname = oldvgname.split('_')[0]
nodename = socket.gethostname().split('.')[0]
vgname = '{}_{}'.format(osname, nodename)
elif '-' in odevname: # unique one
vgmap[odevname] = odevname.split('-')[0]
elif '-' in odevname and split_mapper_name(odevname)[0] != vgname: # unique one
vgmap[odevname] = split_mapper_name(odevname)[0]
lvmvols[odevname] = fs
continue
@@ -499,7 +505,7 @@ def install_to_disk(imgpath):
subprocess.check_call(['pvcreate', '-ff', '-y', morelvmpart])
subprocess.check_call(['vgcreate', morevg, morelvmpart])
donedisks[targdisk] = 1
morelvname = morevolname.split('-', 1)[1]
morelvname = split_mapper_name(morevolname)[1]
subprocess.check_call(['lvcreate', '-L', '{}b'.format(lvmvols[morevolname]['initsize']), '-y', '-n', morelvname, morevg])
lvmvols[morevolname]['targetdisk'] = '/dev/{}/{}'.format(morevg, morelvname)