in nodemanager/scripts/setup.py [0:0]
def updatecert():
if not is_hpcagent_installed():
Log("No hpc agent installed")
sys.exit(1)
certfile = None
certpasswd = None
authenticationkey = None
for a in sys.argv[2:]:
if re.match("^[-/]certfile:.+", a):
certfile = get_argvalue(a)
elif re.match("^[-/]certpasswd:.+", a):
certpasswd = get_argvalue(a)
elif re.match("^[-/]authenticationkey:.+", a):
authenticationkey = get_argvalue(a)
else:
print("Invalid argument: %s" % a)
Usage()
sys.exit(1)
if not os.path.isfile(certfile):
print("certfile not found: %s" % certfile)
sys.exit(1)
if not certpasswd:
certpasswd = getpass.getpass(prompt='Please input the certificate protection password:')
try:
generatekeypair(certfile, certpasswd)
if authenticationkey is not None:
configfile = os.path.join(InstallRoot, 'nodemanager.json')
if not os.path.isfile(configfile):
Log("nodemanager.json not found")
sys.exit(1)
with open(configfile, 'r') as F:
configjson = json.load(F)
configjson['ClusterAuthenticationKey'] = authenticationkey
SetFileContents(configfile, json.dumps(configjson))
os.chmod(configfile, 0o640)
print("The credentials were successfully updated")
if SupportSystemd:
Run("systemctl restart hpcagent")
else:
Run("service hpcagent restart")
sys.exit(0)
except Exception as e:
print("Failed to update certificate: {0}".format(e))
sys.exit(1)