2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-22 18:32:13 +00:00

feat(uftp): receive the root image over UFTP on SLES stateless nodes

genimage gives the stateless initial ramdisk of a SLES or openSUSE Leap
image with dracut 033 or later the same UFTP receiver as an EL image. It
adds the helper and uftpd when the image has the UFTP 5 receiver of
xcat-dep for its architecture, checks the built ramdisk, and marks it
for nodeset. xcatroot receives the first copy of the image over UFTP
when nodeset asks for it, and checks it like an HTTP download.
This commit is contained in:
Vinícius Ferrão
2026-10-17 13:43:33 -03:00
parent d4ea2c6c51
commit a4cef2c4ce
3 changed files with 36 additions and 2 deletions
@@ -7,3 +7,13 @@ dracut_install parted mke2fs bc mkswap swapon chmod mkfs mkfs.ext4 mkfs.xfs xfs_
inst "$moddir/xcat-updateflag" "/tmp/updateflag"
inst "$moddir/xcatroot" "/sbin/xcatroot"
inst_hook cmdline 10 "$moddir/xcat-cmdline.sh"
# genimage adds the UFTP helper only when the image has a UFTP 5 receiver.
if [ -r "$moddir/xcat-rootimg-fetch.sh" ]; then
inst "$moddir/xcat-rootimg-fetch.sh" "/lib/xcat-rootimg-fetch.sh"
for uftpd in /usr/sbin/uftpd /usr/bin/uftpd; do
if [ -x "$uftpd" ]; then
dracut_install "$uftpd"
break
fi
done
fi
@@ -57,7 +57,23 @@ rootimg_matches_checksum() {
return 1
}
# Downloads the image at $1 to the file $2, over UFTP the first time when nodeset asks for it.
rootimg_download() {
if [ -n "$rootimg_uftp" ]; then
rootimg_uftp_port=$rootimg_uftp
rootimg_uftp=
# nodeset asks for UFTP only with the checksum, which the caller checks on the received file.
if [ "$rootimgchecksum" = yes ] && [ -r /lib/xcat-rootimg-fetch.sh ] && . /lib/xcat-rootimg-fetch.sh &&
xcat_uftp_rootimg "$1" "$2" /tmp/rootimg.sha256.before "$rootimg_uftp_port" "$(getarg xcat.uftpfp=)"; then
return 0
fi
logger $SYSLOGHOST -t $log_label -p local4.warning "Cannot receive $1 over UFTP, downloading it over HTTP..."
fi
wget -nv "$1"
}
rootimgchecksum="$(getarg rootimgchecksum=)"
rootimg_uftp="$(getarg xcat.uftp=)"
if [ ! -z "$imgurl" ]; then
if [ xhttp = x${imgurl%%:*} ] || [ xhttps = x${imgurl%%:*} ]; then
@@ -73,7 +89,7 @@ if [ ! -z "$imgurl" ]; then
[ "$xcatdebugmode" > "0" ] && logger -t $log_label -p debug "downloading $imgurl...."
echo Getting $imgurl...
[ "$rootimgchecksum" != yes ] || rootimg_fetch_checksum "$imgurl" /tmp/rootimg.sha256.before || rm -f /tmp/rootimg.sha256.before
if ! wget -nv $imgurl; then
if ! rootimg_download "$imgurl" "$FILENAME"; then
[ "$xcatdebugmode" > "0" ] && logger -t $log_label -p debug "downloading $imgurl failed,retrying...."
rm -f $FILENAME
sleep 27
+9 -1
View File
@@ -1057,6 +1057,10 @@ sub mkinitrd_dracut {
my $dracutmpath = $dracutmoduledir . "97xcat/";
mkpath($dracutmpath);
# Only a stateless initial ramdisk that checks the root image receives it over UFTP.
my $uftp_receiver = eval { imgutils::add_uftp_receiver($rootimg_dir, $arch, $dracutmpath, $mode eq 'stateless' && $dracutdir eq 'dracut_033') };
xdie($@) if $@;
my $perm = (stat("$fullpath/$dracutdir/check"))[2];
cp("$fullpath/$dracutdir/check", $dracutmpath);
chmod($perm & 07777, "$dracutmpath/check");
@@ -1177,8 +1181,12 @@ sub mkinitrd_dracut {
print "\nchroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver\n";
!system("chroot $rootimg_dir dracut $additional_options -f /tmp/initrd.$$.gz $kernelver")
or die("Error: failed to generate the initial ramdisk for $mode.\n");
eval { imgutils::check_uftp_initrd($rootimg_dir, "/tmp/initrd.$$.gz", $mode) } or xdie($@) if $uftp_receiver;
print "the initial ramdisk for $mode is generated successfully.\n";
move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz") and mark_rootimg_check($mode);
if (move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz")) {
mark_rootimg_check($mode);
imgutils::mark_uftp_receiver("$destdir/initrd-$mode.gz", $uftp_receiver) if $mode eq 'stateless';
}
}