Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 50 additions & 4 deletions src/dell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ fn nw_dev_func_matches(
}
}

fn boot_option_name_matches(expected: &str, actual: &str) -> bool {
actual == expected
|| actual
.strip_prefix(expected)
.is_some_and(|suffix| suffix.starts_with(" - "))
}

pub struct Bmc {
s: RedfishStandard,
}
Expand Down Expand Up @@ -405,7 +412,11 @@ impl Redfish for Bmc {
let (expected, actual) = self
.get_expected_and_actual_first_boot_option(boot_interface)
.await?;
if expected.is_none() || expected != actual {
if !matches!(
(&expected, &actual),
(Some(expected), Some(actual))
if boot_option_name_matches(expected, actual)
) {
diffs.push(MachineSetupDiff {
key: "boot_first".to_string(),
expected: expected.unwrap_or_else(|| "Not found".to_string()),
Expand Down Expand Up @@ -1122,7 +1133,7 @@ impl Redfish for Bmc {
.await?;
let boot_order = self.get_boot_order().await?;
for (idx, boot_option) in boot_order.iter().enumerate() {
if boot_option.display_name == expected_boot_option_name {
if boot_option_name_matches(&expected_boot_option_name, &boot_option.display_name) {
if idx == 0 {
// Dells will not generate a bios config job below if the boot orders already configured correctly
tracing::info!(
Expand Down Expand Up @@ -1328,7 +1339,10 @@ impl Redfish for Bmc {
let (expected, actual) = self
.get_expected_and_actual_first_boot_option(boot_interface)
.await?;
Ok(expected.is_some() && expected == actual)
Ok(matches!(
(&expected, &actual),
(Some(expected), Some(actual)) if boot_option_name_matches(expected, actual)
))
})
}

Expand Down Expand Up @@ -2756,7 +2770,7 @@ impl std::fmt::Display for XmlPcdata<'_> {

#[cfg(test)]
mod tests {
use super::{nw_dev_func_matches, XmlPcdata};
use super::{boot_option_name_matches, nw_dev_func_matches, XmlPcdata};
use crate::model::network_device_function::{Ethernet, NetworkDeviceFunction};
use crate::BootInterfaceRef;
use std::collections::HashMap;
Expand Down Expand Up @@ -2818,6 +2832,38 @@ mod tests {
assert!(nw_dev_func_matches(&populated, BootInterfaceRef::Mac(mac)));
}

#[test]
fn boot_option_name_matches_legacy_and_extended_names() {
let expected = "HTTP Device 1: NIC in Slot 4 Port 1 Partition 1";
let cases = [
(expected, true),
(
"HTTP Device 1: NIC in Slot 4 Port 1 Partition 1 - Nvidia Network Adapter - 00:11:22:33:44:55 - IPv4",
true,
),
(
"HTTP Device 1: NIC in Slot 4 Port 1 Partition 10 - Nvidia Network Adapter - 00:11:22:33:44:55 - IPv4",
false,
),
(
"HTTP Device 1: NIC in Slot 4 Port 2 Partition 1 - Nvidia Network Adapter - 00:11:22:33:44:55 - IPv4",
false,
),
(
"HTTP Device 1: NIC in Slot 4 Port 1 Partition 1 unexpected suffix",
false,
),
];

for (actual, should_match) in cases {
assert_eq!(
boot_option_name_matches(expected, actual),
should_match,
"unexpected match result for {actual}"
);
}
}

// Mirrors the attribute-merge logic in machine_setup_oem so we can test it
// without a live HTTP connection.
fn build_oem_attributes(
Expand Down
Loading