1010from lib .installer import AnswerFile
1111from lib .commands import local_cmd
1212
13- from data import (ISO_IMAGES , ISO_IMAGES_BASE , ISO_IMAGES_CACHE ,
13+ from data import (ISO_IMAGES , ISO_IMAGES_BASE , ISO_IMAGES_CACHE , HOSTS_IP_CONFIG ,
1414 ARP_SERVER , TEST_SSH_PUBKEY , TOOLS )
1515
1616# Return true if the version of the ISO doesn't support the source type.
@@ -71,8 +71,14 @@ def answerfile(request):
7171 answerfile_def .top_append (
7272 dict (TAG = "admin-interface" ,
7373 name = "eth0" ,
74- proto = "dhcp" ,
75- ),
74+ proto = "static" ,
75+ CONTENTS = (
76+ dict (TAG = 'ipaddr' , CONTENTS = HOSTS_IP_CONFIG ['HOSTS' ]['DEFAULT' ]),
77+ dict (TAG = 'subnet' , CONTENTS = HOSTS_IP_CONFIG ['NETMASK' ]),
78+ dict (TAG = 'gateway' , CONTENTS = HOSTS_IP_CONFIG ['GATEWAY' ]),
79+ )),
80+ dict (TAG = "name-server" ,
81+ CONTENTS = HOSTS_IP_CONFIG ['DNS' ]),
7682 )
7783
7884 yield answerfile_def
@@ -105,7 +111,22 @@ def installer_iso(request):
105111@pytest .fixture (scope = 'function' )
106112def install_disk (request ):
107113 firmware = request .getfixturevalue ("firmware" )
108- yield {"uefi" : "nvme0n1" , "bios" : "sda" }[firmware ]
114+ if firmware .startswith ("uefi" ):
115+ yield "nvme0n1"
116+ elif firmware .startswith ("bios" ):
117+ yield "sda"
118+ else :
119+ assert False , f"unknown firmware { firmware !r} "
120+
121+ @pytest .fixture (scope = 'function' )
122+ def answerfile_maybe_tweak_parttable (request , answerfile ):
123+ firmware = request .getfixturevalue ("firmware" )
124+ if firmware .endswith ("+dell" ):
125+ answerfile .top_append (dict (TAG = "script" , stage = "installation-start" ,
126+ type = "url" , CONTENTS = "file:///root/preinstall-utilitypart.sh" ))
127+ if firmware .endswith ("+mbr" ):
128+ answerfile .top_append (dict (TAG = "script" , stage = "installation-start" ,
129+ type = "url" , CONTENTS = "file:///root/preinstall-mbrparttable.sh" ))
109130
110131# Remasters the ISO sepecified by `installer_iso` mark, with:
111132# - network and ssh support activated, and .ssh/authorized_key so tests can
@@ -120,7 +141,7 @@ def install_disk(request):
120141# in contexts where the same IP is reused by successively different MACs
121142# (when cloning VMs from cache)
122143@pytest .fixture (scope = 'function' )
123- def remastered_iso (installer_iso , answerfile ):
144+ def remastered_iso (installer_iso , answerfile , install_disk ):
124145 iso_file = installer_iso ['iso' ]
125146 unsigned = installer_iso ['unsigned' ]
126147
@@ -219,6 +240,30 @@ def remastered_iso(installer_iso, answerfile):
219240 chmod +x "$INSTALLIMG/etc/init.d/S12test-pingpxe"
220241fi
221242
243+ cat > "$INSTALLIMG/root/preinstall-utilitypart.sh" <<'EOF'
244+ #!/bin/sh
245+ set -ex
246+
247+ # Dell utility partition
248+ sgdisk --zap-all /dev/{ install_disk }
249+ sfdisk /dev/{ install_disk } << 'EOP'
250+ unit: sectors
251+ p1 : start= 2048, size= 32768, Id=de
252+ EOP
253+ EOF
254+
255+ cat > "$INSTALLIMG/root/preinstall-mbrparttable.sh" <<'EOF'
256+ #!/bin/sh
257+ set -ex
258+
259+ # Dell utility partition
260+ sgdisk --zap-all /dev/{ install_disk }
261+ sfdisk /dev/{ install_disk } << 'EOP'
262+ unit: sectors
263+ p1 : start= 2048, size= 32768, Id=83
264+ EOP
265+ EOF
266+
222267cat > "$INSTALLIMG/root/postinstall.sh" <<'EOF'
223268#!/bin/sh
224269set -ex
@@ -288,6 +333,8 @@ def vm_booted_with_installer(host, create_vms, remastered_iso):
288333 host_vm .insert_cd (os .path .basename (remote_iso ))
289334
290335 try :
336+ pxe .arp_clear_for (mac_address )
337+
291338 host_vm .start ()
292339 wait_for (host_vm .is_running , "Wait for host VM running" )
293340
0 commit comments