2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-11-20 17:32:21 +00:00

Merge pull request #361 from Obihoernchen/fix/image2disk-localstorage-recapture

Fix install to disk of recaptured localstorage LVM nodes
This commit is contained in:
Jarrod Johnson
2026-11-04 08:05:52 -05:00
committed by GitHub
@@ -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, maxsplit=1) + ['']
return names[0].replace('--', '-'), names[1].replace('--', '-')
def convert_lv(oldlvname):
if oldvgname is None:
return None
@@ -407,14 +413,18 @@ def install_to_disk(imgpath):
if fs['device'].startswith('/dev/mapper'):
odevname = fs['device'].rsplit('/', 1)[-1]
if split_mapper_name(odevname)[0] == vgname:
# already in the volume group the install creates, as when
# recapturing a node that was installed this way
pass
# if node has - then /dev/mapper will double up the hypen
if '_' in odevname and '-' in odevname.split('_', 1)[-1]:
elif '_' in odevname and '-' in odevname.split('_', 1)[-1]:
oldvgname = odevname.rsplit('-', 1)[0].replace('--', '-')
osname = oldvgname.split('_')[0]
nodename = socket.gethostname().split('.')[0]
vgname = '{}_{}'.format(osname, nodename)
elif '-' in odevname: # unique one
vgmap[odevname] = odevname.split('-')[0]
vgmap[odevname] = split_mapper_name(odevname)[0]
lvmvols[odevname] = fs
continue
@@ -513,7 +523,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)