From c8268940b1c69328f791175e162d9a358c614cea Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 23 Aug 2023 15:22:51 +0200 Subject: [PATCH] Use random hostname starting with xcp-ng- This allows to have different hostname when installing new VM. --- scripts/install_xcpng.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/install_xcpng.py b/scripts/install_xcpng.py index 4e0d87745..fe55a02fd 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,6 +49,9 @@ 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""" @@ -58,6 +63,7 @@ def generate_answerfile(directory, installer, hostname_or_ip, action, hdd): {installer} Europe/Paris + {hostname}