From fc7ad4b028efaa75f200adb86b7c0088eb8e909b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 12 Jun 2020 14:27:37 -0400 Subject: [PATCH] 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. --- confluent_server/confluent/osimage.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/osimage.py b/confluent_server/confluent/osimage.py index 4296d3a0..95c7e1af 100644 --- a/confluent_server/confluent/osimage.py +++ b/confluent_server/confluent/osimage.py @@ -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:]