Skip to content

wip #7966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

wip #7966

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
64 changes: 36 additions & 28 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2484,13 +2484,6 @@ pub struct SwitchPortSettingsView {
/// Layer 2 link settings.
pub links: Vec<SwitchPortLinkConfig>,

/// Link-layer discovery protocol (LLDP) settings.
pub link_lldp: Vec<LldpLinkConfig>,

/// TX equalization settings. These are optional, and most links will not
/// need them.
pub tx_eq: Vec<Option<TxEqConfig>>,

/// Layer 3 interface settings.
pub interfaces: Vec<SwitchInterfaceConfig>,

Expand All @@ -2504,7 +2497,7 @@ pub struct SwitchPortSettingsView {
pub bgp_peers: Vec<BgpPeer>,

/// Layer 3 IP address settings.
pub addresses: Vec<SwitchPortAddressConfig>,
pub addresses: Vec<SwitchPortAddressView>,
}

/// This structure maps a port settings object to a port settings groups. Port
Expand Down Expand Up @@ -2629,13 +2622,6 @@ pub struct SwitchPortLinkConfig {
/// The port settings this link configuration belongs to.
pub port_settings_id: Uuid,

/// The link-layer discovery protocol service configuration id for this
/// link.
pub lldp_link_config_id: Option<Uuid>,

/// The tx_eq configuration id for this link.
pub tx_eq_config_id: Option<Uuid>,

/// The name of this link.
pub link_name: String,

Expand All @@ -2652,6 +2638,13 @@ pub struct SwitchPortLinkConfig {

/// Whether or not the link has autonegotiation enabled.
pub autoneg: bool,

/// The link-layer discovery protocol service configuration for this
/// link.
pub lldp_link_config: Option<LldpLinkConfig>,

/// The tx_eq configuration for this link.
pub tx_eq_config: Option<TxEqConfig>,
}

/// A link layer discovery protocol (LLDP) service configuration.
Expand Down Expand Up @@ -2742,18 +2735,6 @@ pub struct TxEqConfig {
pub post1: Option<i32>,
}

impl From<crate::api::internal::shared::TxEqConfig> for TxEqConfig {
fn from(x: crate::api::internal::shared::TxEqConfig) -> TxEqConfig {
TxEqConfig {
pre1: x.pre1,
pre2: x.pre2,
main: x.main,
post2: x.post2,
post1: x.post1,
}
}
}

/// Describes the kind of an switch interface.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
#[serde(rename_all = "snake_case")]
Expand Down Expand Up @@ -2821,7 +2802,7 @@ pub struct SwitchPortRouteConfig {
pub dst: oxnet::IpNet,

/// The route's gateway address.
pub gw: oxnet::IpNet,
pub gw: IpAddr,

/// The VLAN identifier for the route. Use this if the gateway is reachable
/// over an 802.1Q tagged L2 segment.
Expand Down Expand Up @@ -2977,6 +2958,33 @@ pub struct SwitchPortAddressConfig {
pub interface_name: String,
}

/// An IP address configuration for a port settings object.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct SwitchPortAddressView {
/// The port settings object this address configuration belongs to.
pub port_settings_id: Uuid,

/// The id of the address lot this address is drawn from.
pub address_lot_id: Uuid,

/// The name of the address lot this address is drawn from.
pub address_lot_name: Name,

/// The id of the address lot block this address is drawn from.
pub address_lot_block_id: Uuid,

/// The IP address and prefix.
pub address: oxnet::IpNet,

/// An optional VLAN ID
pub vlan_id: Option<u16>,

/// The interface name this address belongs to.
// TODO: https://github.com/oxidecomputer/omicron/issues/3050
// Use `Name` instead of `String` for `interface_name` type
pub interface_name: String,
}

/// The current state of a BGP peer.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
#[serde(rename_all = "snake_case")]
Expand Down
1 change: 1 addition & 0 deletions nexus/db-model/src/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

17 changes: 1 addition & 16 deletions nexus/db-model/src/switch_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,21 +407,6 @@ impl SwitchPortLinkConfig {
}
}

impl Into<external::SwitchPortLinkConfig> for SwitchPortLinkConfig {
fn into(self) -> external::SwitchPortLinkConfig {
external::SwitchPortLinkConfig {
port_settings_id: self.port_settings_id,
lldp_link_config_id: self.lldp_link_config_id,
tx_eq_config_id: self.tx_eq_config_id,
link_name: self.link_name.clone(),
mtu: self.mtu.into(),
fec: self.fec.map(|fec| fec.into()),
speed: self.speed.into(),
autoneg: self.autoneg,
}
}
}

#[derive(
Queryable,
Insertable,
Expand Down Expand Up @@ -625,7 +610,7 @@ impl Into<external::SwitchPortRouteConfig> for SwitchPortRouteConfig {
port_settings_id: self.port_settings_id,
interface_name: self.interface_name.clone(),
dst: self.dst.into(),
gw: self.gw.into(),
gw: self.gw.ip(),
vlan_id: self.vid.map(Into::into),
rib_priority: self.rib_priority.map(Into::into),
}
Expand Down
Loading
Loading