Skip to content

Commit

Permalink
[Virtualization]: Wipe all disks before host installation
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-suse committed Sep 30, 2024
1 parent 57a50c0 commit 2774659
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<timeout config:type="integer">15</timeout>
<trusted_grub>false</trusted_grub>
<secure_boot>false</secure_boot>
% if ($check_var->('IPXE_UEFI', '1')) {
<update_nvram>true</update_nvram>
% }
<terminal>console</terminal>
% if ($check_var->('SYSTEM_ROLE', 'xen')) {
<xen_append>vt.color=0x07 splash=silent console=hvc0 <%= defined $bmwqemu::vars{"ENABLE_CONSOLE_KERNEL_LOG"} ? "loglvl=all guest_loglvl=all" : "loglvl=debug guest_loglvl=debug" %> <%= defined $bmwqemu::vars{"OPT_KERNEL_PARAMS"} ? $bmwqemu::vars{"OPT_KERNEL_PARAMS"} : "" %></xen_append>
Expand Down Expand Up @@ -302,6 +305,28 @@
</user>
</users>
<scripts>
<pre-scripts config:type="list">
<script>
<filename>pre_erase_all_disks.sh</filename>
<interpreter>shell</interpreter>
<source><![CDATA[
#!/bin/sh
disks=$(lsblk -n -l -o NAME -d -e 7,11,254);
for disk in $disks;do
echo "Wiping /dev/$disk..."
wipefs -af /dev/$disk
sync
parted -s /dev/$disk mklabel gpt
sync
done
echo "All disks are wiped out."
lsblk
]]>
</source>
<feedback config:type="boolean">false</feedback>
<notification>Please wait while pre-script is running...</notification>
</script>
</pre-scripts>
<init-scripts config:type="list">
% if ($check_var->('SYSTEM_ROLE', 'xen') && $check_var->('XEN_DEFAULT_BOOT_IS_SET', 1)) {
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
<hiddenmenu>false</hiddenmenu>
<os_prober>false</os_prober>
<secure_boot>false</secure_boot>
% if ($check_var->('IPXE_UEFI', '1')) {
<update_nvram>true</update_nvram>
% }
<serial>serial --speed=115200 --unit=<%= $get_var->('SERIALDEV', 'ttyS1') =~ s/ttyS//r %> --word=8 --parity=no --stop=1</serial>
<timeout config:type="integer">15</timeout>
<trusted_grub>false</trusted_grub>
Expand Down Expand Up @@ -280,6 +283,27 @@
</user>
</users>
<scripts>
<pre-scripts config:type="list">
<script>
<filename>pre_erase_all_disks.sh</filename>
<interpreter>/bin/bash -x</interpreter>
<source><![CDATA[
disks=$(lsblk -n -l -o NAME -d -e 7,11,254);
for disk in $disks;do
echo "Wiping /dev/$disk..."
wipefs -af /dev/$disk
sync
parted -s /dev/$disk mklabel gpt
sync
done
echo "All disks are wiped out."
lsblk
]]>
</source>
<feedback config:type="boolean">false</feedback>
<notification>Please wait while pre-script is running...</notification>
</script>
</pre-scripts>
<chroot-scripts config:type="list">
<script>
<!-- Keep ssh connection alive for long-time run test -->
Expand Down
2 changes: 1 addition & 1 deletion tests/installation/ipxe_install.pm
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ sub run {
if (check_screen(\@tags, $ssh_vnc_wait_time)) {
save_screenshot;
sleep 2;
return if is_usb_boot;
prepare_disks if (!is_upgrade && !get_var('KEEP_DISKS'));
return if is_usb_boot;
}
else {
save_screenshot;
Expand Down
1 change: 0 additions & 1 deletion tests/installation/usb_install.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use LWP::Simple 'head';
use Utils::Backends 'use_ssh_serial_console';

sub run {
assert_screen('sshd-server-started', 5);
use_ssh_serial_console;
assert_script_run("set -o pipefail");

Expand Down
14 changes: 13 additions & 1 deletion tests/virt_autotest/login_console.pm
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,24 @@ sub run {

sub post_fail_hook {
my ($self) = @_;
if (check_var('PERF_KERNEL', '1')) {
if (check_var('PERF_KERNEL', '1') || check_var('VIRT_AUTOTEST', '1')) {
select_console 'log-console';
save_screenshot;
script_run "save_y2logs /tmp/y2logs.tar.bz2";
upload_logs "/tmp/y2logs.tar.bz2";
save_screenshot;
if (check_var('VIRT_AUTOTEST', '1')) {
# show efi boot entry
if (check_var('IPXE_UEFI', '1')) {
record_info('UEFI entries', script_output('efibootmgr -v'));
record_info('Boot partition contents', script_output('ls -R /boot/efi'));
}
if (get_var('AUTOYAST', '')) {
script_run "tar czvf /tmp/autoinstall.tar.gz /var/adm/autoinstall";
upload_logs "/tmp/autoinstall.tar.gz";
}
$self->SUPER::post_fail_hook;
}
}
else {
$self->SUPER::post_fail_hook;
Expand Down

0 comments on commit 2774659

Please sign in to comment.