@@ -20,6 +20,9 @@ use std::collections::HashMap;
2020use serde:: Deserialize ;
2121use sha2:: { Digest , Sha256 } ;
2222
23+ const STATIC_IPXE_MENU_TEMPLATE_ID : & str = "c816a939-0993-5ebf-82dd-5227ad215703" ;
24+ const STATIC_IPXE_MENU_TEMPLATE : & str = include_str ! ( "../../../pxe/ipxe/local/embed.ipxe" ) ;
25+
2326/// iPXE OS definition with template-based rendering support
2427#[ derive( Debug , Clone ) ]
2528pub struct IpxeScript {
@@ -64,7 +67,7 @@ pub struct IpxeTemplateArtifact {
6467#[ derive( Debug , Clone , Copy , PartialEq , Eq , Default , Deserialize ) ]
6568#[ serde( rename_all = "lowercase" ) ]
6669pub enum IpxeTemplateScope {
67- /// Carbide-core usage only.
70+ /// NICo Core usage only.
6871 #[ default]
6972 Internal ,
7073 /// Usable by tenant.
@@ -135,7 +138,7 @@ pub trait IpxeScriptRenderer {
135138 /// Render generates the final iPXE script from an IpxeScript object.
136139 /// Artifact URLs are replaced by local cached URLs when available (cached_url).
137140 /// `reserved_params` must contain exactly the reserved parameters defined
138- /// in the template (provided by carbide-core ).
141+ /// in the template (provided by NICo Core ).
139142 fn render (
140143 & self ,
141144 ipxeos : & IpxeScript ,
@@ -190,7 +193,13 @@ impl DefaultIpxeScriptRenderer {
190193 let templates = template_collection
191194 . templates
192195 . into_iter ( )
193- . map ( |t| ( t. name . clone ( ) , t) )
196+ . map ( |mut t| {
197+ if t. id == STATIC_IPXE_MENU_TEMPLATE_ID {
198+ t. template = STATIC_IPXE_MENU_TEMPLATE . to_string ( ) ;
199+ }
200+
201+ ( t. name . clone ( ) , t)
202+ } )
194203 . collect ( ) ;
195204
196205 Self { templates }
@@ -1049,6 +1058,47 @@ mod tests {
10491058 assert ! ( templates. len( ) >= 11 ) ;
10501059 }
10511060
1061+ #[ test]
1062+ fn test_static_ipxe_menu_uses_nico_branding ( ) {
1063+ const BRANDING_H : & str = include_str ! ( "../../../pxe/ipxe/local/branding.h" ) ;
1064+
1065+ let renderer = DefaultIpxeScriptRenderer :: new ( ) ;
1066+ let menu_template = renderer
1067+ . get_template_by_id ( STATIC_IPXE_MENU_TEMPLATE_ID )
1068+ . expect ( "static iPXE menu template should exist" ) ;
1069+
1070+ assert_eq ! ( menu_template. template, STATIC_IPXE_MENU_TEMPLATE ) ;
1071+
1072+ for ( name, contents) in [
1073+ ( "embedded iPXE script" , STATIC_IPXE_MENU_TEMPLATE ) ,
1074+ ( "iPXE branding header" , BRANDING_H ) ,
1075+ (
1076+ "renderer static menu description" ,
1077+ menu_template. description . as_str ( ) ,
1078+ ) ,
1079+ ] {
1080+ assert ! ( contents. contains( "NICo" ) , "{name} should mention NICo" ) ;
1081+ }
1082+
1083+ for ( name, contents) in [
1084+ ( "embedded iPXE script" , STATIC_IPXE_MENU_TEMPLATE ) ,
1085+ ( "iPXE branding header" , BRANDING_H ) ,
1086+ (
1087+ "renderer static menu description" ,
1088+ menu_template. description . as_str ( ) ,
1089+ ) ,
1090+ ] {
1091+ assert ! (
1092+ !contents. contains( "Carbide" ) && !contents. contains( "carbide" ) ,
1093+ "{name} should not mention Carbide"
1094+ ) ;
1095+ assert ! (
1096+ !contents. contains( "Forge" ) && !contents. contains( "forge" ) ,
1097+ "{name} should not mention Forge"
1098+ ) ;
1099+ }
1100+ }
1101+
10521102 #[ test]
10531103 fn test_get_template_by_name ( ) {
10541104 let renderer = DefaultIpxeScriptRenderer :: new ( ) ;
0 commit comments