forked from NationTech/harmony
feat: Harmony now sets dhcp next boot server for PXE on okd setup
This commit is contained in:
@@ -54,7 +54,9 @@ impl<'a> DhcpConfig<'a> {
|
||||
|
||||
pub fn remove_static_mapping(&mut self, mac: &str) {
|
||||
let lan_dhcpd = self.get_lan_dhcpd();
|
||||
lan_dhcpd.staticmaps.retain(|static_entry| static_entry.mac != mac);
|
||||
lan_dhcpd
|
||||
.staticmaps
|
||||
.retain(|static_entry| static_entry.mac != mac);
|
||||
}
|
||||
|
||||
fn get_lan_dhcpd(&mut self) -> &mut opnsense_config_xml::DhcpInterface {
|
||||
@@ -77,7 +79,6 @@ impl<'a> DhcpConfig<'a> {
|
||||
let mac = mac.to_string();
|
||||
let hostname = hostname.to_string();
|
||||
let lan_dhcpd = self.get_lan_dhcpd();
|
||||
let range = &lan_dhcpd.range;
|
||||
let existing_mappings: &mut Vec<StaticMap> = &mut lan_dhcpd.staticmaps;
|
||||
|
||||
if !Self::is_valid_mac(&mac) {
|
||||
@@ -87,7 +88,7 @@ impl<'a> DhcpConfig<'a> {
|
||||
// TODO verify if address is in subnet range
|
||||
// This check here does not do what we want to do, as we want to assign static leases
|
||||
// outside of the dynamic DHCP pool
|
||||
//
|
||||
// let range = &lan_dhcpd.range;
|
||||
// if !Self::is_ip_in_range(&ipaddr, range) {
|
||||
// return Err(DhcpError::IpAddressOutOfRange(ipaddr.to_string()));
|
||||
// }
|
||||
@@ -177,6 +178,14 @@ impl<'a> DhcpConfig<'a> {
|
||||
|
||||
Ok(static_maps)
|
||||
}
|
||||
pub fn enable_netboot(&mut self) {
|
||||
self.get_lan_dhcpd().netboot = Some(1);
|
||||
}
|
||||
|
||||
pub fn set_next_server(&mut self, ip: Ipv4Addr) {
|
||||
self.enable_netboot();
|
||||
self.get_lan_dhcpd().nextserver = Some(ip.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user