- log.write("Generating {} host key {}\n".format(label, key_file))
- utils.sysexec_chroot(SYSIMG_PATH, "{} -q -t {} -f {} -C '' -N ''"\
- .format(key_gen_prog, key_type, key_file), log)
- utils.sysexec("chmod 600 {}/{}".format(SYSIMG_PATH, key_file), log)
- utils.sysexec("chmod 644 {}/{}.pub".format(SYSIMG_PATH, key_file), log)
-
+ log.write("Generating {} host key {} (mandatory success={})\n"
+ .format(label, key_file, mandatory))
+ if mandatory:
+ run = utils.sysexec
+ run_chroot = utils.sysexec_chroot
+ else:
+ run = utils.sysexec_noerr
+ run_chroot = utils.sysexec_chroot_noerr
+ run_chroot(SYSIMG_PATH, "{} -q -t {} -f {} -C '' -N ''"\
+ .format(key_gen_prog, key_type, key_file), log)
+ run("chmod 600 {}/{}".format(SYSIMG_PATH, key_file), log)
+ run("chmod 644 {}/{}.pub".format(SYSIMG_PATH, key_file), log)
+