Skip to content

Commit

Permalink
Merge pull request os-autoinst#20777 from rfan1/ipxe_sle16
Browse files Browse the repository at this point in the history
Enable Agama auto install on Bare Metal server
  • Loading branch information
rfan1 authored Dec 18, 2024
2 parents 4bb114c + 51ba290 commit 6ed938f
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 7 deletions.
10 changes: 10 additions & 0 deletions lib/version_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use constant {
is_sle_micro
is_micro
is_alp
is_agama
is_selfinstall
is_gnome_next
is_jeos
Expand Down Expand Up @@ -987,3 +988,12 @@ sub has_selinux_by_default {
sub has_selinux {
return get_var('SELINUX', has_selinux_by_default);
}

=head2 is_agama
Check if agama installation is being used
=cut

sub is_agama {
return (get_var('AGAMA') || get_var('AGAMA_AUTO'));
}
69 changes: 66 additions & 3 deletions tests/installation/agama_reboot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
# Copyright 2024 SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: Installation of Leap or Tumbleweed with Agama
# Summary: Installation of Sle/Leap or Tumbleweed with Agama
# https://github.com/openSUSE/agama/

# Exepcted to be executed right after agama.pm
# Exepcted to be executed right after agama.pm or agama auto install
# This test handles actions that happen once we see the reboot button after install
# 1) Switch from installer to console to Upload logs
# 2) Switch back to X11/Wayland and reset_console s
# so newly booted system does not think that we're still logged in console
# 3) workaround for no ability to disable grub timeout in agama
# https://github.com/openSUSE/agama/issues/1594
# grub_test() is too slow to catch boot screen for us
# 4) for ipmi backend, vnc access during the installation is not available now,
# we need to access to live root system to monitor installation process
# Maintainer: Lubos Kocman <lubos.kocman@suse.com>,

use strict;
Expand All @@ -24,12 +26,14 @@ use version_utils qw(is_leap is_sle);
use utils;
use Utils::Logging qw(export_healthcheck_basic);
use x11utils 'ensure_unlocked_desktop';
use Utils::Backends qw(is_ipmi);
use Utils::Architectures qw(is_aarch64);

sub upload_agama_logs {
return if (get_var('NOLOGS'));
select_console("root-console");
# stores logs in /tmp/agma-logs.tar.gz
script_run('agama logs store');
script_run('agama logs store -d /tmp');
upload_logs('/tmp/agama-logs.tar.gz');
}

Expand All @@ -38,9 +42,68 @@ sub get_agama_install_console_tty {
return 7;
}

sub verify_agama_auto_install_done_cmdline {
# for some remote workers, there is no vnc access to the install console,
# so we need to make sure the installation has completed from command line.
my $timeout = 300;
while ($timeout > 0) {
if (script_run("journalctl -u agama | grep 'Install phase done'") == 0) {
record_info("agama install phase done");
return;
}
sleep 20;
$timeout = $timeout - 20;
}
die "Install phase is not done, please check agama logs";
}

sub agama_system_prepare_ipmi {
# Mount the root disk after installation, and do some prepare tasks:
# Configure serial console, enable root ssh access, etc

# Get the root disk name
my $device = script_output qq(agama config show | grep -oP '(?<="disk": ")[^"]+');
# Use partition prefix for nvme devices
my $prefix = $device =~ /nvme/ ? "p" : "";
my $root_partition_id = 2;
my $root_partition = "${device}" . $prefix . $root_partition_id;
record_info("Device information", "Device: ${device}\nRoot partition: ${root_partition}");
assert_script_run("mount ${root_partition} /mnt");
# Set correct serial console to be able to see login in first boot
record_info("Set serial console");
my $sol_console = (is_aarch64) ? get_var('SERIALCONSOLE', 'ttyAMA0') : get_var('SERIALCONSOLE', 'ttyS1');
assert_script_run("sed -i 's/quiet/console=$sol_console,115200/g' /mnt/boot/grub2/grub.cfg");
# Upload original grub configuration
upload_logs("/mnt/etc/default/grub", failok => 1);
upload_logs("/mnt/boot/grub2/grub.cfg", failok => 1);
# Set permanent grub configuration
assert_script_run("sed -i 's/quiet/console=$sol_console,115200/g' /mnt/etc/default/grub");
# Enable root ssh access
record_info("Enable root ssh login");
assert_script_run("echo 'PermitRootLogin yes' > /mnt/etc/ssh/sshd_config.d/root.conf");
assert_script_run("umount /mnt");
}

sub run {
my ($self) = @_;

if (is_ipmi && get_var('AGAMA_AUTO')) {
select_console('root-console');
record_info 'Wait for installation phase done';
verify_agama_auto_install_done_cmdline();
script_run('agama logs store -d /tmp');
upload_logs('/tmp/agama-logs.tar.gz');
record_info 'Prepare system before rebooting';
agama_system_prepare_ipmi();
record_info 'Reboot system to disk boot';
enter_cmd 'reboot';
# Swith back to sol console, then user can monitor the boot log
select_console 'sol', await_console => 0;
wait_still_screen 10;
save_screenshot;
return;
}

assert_screen('agama-congratulations');
console('installation')->set_tty(get_agama_install_console_tty());
upload_agama_logs();
Expand Down
67 changes: 63 additions & 4 deletions tests/installation/ipxe_install.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use utils;
use testapi;
use bmwqemu;
use ipmi_backend_utils;
use version_utils qw(is_upgrade is_tumbleweed is_sle is_leap is_sle_micro);
use version_utils qw(is_upgrade is_tumbleweed is_sle is_leap is_sle_micro is_agama);
use bootloader_setup 'prepare_disks';
use Utils::Architectures;
use Utils::Backends qw(is_ipmi is_qemu);
Expand Down Expand Up @@ -132,6 +132,38 @@ END_BOOTSCRIPT
set_ipxe_bootscript($bootscript);
}

sub set_bootscript_agama {
my $host = get_required_var('SUT_IP');
my $arch = get_required_var('ARCH');
my $mirror_http = get_required_var('MIRROR_HTTP');
my $openqa_hostname = get_var('OPENQA_HOSTNAME', 'openqa.suse.de');
my $agama_iso = get_required_var('ISO');
my $agama_live_iso = get_var("AGAMA_LIVE_ISO_URL", "http://$openqa_hostname/assets/iso/$agama_iso");
my $install = "root=live:$agama_live_iso live.password=$testapi::password";
my $kernel = "$mirror_http/boot/$arch/loader/linux";
my $initrd = "$mirror_http/boot/$arch/loader/initrd";

my $cmdline_extra = set_bootscript_agama_cmdline_extra();

my $bootscript = <<"END_BOOTSCRIPT";
#!ipxe
echo ++++++++++++++++++++++++++++++++++++++++++
echo +++++++++ openQA agama ipxe boot +++++++++
echo + Host: $host
echo ++++++++++++++++++++++++++++++++++++++++++
echo Loading kernel
kernel $kernel $install $cmdline_extra
echo Loading initrd
initrd $initrd
sleep 3
echo Starting the installation
boot
END_BOOTSCRIPT

set_ipxe_bootscript($bootscript);
}

sub enter_o3_ipxe_boot_entry {
ipmitool('chassis power reset') unless check_screen([qw(o3-ipxe-menu ipxe-boot-failure)], 180);
assert_screen('o3-ipxe-menu', 210);
Expand All @@ -147,8 +179,29 @@ sub enter_o3_ipxe_boot_entry {
}
}

sub set_bootscript_cmdline_extra {

sub set_bootscript_agama_cmdline_extra {
my $cmdline_extra = " ";
if (get_var('AGAMA_AUTO')) {
my $agama_auto = data_url(get_var('AGAMA_AUTO'));
$agama_auto =~ s/^\s+|\s+$//g;
$cmdline_extra .= "agama.auto=$agama_auto ";
}
# Agama Installation repository URL
# By default Agama installs the packages from the repositories specified in the product configuration.
# From now Agama supports using the agama.install_url boot parameter for overriding the default installation repositories.
if (my $agama_install_url = get_var('AGAMA_INSTALL_URL')) {
$agama_install_url =~ s/^\s+|\s+$//g;
$cmdline_extra .= "agama.install_url=$agama_install_url ";
}
if (is_ipmi) {
my $sol_console = get_required_var('IPXE_CONSOLE');
$cmdline_extra .= "console=$sol_console linuxrc.log=/dev/$sol_console linuxrc.core=/dev/$sol_console linuxrc.debug=4,trace ";
}
return $cmdline_extra;
}

sub set_bootscript_cmdline_extra {
my $cmdline_extra = " ";
my $regurl = get_var('VIRT_AUTOTEST') ? get_var('HOST_SCC_URL', '') : get_var('SCC_URL', '');
my $console = get_var('IPXE_CONSOLE', '');
Expand Down Expand Up @@ -214,7 +267,6 @@ sub set_bootscript_cmdline_extra {
$cmdline_extra .= " reboot_timeout=" . get_var('REBOOT_TIMEOUT', 0) . ' '
unless (is_leap('<15.2') || is_sle('<15-SP2'));
$cmdline_extra .= get_var('EXTRABOOTPARAMS', '');

return $cmdline_extra;
}

Expand Down Expand Up @@ -277,7 +329,7 @@ sub run {
die "Can't set AUTOYAST for usb boot!" if (get_var('AUTOYAST', '') && is_usb_boot);

# virtualization tests use a static ipxe configuration file in O3
set_bootscript unless get_var('IPXE_STATIC');
is_agama ? set_bootscript_agama : set_bootscript unless (get_var('IPXE_STATIC'));

set_pxe_boot;

Expand All @@ -290,6 +342,13 @@ sub run {
return;
}

if (is_agama) {
assert_screen([qw(load-linux-kernel load-initrd)], 240);
record_info("Installing", "Please check the expected product is being installed");
assert_screen('agama-installer-live-root', 400);
return;
}

# Print screenshots for ipxe boot process
if (get_var('VIRT_AUTOTEST')) {
#it is static menu and choose the TW entry to start installation
Expand Down
11 changes: 11 additions & 0 deletions variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,3 +482,14 @@ Variable | Type | Default value | Details
--- | --- | --- | ---
SCC_RECGODE_LTSS | string | | This will hold the registration code for activating the product SLES-LTSS
SCC_RECGODE_LTSS_ES | string | | This will hold the registration code for activating the product SLES-LTSS-Extended-Security

### Agama specific variables

Following variables are relevant for agama installation

Variable | Type | Default value | Details
--- | --- | --- | ---
AGAMA | boolean | 0 | Agama installation support
AGAMA_AUTO | string | | The auto-installation is started by passing `agama.auto=<url>` on the kernel's command line
AGAMA_LIVE_ISO_URL | string | | The url of agama live iso to pass as kernel's command-line parameter. Example of usage "root=live:http://agama.iso"
AGAMA_INSTALL_URL | string | | This will support using 'agama.install_url' boot parameter for overriding the default installation repositories. You can use multiple URLs separated by comma: agama.install_url=https://example.com/1,https://example.com/2

0 comments on commit 6ed938f

Please sign in to comment.