From 3b9e66bed475b522a4e4681e6e87acfae622b06b Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Tue, 15 Oct 2024 18:05:43 +0200 Subject: [PATCH] install_xcpng: setup admin iface as static if name has an IP in data.py Uses the HOSTS_IP_CONFIG struct already usable to set this config for automated install tests. Signed-off-by: Yann Dirson --- lib/host.py | 15 ++++++++++++--- scripts/install_xcpng.py | 16 ++++++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/host.py b/lib/host.py index d7569962f..ec52ff26c 100644 --- a/lib/host.py +++ b/lib/host.py @@ -21,12 +21,21 @@ def host_data(hostname_or_ip): # read from data.py - from data import HOST_DEFAULT_USER, HOST_DEFAULT_PASSWORD, HOSTS + from data import HOST_DEFAULT_USER, HOST_DEFAULT_PASSWORD, HOSTS, HOSTS_IP_CONFIG if hostname_or_ip in HOSTS: h_data = HOSTS[hostname_or_ip] - return h_data + ret = h_data else: - return {'user': HOST_DEFAULT_USER, 'password': HOST_DEFAULT_PASSWORD} + ret = {'user': HOST_DEFAULT_USER, 'password': HOST_DEFAULT_PASSWORD} + # + ip = HOSTS_IP_CONFIG.get('ip', None) + if ip: + ret.update(ip=ip, + netmask=HOSTS_IP_CONFIG['NETMASK'], + gw=HOSTS_IP_CONFIG['GATEWAY'], + dns=HOSTS_IP_CONFIG['DNS']) + + return ret class Host: xe_prefix = "host" diff --git a/scripts/install_xcpng.py b/scripts/install_xcpng.py index af0e71f70..ae33d775c 100755 --- a/scripts/install_xcpng.py +++ b/scripts/install_xcpng.py @@ -25,7 +25,19 @@ logging.basicConfig(format='[%(levelname)s] %(message)s', level=logging.INFO) def generate_answerfile(directory, installer, hostname_or_ip, target_hostname, action, hdd, netinstall_gpg_check): - password = host_data(hostname_or_ip)['password'] + h_data = host_data(hostname_or_ip) + password = h_data['password'] + if 'ip' in h_data: + iface = f""" + + {h_data['ip']} + {h_data['netmask']} + {h_data['gw']} + + {h_data['dns']} + """ + else: + iface = '' cmd = ['openssl', 'passwd', '-6', password] res = subprocess.run(cmd, stdout=subprocess.PIPE) encrypted_password = res.stdout.decode().strip() @@ -42,7 +54,7 @@ def generate_answerfile(directory, installer, hostname_or_ip, target_hostname, a {hdd} {encrypted_password} {installer} - +{iface} Europe/Paris {target_hostname}