From c328a8cad72ba62c84dfe4ac6e7dfb7c94e917f0 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Thu, 17 Aug 2023 15:04:44 +0200 Subject: [PATCH] Generate a random hostname starting with xcp-ng Signed-off-by: Guillaume --- scripts/install_xcpng.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/install_xcpng.py b/scripts/install_xcpng.py index 4e0d87745..1cc9aae2c 100755 --- a/scripts/install_xcpng.py +++ b/scripts/install_xcpng.py @@ -4,7 +4,9 @@ import atexit import logging import os +import random import requests +import string import subprocess import sys import tempfile @@ -47,11 +49,13 @@ def generate_answerfile(directory, installer, hostname_or_ip, action, hdd): cmd = ['openssl', 'passwd', '-6', password] res = subprocess.run(cmd, stdout=subprocess.PIPE) encrypted_password = res.stdout.decode().strip() + hostname = "xcp-ng-" + "".join(random.choice(string.ascii_lowercase) for i in range(5)) with open(f'{directory}/answerfile.xml', 'w') as answerfile: if action == 'install': answerfile.write(f""" fr + {hostname} {hdd} {hdd} {encrypted_password}