Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/dell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl Redfish for Bmc {
let (expected, actual) = self
.get_expected_and_actual_first_boot_option(crate::BootInterfaceRef::Mac(mac))
.await?;
if expected.is_none() || expected != actual {
if !matches!((&expected, &actual), (Some(e), Some(a)) if a.starts_with(e)) {

@williampnvidia williampnvidia Jul 12, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

starts_with is too broad. For example, an expected Partition 1 can prefix-match Partition 10. Also this same in-line expression is used 3 times. I would use a matcher function like this:

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add a unit test, something like this:

  #[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}"
          );
      }
  }

diffs.push(MachineSetupDiff {
key: "boot_first".to_string(),
expected: expected.unwrap_or_else(|| "Not found".to_string()),
Expand Down Expand Up @@ -1146,7 +1146,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.display_name.starts_with(&expected_boot_option_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 @@ -1358,7 +1358,7 @@ 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(e), Some(a)) if a.starts_with(e)))
})
}

Expand Down