2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-12-23 19:52:10 +00:00

Label boot.img with profile name

This allows for easier
search should an image want it
This commit is contained in:
Jarrod Johnson 2020-11-09 15:45:44 -05:00
parent dc262c366c
commit 014727d355
2 changed files with 16 additions and 6 deletions

View File

@ -8,7 +8,7 @@ import os
import subprocess
import sys
def create_image(directory, image):
def create_image(directory, image, label=None):
ents = 0
datasz = 512
for dir in os.walk(sys.argv[1]):
@ -25,8 +25,13 @@ def create_image(directory, image):
with open(image, 'wb') as imgfile:
imgfile.seek(datasz * 512 - 1)
imgfile.write(b'\x00')
subprocess.check_call(['mformat', '-i', image, '-r', '16', '-d', '1', '-t',
str(datasz), '-s', '1','-h', '1', '::'])
if label:
subprocess.check_call(['mformat', '-i', image, '-v', label,
'-r', '16', '-d', '1', '-t', str(datasz),
'-s', '1','-h', '1', '::'])
else:
subprocess.check_call(['mformat', '-i', image, '-r', '16', '-d', '1', '-t',
str(datasz), '-s', '1','-h', '1', '::'])
# Some clustered filesystems will have the lock from mformat
# linger after close (mformat doesn't unlock)
# do a blocking wait for shared lock and then explicitly
@ -50,4 +55,7 @@ if __name__ == '__main__':
sys.stderr.write("Usage: {0} <directory> <imagefile>".format(
sys.argv[0]))
sys.exit(1)
create_image(sys.argv[1], sys.argv[2])
label = None
if len(sys.argv) > 3:
label = sys.argv[3]
create_image(sys.argv[1], sys.argv[2], label)

View File

@ -75,6 +75,7 @@ def update_boot(profilename):
update_boot_esxi(profiledir, profile, label)
def update_boot_esxi(profiledir, profile, label):
profname = os.path.basename(profiledir)
kernelargs = profile.get('kernelargs', '')
oum = os.umask(0o22)
bootcfg = open('{0}/distribution/BOOT.CFG'.format(profiledir), 'r').read()
@ -140,10 +141,11 @@ def update_boot_esxi(profiledir, profile, label):
ipxeout.close()
subprocess.check_call(
['/opt/confluent/bin/dir2img', '{0}/boot'.format(profiledir),
'{0}/boot.img'.format(profiledir)], preexec_fn=relax_umask)
'{0}/boot.img'.format(profiledir), profname], preexec_fn=relax_umask)
def update_boot_linux(profiledir, profile, label):
profname = os.path.basename(profiledir)
kernelargs = profile.get('kernelargs', '')
grubcfg = "set timeout=5\nmenuentry '"
grubcfg += label
@ -178,7 +180,7 @@ def update_boot_linux(profiledir, profile, label):
ipxeout.close()
subprocess.check_call(
['/opt/confluent/bin/dir2img', '{0}/boot'.format(profiledir),
'{0}/boot.img'.format(profiledir)], preexec_fn=relax_umask)
'{0}/boot.img'.format(profiledir), profname], preexec_fn=relax_umask)
def extract_entries(entries, flags=0, callback=None, totalsize=None, extractlist=None):