diff --git a/confluent_client/bin/dir2img b/confluent_client/bin/dir2img index 331eb365..abfc4b25 100644 --- a/confluent_client/bin/dir2img +++ b/confluent_client/bin/dir2img @@ -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} ".format( sys.argv[0])) sys.exit(1) - create_image(sys.argv[1], sys.argv[2]) \ No newline at end of file + label = None + if len(sys.argv) > 3: + label = sys.argv[3] + create_image(sys.argv[1], sys.argv[2], label) \ No newline at end of file diff --git a/confluent_server/confluent/osimage.py b/confluent_server/confluent/osimage.py index 072303e3..04300d9a 100644 --- a/confluent_server/confluent/osimage.py +++ b/confluent_server/confluent/osimage.py @@ -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):