From 96b4e62fce5054f075cbe6e7d8fe348fce0cfa88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Wed, 26 Aug 2026 17:25:00 -0300 Subject: [PATCH] refactor(dhcp): expose ISC client boot policy --- perl-xCAT/xCAT/DHCP/BootPolicy.pm | 44 ++++++++++++++++++++++++++ xCAT-server/lib/xcat/plugins/dhcp.pm | 47 +++++----------------------- 2 files changed, 51 insertions(+), 40 deletions(-) diff --git a/perl-xCAT/xCAT/DHCP/BootPolicy.pm b/perl-xCAT/xCAT/DHCP/BootPolicy.pm index c574df125..ba33b89b6 100644 --- a/perl-xCAT/xCAT/DHCP/BootPolicy.pm +++ b/perl-xCAT/xCAT/DHCP/BootPolicy.pm @@ -102,6 +102,50 @@ sub kea_httpboot_network_classes { return \@classes; } +sub isc_client_architecture_lines { + my ( $class, %opts ) = @_; + + my $tftp = $opts{next_server} // ''; + my $portsuffix = $opts{portsuffix} // ''; + my $tftpdir = $opts{tftpdir} // '/tftpboot'; + my $net = $opts{net} // ''; + my $maskbits = $opts{prefix} // ''; + + return [ + " if option user-class-identifier = \"xNBA\" and option client-architecture = 00:00 { #x86, xCAT Network Boot Agent\n", + " always-broadcast on;\n", + " filename = \"http://$tftp$portsuffix/tftpboot/xcat/xnba/nets/${net}_${maskbits}\";\n", + " } else if option user-class-identifier = \"xNBA\" and option client-architecture = 00:09 { #x86, xCAT Network Boot Agent\n", + " filename = \"http://$tftp$portsuffix/tftpboot/xcat/xnba/nets/${net}_${maskbits}.uefi\";\n", + " } else if option user-class-identifier = \"xNBA\" and option client-architecture = 00:07 { #x86-64 UEFI, xCAT Network Boot Agent\n", + " filename = \"http://$tftp$portsuffix/tftpboot/xcat/xnba/nets/${net}_${maskbits}.uefi\";\n", + " } else if option client-architecture = 00:00 { #x86\n", + " filename \"xcat/xnba.kpxe\";\n", + " } else if option vendor-class-identifier = \"Etherboot-5.4\" { #x86\n", + " filename \"xcat/xnba.kpxe\";\n", + " } else if option client-architecture = 00:07 { #x86_64 uefi\n ", + " filename \"xcat/xnba.efi\";\n", + " } else if option client-architecture = 00:09 { #x86_64 uefi alternative id\n ", + " filename \"xcat/xnba.efi\";\n", + " } else if option client-architecture = 00:02 { #ia64\n ", + " filename \"elilo.efi\";\n", + " } else if option client-architecture = 00:0b { #aaarch64\n ", + " filename \"boot/grub2/grub2.aarch64\";\n", + " } else if option client-architecture = 00:1b { #riscv64 uefi\n ", + " filename \"boot/grub2/grub2.riscv64\";\n", + " } else if option client-architecture = 00:1c { #riscv64 uefi http boot\n ", + " option vendor-class-identifier \"HTTPClient\";\n", + " filename \"http://$tftp$portsuffix$tftpdir/boot/grub2/grub2.riscv64\";\n", + " } else if option client-architecture = 00:0e { #OPAL-v3\n ", + " option conf-file = \"http://$tftp$portsuffix/tftpboot/pxelinux.cfg/p/${net}_${maskbits}\";\n", + " } else if substring (option vendor-class-identifier,0,11) = \"onie_vendor\" { #for onie on cumulus switch\n", + " option www-server = \"http://$tftp$portsuffix/install/onie/onie-installer\";\n", + " } else if substring(filename,0,1) = null { #otherwise, provide yaboot if the client isn't specific\n ", + " filename \"/yaboot\";\n", + " }\n", + ]; +} + sub kea_xnba_node_classes { my ( $class, %opts ) = @_; diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index e6691730e..150f8613d 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -4454,46 +4454,13 @@ sub addnet } # $lstatements = 'if exists gpxe.bus-id { filename = \"\"; } else if exists client-architecture { filename = \"xcat/xnba.kpxe\"; } '.$lstatements; - push @netent, " if option user-class-identifier = \"xNBA\" and option client-architecture = 00:00 { #x86, xCAT Network Boot Agent\n"; - push @netent, " always-broadcast on;\n"; - push @netent, " filename = \"http://$tftp$portsuffix/tftpboot/xcat/xnba/nets/" . $net . "_" . $maskbits . "\";\n"; - push @netent, " } else if option user-class-identifier = \"xNBA\" and option client-architecture = 00:09 { #x86, xCAT Network Boot Agent\n"; - push @netent, " filename = \"http://$tftp$portsuffix/tftpboot/xcat/xnba/nets/" . $net . "_" . $maskbits . ".uefi\";\n"; - push @netent, " } else if option user-class-identifier = \"xNBA\" and option client-architecture = 00:07 { #x86-64 UEFI, xCAT Network Boot Agent\n"; - push @netent, " filename = \"http://$tftp$portsuffix/tftpboot/xcat/xnba/nets/" . $net . "_" . $maskbits . ".uefi\";\n"; - push @netent, " } else if option client-architecture = 00:00 { #x86\n"; - push @netent, " filename \"xcat/xnba.kpxe\";\n"; - push @netent, " } else if option vendor-class-identifier = \"Etherboot-5.4\" { #x86\n"; - push @netent, " filename \"xcat/xnba.kpxe\";\n"; - push @netent, - " } else if option client-architecture = 00:07 { #x86_64 uefi\n "; - push @netent, " filename \"xcat/xnba.efi\";\n"; - push @netent, - " } else if option client-architecture = 00:09 { #x86_64 uefi alternative id\n "; - push @netent, " filename \"xcat/xnba.efi\";\n"; - push @netent, - " } else if option client-architecture = 00:02 { #ia64\n "; - push @netent, " filename \"elilo.efi\";\n"; - push @netent, - " } else if option client-architecture = 00:0b { #aaarch64\n "; - push @netent, " filename \"boot/grub2/grub2.aarch64\";\n"; - push @netent, - " } else if option client-architecture = 00:1b { #riscv64 uefi\n "; - push @netent, " filename \"boot/grub2/grub2.riscv64\";\n"; - push @netent, - " } else if option client-architecture = 00:1c { #riscv64 uefi http boot\n "; - push @netent, " option vendor-class-identifier \"HTTPClient\";\n"; - push @netent, " filename \"http://$tftp$portsuffix$tftpdir/boot/grub2/grub2.riscv64\";\n"; - push @netent, - " } else if option client-architecture = 00:0e { #OPAL-v3\n "; - push @netent, " option conf-file = \"http://$tftp$portsuffix/tftpboot/pxelinux.cfg/p/" . $net . "_" . $maskbits . "\";\n"; - push @netent, - " } else if substring (option vendor-class-identifier,0,11) = \"onie_vendor\" { #for onie on cumulus switch\n"; - push @netent, " option www-server = \"http://$tftp$portsuffix/install/onie/onie-installer\";\n"; - push @netent, - " } else if substring(filename,0,1) = null { #otherwise, provide yaboot if the client isn't specific\n "; - push @netent, " filename \"/yaboot\";\n"; - push @netent, " }\n"; + push @netent, @{ xCAT::DHCP::BootPolicy->isc_client_architecture_lines( + next_server => $tftp, + portsuffix => $portsuffix, + tftpdir => $tftpdir, + net => $net, + prefix => $maskbits, + ) }; if ($range) { foreach my $singlerange (split /;/, $range) {