2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00

Generate different boot.cfg for esxi

media boot and pxe boot need
two different strategies for module
location. Print the two cfg files
with the respectively useful
values.
This commit is contained in:
Jarrod Johnson 2020-06-12 14:27:37 -04:00
parent ab04ad85e8
commit fc7ad4b028

View File

@ -59,36 +59,46 @@ def update_boot_esxi(profiledir, profile, label):
bootcfg = open('{0}/distribution/BOOT.CFG'.format(profiledir), 'r').read()
bootcfg = bootcfg.split('\n')
newbootcfg = ''
efibootcfg = ''
filesneeded = []
for cfgline in bootcfg:
if cfgline.startswith('title='):
newbootcfg += 'title={0}\n'.format(label)
efibootcfg += 'title={0}\n'.format(label)
elif cfgline.startswith('kernelopt='):
newbootcfg += 'kernelopt={0}\n'.format(kernelargs)
efibootcfg += 'kernelopt={0}\n'.format(kernelargs)
elif cfgline.startswith('kernel='):
kern = cfgline.split('=', 1)[1]
kern = kern.replace('/', '')
newbootcfg += 'kernel={0}\n'.format(kern)
efibootcfg += cfgiline + '\n'
filesneeded.append(kern)
elif cfgline.startswith('modules='):
modlist = cfgline.split('=', 1)[1]
mods = modlist.split(' --- ')
efibootcfg += 'modules=' + ' --- '.join(mods) + ' --- /initramfs/addons.tgz --- /site.tgz\n'
mods = [x.replace('/', '') for x in mods]
filesneeded.extend(mods)
newbootcfg += 'modules=' + ' --- '.join(mods) + ' --- initramfs/addons.tgz --- site.tgz\n'
else:
newbootcfg += cfgline + '\n'
efibootcfg += cfgline + '\n'
os.makedirs('{0}/boot/efi/boot/'.format(profiledir), 0o755)
bcfgout = os.open('{0}/boot/efi/boot/boot.cfg'.format(profiledir), os.O_WRONLY|os.O_CREAT, 0o644)
bcfg = os.fdopen(bcfgout, 'w')
try:
bcfg.write(efibootcfg)
finally:
bcfg.close()
bcfgout = os.open('{0}/boot/boot.cfg'.format(profiledir), os.O_WRONLY|os.O_CREAT, 0o644)
bcfg = os.fdopen(bcfgout, 'w')
try:
bcfg.write(newbootcfg)
finally:
bcfg.close()
os.symlink('/var/lib/confluent/public/site/initramfs.tgz',
'{0}/boot/site.tgz'.format(profiledir))
os.symlink('{0}/boot/efi/boot/boot.cfg'.format(profiledir), '{0}/boot/boot.cfg'.format(profiledir))
for fn in filesneeded:
if fn.startswith('/'):
fn = fn[1:]