Skip to content

Commit

Permalink
fixup! install 7/n: answerfile generation
Browse files Browse the repository at this point in the history
This gets back to DHCP, as static IPs are not needed for this part of
the job.
  • Loading branch information
ydirson committed Oct 17, 2024
1 parent b1d7b31 commit d8a1ccf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 33 deletions.
12 changes: 0 additions & 12 deletions data.py-dist
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ PXE_CONFIG_SERVER = 'pxe'
# Default VM images location
DEF_VM_URL = 'http://pxe/images/'

# IP addresses for hosts to be installed
# NOTE: do NOT set an IP for host1, it is assumed to use DEFAULT
HOSTS_IP_CONFIG = {
'HOSTS': {
# 'DEFAULT': '192.16.0.1',
# 'host2': '192.16.0.2',
},
# 'NETMASK': '255.255.0.0',
# 'GATEWAY': '192.16.0.254',
# 'DNS': '192.16.0.254',
}

# Tools
TOOLS = {
# "iso-remaster": "/home/user/src/xcpng/xcp/scripts/iso-remaster/iso-remaster.sh",
Expand Down
11 changes: 2 additions & 9 deletions tests/install/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,11 @@ def answerfile(request):
answerfile_def = callable_marker(marker.args[0], request)
assert isinstance(answerfile_def, AnswerFile)

from data import HOSTS_IP_CONFIG
answerfile_def.top_append(
dict(TAG="admin-interface",
name="eth0",
proto="static",
CONTENTS=(
dict(TAG='ipaddr', CONTENTS=HOSTS_IP_CONFIG['HOSTS']['DEFAULT']),
dict(TAG='subnet', CONTENTS=HOSTS_IP_CONFIG['NETMASK']),
dict(TAG='gateway', CONTENTS=HOSTS_IP_CONFIG['GATEWAY']),
)),
dict(TAG="name-server",
CONTENTS=HOSTS_IP_CONFIG['DNS']),
proto="dhcp",
),
)

yield answerfile_def
Expand Down
21 changes: 9 additions & 12 deletions tests/install/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from lib.pool import Pool
from lib.vdi import VDI

from data import HOSTS_IP_CONFIG, ISO_IMAGES, NETWORKS
from data import ISO_IMAGES, NETWORKS
assert "MGMT" in NETWORKS
assert "HOSTS" in HOSTS_IP_CONFIG

# Requirements:
# - one XCP-ng host capable of nested virt, with an ISO SR, and a default SR
Expand Down Expand Up @@ -122,13 +121,6 @@ def test_tune_firstboot(self, create_vms, helper_vm_with_plugged_disk,
# hostname
logging.info("Setting hostname to %r", machine)
helper_vm.ssh(["echo > /mnt/etc/hostname", machine])
# management IP
if machine in HOSTS_IP_CONFIG['HOSTS']:
ip = HOSTS_IP_CONFIG['HOSTS'][machine]
logging.info("Changing IP to %s", ip)

helper_vm.ssh([f"sed -i s/^IP=.*/IP='{ip}'/",
"/mnt/etc/firstboot.d/data/management.conf"])
# UUIDs
logging.info("Randomizing UUIDs")
helper_vm.ssh(
Expand Down Expand Up @@ -182,9 +174,14 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=Fal
host_vm.start()
wait_for(host_vm.is_running, "Wait for host VM running")

host_vm.ip = HOSTS_IP_CONFIG['HOSTS'].get(machine,
HOSTS_IP_CONFIG['HOSTS']['DEFAULT'])
logging.info("Expecting host VM to have IP %s", host_vm.ip)
# catch host-vm IP address
wait_for(lambda: pxe.arp_addresses_for(mac_address),
"Wait for DHCP server to see Host VM in ARP tables",
timeout_secs=10 * 60)
ips = pxe.arp_addresses_for(mac_address)
logging.info("Host VM has IPs %s", ips)
assert len(ips) == 1
host_vm.ip = ips[0]

wait_for(
lambda: commands.local_cmd(
Expand Down

0 comments on commit d8a1ccf

Please sign in to comment.