Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 2 additions & 5 deletions crates/bmc-mock/src/machine_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,24 @@ pub enum MachineInfo {
Dpu(DpuMachineInfo),
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone)]
pub struct HostMachineInfo {
pub hw_type: HostHardwareType,
pub bmc_mac_address: MacAddress,
pub serial: String,
pub dpus: Vec<DpuMachineInfo>,
pub non_dpu_mac_address: Option<MacAddress>,
#[serde(default)]
pub nvos_mac_addresses: Vec<MacAddress>,
#[serde(default)]
pub switch_serial_number: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone)]
pub struct DpuMachineInfo {
pub hw_type: HostHardwareType,
pub bmc_mac_address: MacAddress,
pub host_mac_address: MacAddress,
pub oob_mac_address: MacAddress,
pub serial: String,
#[serde(flatten)]
pub settings: DpuSettings,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bmc-mock/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn default_host_mock() -> Router {
let command_channel = spawn_qemu_reboot_handler();
let callbacks = Arc::new(ChannelCallbacks::new(command_channel));
bmc_mock::machine_router(
MachineInfo::Host(HostMachineInfo::new(
&MachineInfo::Host(HostMachineInfo::new(
HostHardwareType::WiwynnGB200Nvl,
vec![DpuMachineInfo::default(), DpuMachineInfo::default()],
)),
Expand Down
4 changes: 2 additions & 2 deletions crates/bmc-mock/src/mock_machine_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl AddRoutes for Router<BmcState> {
/// Return an axum::Router that mocks various redfish calls to match
/// the provided MachineInfo.
pub fn machine_router(
machine_info: MachineInfo,
machine_info: &MachineInfo,
callbacks: Arc<dyn Callbacks>,
mat_host_id: String,
redfish_auth: bool,
Expand All @@ -86,7 +86,7 @@ pub fn machine_router(
.add_routes(crate::redfish::session_service::add_routes)
.add_routes(|routes| crate::redfish::computer_system::add_routes(routes, bmc_vendor))
.add_routes(crate::ipmi::add_routes);
let router = match &machine_info {
let router = match machine_info {
MachineInfo::Dpu(_) => {
router.add_routes(crate::redfish::oem::nvidia::bluefield::add_routes)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bmc-mock/src/redfish/expander_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ mod tests {
fn test_host_mock() -> Router {
let callbacks = Arc::new(TestCallbacks {});
crate::machine_router(
MachineInfo::Host(HostMachineInfo::new(
&MachineInfo::Host(HostMachineInfo::new(
HostHardwareType::DellPowerEdgeR750,
vec![DpuMachineInfo::default()],
)),
Expand Down
22 changes: 11 additions & 11 deletions crates/bmc-mock/src/test_support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async fn test_bmc((router, state): (axum::Router, BmcState)) -> TestBmcHandle {

pub async fn wiwynn_gb200_bmc() -> TestBmcHandle {
test_bmc(machine_router(
MachineInfo::Host(HostMachineInfo::new(
&MachineInfo::Host(HostMachineInfo::new(
HostHardwareType::WiwynnGB200Nvl,
vec![
DpuMachineInfo::new(HostHardwareType::WiwynnGB200Nvl, DpuSettings::default()),
Expand All @@ -89,7 +89,7 @@ pub async fn wiwynn_gb200_bmc() -> TestBmcHandle {

pub async fn lenovo_gb300_bmc() -> TestBmcHandle {
test_bmc(machine_router(
MachineInfo::Host(HostMachineInfo::new(
&MachineInfo::Host(HostMachineInfo::new(
HostHardwareType::LenovoGB300Nvl,
vec![DpuMachineInfo::new(
HostHardwareType::LenovoGB300Nvl,
Expand All @@ -105,7 +105,7 @@ pub async fn lenovo_gb300_bmc() -> TestBmcHandle {

pub async fn dgx_gb300_bmc() -> TestBmcHandle {
test_bmc(machine_router(
MachineInfo::Host(HostMachineInfo::new(
&MachineInfo::Host(HostMachineInfo::new(
HostHardwareType::NvidiaDgxGb300,
vec![DpuMachineInfo::new(
HostHardwareType::NvidiaDgxGb300,
Expand All @@ -121,7 +121,7 @@ pub async fn dgx_gb300_bmc() -> TestBmcHandle {

pub async fn supermicro_gb300_bmc() -> TestBmcHandle {
test_bmc(machine_router(
MachineInfo::Host(HostMachineInfo::new(
&MachineInfo::Host(HostMachineInfo::new(
HostHardwareType::SupermicroGb300Nvl,
vec![DpuMachineInfo::new(
HostHardwareType::SupermicroGb300Nvl,
Expand All @@ -137,7 +137,7 @@ pub async fn supermicro_gb300_bmc() -> TestBmcHandle {

pub async fn generic_supermicro_bmc() -> TestBmcHandle {
test_bmc(machine_router(
MachineInfo::Host(HostMachineInfo::new(
&MachineInfo::Host(HostMachineInfo::new(
HostHardwareType::GenericSupermicro,
vec![],
)),
Expand All @@ -150,7 +150,7 @@ pub async fn generic_supermicro_bmc() -> TestBmcHandle {

pub async fn liteon_powershelf_bmc() -> TestBmcHandle {
test_bmc(machine_router(
MachineInfo::Host(HostMachineInfo::new(
&MachineInfo::Host(HostMachineInfo::new(
HostHardwareType::LiteOnPowerShelf,
vec![],
)),
Expand All @@ -163,7 +163,7 @@ pub async fn liteon_powershelf_bmc() -> TestBmcHandle {

pub async fn nvidia_switch_nd5200_ld_bmc() -> TestBmcHandle {
test_bmc(machine_router(
MachineInfo::Host(HostMachineInfo::new(
&MachineInfo::Host(HostMachineInfo::new(
HostHardwareType::NvidiaSwitchNd5200Ld,
vec![],
)),
Expand All @@ -176,7 +176,7 @@ pub async fn nvidia_switch_nd5200_ld_bmc() -> TestBmcHandle {

pub async fn dell_poweredge_r750_bmc() -> TestBmcHandle {
test_bmc(machine_router(
MachineInfo::Host(HostMachineInfo::new(
&MachineInfo::Host(HostMachineInfo::new(
HostHardwareType::DellPowerEdgeR750,
vec![],
)),
Expand All @@ -189,7 +189,7 @@ pub async fn dell_poweredge_r750_bmc() -> TestBmcHandle {

pub async fn dell_poweredge_r750_bluefield3_bmc(settings: DpuSettings) -> TestBmcHandle {
test_bmc(machine_router(
MachineInfo::Dpu(DpuMachineInfo::new(
&MachineInfo::Dpu(DpuMachineInfo::new(
HostHardwareType::DellPowerEdgeR750,
settings,
)),
Expand All @@ -202,7 +202,7 @@ pub async fn dell_poweredge_r750_bluefield3_bmc(settings: DpuSettings) -> TestBm

pub async fn generic_ami_bmc() -> TestBmcHandle {
test_bmc(machine_router(
MachineInfo::Host(HostMachineInfo::new(HostHardwareType::GenericAmi, vec![])),
&MachineInfo::Host(HostMachineInfo::new(HostHardwareType::GenericAmi, vec![])),
Arc::new(NoopCallbacks),
"test-host-id".to_string(),
false,
Expand All @@ -224,7 +224,7 @@ mod test {
async fn transport_supports_expand_query_through_mock_expander() {
let client = AxumRouterHttpClient::new(
machine_router(
MachineInfo::Host(HostMachineInfo::new(
&MachineInfo::Host(HostMachineInfo::new(
HostHardwareType::DellPowerEdgeR750,
vec![],
)),
Expand Down
16 changes: 8 additions & 8 deletions crates/machine-a-tron/src/bmc_mock_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::mock_ssh_server::{MockSshServerHandle, PromptBehavior};
/// either a DPU or a Host. It will rewrite certain responses to customize them for the machines
/// machine-a-tron is mocking.
pub struct BmcMockWrapper {
machine_info: MachineInfo,
ssh_prompt_behavior: PromptBehavior,
app_context: Arc<MachineATronContext>,
bmc_mock_router: Router,
bmc_mock_state: BmcState,
Expand All @@ -45,17 +45,20 @@ pub struct BmcMockWrapper {

impl BmcMockWrapper {
pub fn new(
machine_info: MachineInfo,
machine_info: &MachineInfo,
app_context: Arc<MachineATronContext>,
callbacks: Arc<dyn Callbacks>,
hostname: Arc<dyn HostnameQuerying>,
host_id: Uuid,
) -> Self {
let (bmc_mock_router, bmc_mock_state) =
bmc_mock::machine_router(machine_info.clone(), callbacks, host_id.to_string(), true);
bmc_mock::machine_router(machine_info, callbacks, host_id.to_string(), true);

BmcMockWrapper {
machine_info,
ssh_prompt_behavior: match machine_info {
MachineInfo::Host(_) => PromptBehavior::Dell,
MachineInfo::Dpu(_) => PromptBehavior::Dpu,
},
app_context,
bmc_mock_router,
bmc_mock_state,
Expand Down Expand Up @@ -120,10 +123,7 @@ impl BmcMockWrapper {
user: "root".to_string(),
password: "password".to_string(),
}),
match self.machine_info {
MachineInfo::Host(_) => PromptBehavior::Dell,
MachineInfo::Dpu(_) => PromptBehavior::Dpu,
},
self.ssh_prompt_behavior,
)
.await
.map_err(|error| {
Expand Down
2 changes: 1 addition & 1 deletion crates/machine-a-tron/src/machine_state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ impl MachineStateMachine {
ip_address: Ipv4Addr,
) -> Result<(Option<Arc<BmcMockWrapperHandle>>, BmcState), MachineStateError> {
let mut bmc_mock = BmcMockWrapper::new(
self.machine_info.clone(),
&self.machine_info,
self.app_context.clone(),
Arc::new(LiveStateCallbacks::new(
self.live_state.clone(),
Expand Down
Loading