Skip to content

Commit

Permalink
fix 4470
Browse files Browse the repository at this point in the history
  • Loading branch information
rcgoodfellow committed Nov 28, 2023
1 parent b9d8b8f commit 29685db
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 10 deletions.
4 changes: 2 additions & 2 deletions common/src/api/internal/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pub enum ExternalPortDiscovery {
}

/// Switchport Speed options
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum PortSpeed {
#[serde(alias = "0G")]
Expand All @@ -284,7 +284,7 @@ pub enum PortSpeed {
}

/// Switchport FEC options
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum PortFec {
Firecode,
Expand Down
20 changes: 20 additions & 0 deletions nexus/src/app/rack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use nexus_db_queries::db::lookup::LookupPath;
use nexus_types::external_api::params::Address;
use nexus_types::external_api::params::AddressConfig;
use nexus_types::external_api::params::AddressLotBlockCreate;
use nexus_types::external_api::params::LinkConfig;
use nexus_types::external_api::params::LldpServiceConfig;
use nexus_types::external_api::params::RouteConfig;
use nexus_types::external_api::params::SwitchPortConfig;
use nexus_types::external_api::params::{
Expand Down Expand Up @@ -503,6 +505,24 @@ impl super::Nexus {
.routes
.insert("phy0".to_string(), RouteConfig { routes });

let link = LinkConfig {
mtu: 1500, //TODO as parameter
lldp: LldpServiceConfig {
enabled: false,
lldp_config: None,
},
fec: uplink_config.uplink_port_fec.into(),
speed: uplink_config.uplink_port_speed.into(),
};

port_settings_params.links.insert("phy".to_string(), link);

/*
port_settings_params
.links
.insert("phy0".to_string(), LinkConfig { links });
*/

match self
.db_datastore
.switch_port_settings_create(
Expand Down
46 changes: 46 additions & 0 deletions nexus/types/src/external_api/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,18 @@ pub enum LinkFec {
Rs,
}

impl From<omicron_common::api::internal::shared::PortFec> for LinkFec {
fn from(x: omicron_common::api::internal::shared::PortFec) -> LinkFec {
match x {
omicron_common::api::internal::shared::PortFec::Firecode => {
Self::Firecode
}
omicron_common::api::internal::shared::PortFec::None => Self::None,
omicron_common::api::internal::shared::PortFec::Rs => Self::Rs,
}
}
}

/// The speed of a link.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
Expand All @@ -1361,6 +1373,40 @@ pub enum LinkSpeed {
Speed400G,
}

impl From<omicron_common::api::internal::shared::PortSpeed> for LinkSpeed {
fn from(x: omicron_common::api::internal::shared::PortSpeed) -> Self {
match x {
omicron_common::api::internal::shared::PortSpeed::Speed0G => {
Self::Speed0G
}
omicron_common::api::internal::shared::PortSpeed::Speed1G => {
Self::Speed1G
}
omicron_common::api::internal::shared::PortSpeed::Speed10G => {
Self::Speed10G
}
omicron_common::api::internal::shared::PortSpeed::Speed25G => {
Self::Speed25G
}
omicron_common::api::internal::shared::PortSpeed::Speed40G => {
Self::Speed40G
}
omicron_common::api::internal::shared::PortSpeed::Speed50G => {
Self::Speed50G
}
omicron_common::api::internal::shared::PortSpeed::Speed100G => {
Self::Speed100G
}
omicron_common::api::internal::shared::PortSpeed::Speed200G => {
Self::Speed200G
}
omicron_common::api::internal::shared::PortSpeed::Speed400G => {
Self::Speed400G
}
}
}
}

/// Switch link configuration.
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct LinkConfig {
Expand Down
10 changes: 2 additions & 8 deletions sled-agent/src/rack_setup/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,8 @@ impl ServiceInner {
.collect(),
addresses: config.addresses.clone(),
switch: config.switch.into(),
uplink_port_speed: config
.uplink_port_speed
.clone()
.into(),
uplink_port_fec: config
.uplink_port_fec
.clone()
.into(),
uplink_port_speed: config.uplink_port_speed.into(),
uplink_port_fec: config.uplink_port_fec.into(),
bgp_peers: config
.bgp_peers
.iter()
Expand Down

0 comments on commit 29685db

Please sign in to comment.