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

Fix update boot

update boot would leave
leftover content, truncate to
get rid of it.
This commit is contained in:
Jarrod Johnson 2020-08-07 13:45:10 -04:00
parent 022ba77298
commit 468f9758e5
2 changed files with 7 additions and 5 deletions

View File

@ -169,8 +169,10 @@ def handle_deployment(configmanager, inputdata, pathcomponents,
return
if len(pathcomponents) == 3:
profname = pathcomponents[-1]
if 'operation' == 'update':
if operation == 'update' and 'updateboot' in inputdata:
osimage.update_boot(profname)
yield msg.KeyValueData({'updated': profname})
return
if pathcomponents[1] == 'importing':
if len(pathcomponents) == 2 or not pathcomponents[-1]:
if operation == 'retrieve':

View File

@ -90,13 +90,13 @@ def update_boot_esxi(profiledir, profile, label):
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)
bcfgout = os.open('{0}/boot/efi/boot/boot.cfg'.format(profiledir), os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 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)
bcfgout = os.open('{0}/boot/boot.cfg'.format(profiledir), os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0o644)
bcfg = os.fdopen(bcfgout, 'w')
try:
bcfg.write(newbootcfg)
@ -112,7 +112,7 @@ def update_boot_esxi(profiledir, profile, label):
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))
ipout = os.open(profiledir + '/boot.ipxe', os.O_WRONLY|os.O_CREAT, 0o644)
ipout = os.open(profiledir + '/boot.ipxe', os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0o644)
ipxeout = os.fdopen(ipout, 'w')
try:
os.umask(oum)
@ -149,7 +149,7 @@ def update_boot_linux(profiledir, profile, label):
for initramfs in initrds:
ipxeargs += " initrd=" + initramfs
oum = os.umask(0o22)
ipout = os.open(profiledir + '/boot.ipxe', os.O_WRONLY|os.O_CREAT, 0o644)
ipout = os.open(profiledir + '/boot.ipxe', os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0o644)
ipxeout = os.fdopen(ipout, 'w')
try:
os.umask(oum)