diff --git a/confluent_osdeploy/confluent_osdeploy.spec.tmpl b/confluent_osdeploy/confluent_osdeploy.spec.tmpl index f40b6d31..4bc123fe 100644 --- a/confluent_osdeploy/confluent_osdeploy.spec.tmpl +++ b/confluent_osdeploy/confluent_osdeploy.spec.tmpl @@ -38,7 +38,8 @@ mkdir esxi7out cd esxi7out cp -a ../opt . cp -a ../esxi7/initramfs/* . -tar zcvf ../addons.tgz . +chmod +x bin/* opt/confluent/bin/* +tar zcvf ../addons.tgz * mv ../addons.tgz . cd .. diff --git a/confluent_osdeploy/esxi7/initramfs/opt/confluent/bin/apiclient b/confluent_osdeploy/esxi7/initramfs/opt/confluent/bin/apiclient index a390c0f6..9c64e88e 100644 --- a/confluent_osdeploy/esxi7/initramfs/opt/confluent/bin/apiclient +++ b/confluent_osdeploy/esxi7/initramfs/opt/confluent/bin/apiclient @@ -30,7 +30,7 @@ class HTTPSClient(client.HTTPConnection, object): host = self.host.split('%', 1)[0] if '[' not in host and ':' in host: self.stdheaders['Host'] = '[{0}]'.format(host) - else + else: self.stdheaders['Host'] = '{0}'.format(host) ctx.verify_mode = ssl.CERT_REQUIRED ctx.check_hostname = True diff --git a/confluent_osdeploy/esxi7/profiles/hypervisor/profile.yaml b/confluent_osdeploy/esxi7/profiles/hypervisor/profile.yaml index bedf0756..0ec9814c 100644 --- a/confluent_osdeploy/esxi7/profiles/hypervisor/profile.yaml +++ b/confluent_osdeploy/esxi7/profiles/hypervisor/profile.yaml @@ -1 +1,2 @@ label: VMware ESXi %%VERSION%% Hypervisor +ostype: esxi diff --git a/confluent_server/confluent/osimage.py b/confluent_server/confluent/osimage.py index 911ed6ce..87aecaa5 100644 --- a/confluent_server/confluent/osimage.py +++ b/confluent_server/confluent/osimage.py @@ -47,6 +47,53 @@ def update_boot(profiledir): with open('{0}/profile.yaml'.format(profiledir)) as profileinfo: profile = yaml.safe_load(profileinfo) label = profile.get('label', profname) + ostype = profile.get('ostype', 'linux') + if ostype == 'linux': + update_boot_linux(profiledir, profile, label) + elif ostype == 'esxi': + update_boot_esxi(profiledir, profile, label) + +def update_boot_esxi(profiledir, profile, label): + kernelargs = profile.get('kernelargs', '') + bootcfg = open('{0}/distribution/BOOT.CFG'.format(profiledir), 'r').read() + bootcfg = bootcfg.split('\n') + newbootcfg = '' + filesneeded = [] + for cfgline in bootcfg: + if cfgline.startswith('title='): + newbootcfg += 'title={0}\n'.format(label) + elif cfgline.startswith('kernelopt='): + newbootcfg += 'kernelopt={0}\n'.format(kernelargs) + elif cfgline.startswith('kernel='): + newbootcfg += cfgline + '\n' + kern = cfgline.split('=', 1)[1] + filesneeded.append(kern) + elif cfgline.startswith('modules='): + modlist = cfgline.split('=', 1)[1] + filesneeded.extend(modlist.split(' --- ')) + newbootcfg += cfgline + ' --- /initramfs/addons.tgz --- /site.tgz\n' + else: + newbootcfg += cfgline + '\n' + os.makedirs('{0}/boot/efi/boot/'.format(profiledir)) + with open('{0}/boot/efi/boot/BOOT.CFG'.format(profiledir), 'w+') as bcfg: + bcfg.write(newbootcfg) + os.symlink('/var/lib/confluent/public/site/initramfs.tgz', + '{0}/boot/site.tgz'.format(profiledir)) + for fn in filesneeded: + if fn.startswith('/'): + fn = fn[1:] + sourcefile = '{0}/distribution/{1}'.format(profiledir, fn) + if not os.path.exists(sourcefile): + sourcefile = '{0}/distribution/{1}'.format(profiledir, fn.upper()) + os.symlink(sourcefile, '{0}/boot/{1}'.format(profiledir, fn)) + os.symlink('{0}/distribution/EFI/BOOT/BOOTX64.EFI'.format(profiledir), '{0}/boot/efi/boot/bootx64.efi'.format(profiledir)) + os.symlink('{0}/distribution/EFI/BOOT/SAFEBOOT.EFI'.format(profiledir), '{0}/boot/efi/boot/safe.efi'.format(profiledir)) + subprocess.check_call( + ['/opt/confluent/bin/dir2img', '{0}/boot'.format(profiledir), + '{0}/boot.img'.format(profiledir)], preexec_fn=relax_umask) + + +def update_boot_linux(profiledir, profile, label): kernelargs = profile.get('kernelargs', '') grubcfg = "set timeout=5\nmenuentry '" grubcfg += label