Skip to content

Commit 9e56717

Browse files
authored
[nexus] Remove duplicated networking types from omicron-common / external API (#10344)
This fixes #10293. 2/3 of these were straightforward; removing the duplicate `SwitchPortGeometry2` and `TxEqConfig2` types required removing those from `common` and moving any other types still in `common` that used them out into `nexus-types-versions`; those are done in the first two commits on this PR. Removing the duplicate `SwitchInterfaceKind2` was more involved because the two types didn't have the same structure despite having the same name. The change I made on this PR is to drop the `vlan_interfaces` field entirely, change the `kind` of `SwitchInterfaceConfig` to include the vlan ID, then do the reassembly ourselves when we load this object from the db.
1 parent 60352ac commit 9e56717

21 files changed

Lines changed: 637 additions & 532 deletions

File tree

common/src/api/external/mod.rs

Lines changed: 0 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,159 +2843,6 @@ pub struct AddressLotBlock {
28432843
pub last_address: IpAddr,
28442844
}
28452845

2846-
/// A switch port settings identity whose id may be used to view additional
2847-
/// details.
2848-
#[derive(
2849-
ObjectIdentity, Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq,
2850-
)]
2851-
pub struct SwitchPortSettingsIdentity {
2852-
#[serde(flatten)]
2853-
pub identity: IdentityMetadata,
2854-
}
2855-
2856-
/// This structure maps a port settings object to a port settings groups. Port
2857-
/// settings objects may inherit settings from groups. This mapping defines the
2858-
/// relationship between settings objects and the groups they reference.
2859-
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
2860-
pub struct SwitchPortSettingsGroups {
2861-
/// The id of a port settings object referencing a port settings group.
2862-
pub port_settings_id: Uuid,
2863-
2864-
/// The id of a port settings group being referenced by a port settings
2865-
/// object.
2866-
pub port_settings_group_id: Uuid,
2867-
}
2868-
2869-
/// A port settings group is a named object that references a port settings
2870-
/// object.
2871-
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
2872-
pub struct SwitchPortSettingsGroup {
2873-
#[serde(flatten)]
2874-
pub identity: IdentityMetadata,
2875-
2876-
/// The port settings that comprise this group.
2877-
pub port_settings_id: Uuid,
2878-
}
2879-
2880-
/// The link geometry associated with a switch port.
2881-
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
2882-
#[serde(rename_all = "lowercase")]
2883-
pub enum SwitchPortGeometry {
2884-
/// The port contains a single QSFP28 link with four lanes.
2885-
Qsfp28x1,
2886-
2887-
/// The port contains two QSFP28 links each with two lanes.
2888-
Qsfp28x2,
2889-
2890-
/// The port contains four SFP28 links each with one lane.
2891-
Sfp28x4,
2892-
}
2893-
2894-
/// A physical port configuration for a port settings object.
2895-
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
2896-
pub struct SwitchPortConfig {
2897-
/// The id of the port settings object this configuration belongs to.
2898-
pub port_settings_id: Uuid,
2899-
2900-
/// The physical link geometry of the port.
2901-
pub geometry: SwitchPortGeometry,
2902-
}
2903-
2904-
/// The speed of a link.
2905-
#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
2906-
#[serde(rename_all = "snake_case")]
2907-
pub enum LinkSpeed {
2908-
/// Zero gigabits per second.
2909-
Speed0G,
2910-
/// 1 gigabit per second.
2911-
Speed1G,
2912-
/// 10 gigabits per second.
2913-
Speed10G,
2914-
/// 25 gigabits per second.
2915-
Speed25G,
2916-
/// 40 gigabits per second.
2917-
Speed40G,
2918-
/// 50 gigabits per second.
2919-
Speed50G,
2920-
/// 100 gigabits per second.
2921-
Speed100G,
2922-
/// 200 gigabits per second.
2923-
Speed200G,
2924-
/// 400 gigabits per second.
2925-
Speed400G,
2926-
}
2927-
2928-
/// The forward error correction mode of a link.
2929-
#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
2930-
#[serde(rename_all = "snake_case")]
2931-
pub enum LinkFec {
2932-
/// Firecode forward error correction.
2933-
Firecode,
2934-
/// No forward error correction.
2935-
None,
2936-
/// Reed-Solomon forward error correction.
2937-
Rs,
2938-
}
2939-
2940-
/// A link configuration for a port settings object.
2941-
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
2942-
pub struct SwitchPortLinkConfig {
2943-
/// The port settings this link configuration belongs to.
2944-
pub port_settings_id: Uuid,
2945-
2946-
/// The name of this link.
2947-
pub link_name: Name,
2948-
2949-
/// The maximum transmission unit for this link.
2950-
pub mtu: u16,
2951-
2952-
/// The requested forward-error correction method. If this is not
2953-
/// specified, the standard FEC for the underlying media will be applied
2954-
/// if it can be determined.
2955-
pub fec: Option<LinkFec>,
2956-
2957-
/// The configured speed of the link.
2958-
pub speed: LinkSpeed,
2959-
2960-
/// Whether or not the link has autonegotiation enabled.
2961-
pub autoneg: bool,
2962-
2963-
/// The link-layer discovery protocol service configuration for this
2964-
/// link.
2965-
pub lldp_link_config: Option<LldpLinkConfig>,
2966-
2967-
/// The tx_eq configuration for this link.
2968-
pub tx_eq_config: Option<TxEqConfig>,
2969-
}
2970-
2971-
/// A link layer discovery protocol (LLDP) service configuration.
2972-
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
2973-
pub struct LldpLinkConfig {
2974-
/// The id of this LLDP service instance.
2975-
pub id: Uuid,
2976-
2977-
/// Whether or not the LLDP service is enabled.
2978-
pub enabled: bool,
2979-
2980-
/// The LLDP link name TLV.
2981-
pub link_name: Option<String>,
2982-
2983-
/// The LLDP link description TLV.
2984-
pub link_description: Option<String>,
2985-
2986-
/// The LLDP chassis identifier TLV.
2987-
pub chassis_id: Option<String>,
2988-
2989-
/// The LLDP system name TLV.
2990-
pub system_name: Option<String>,
2991-
2992-
/// The LLDP system description TLV.
2993-
pub system_description: Option<String>,
2994-
2995-
/// The LLDP management IP TLV.
2996-
pub management_ip: Option<IpAddr>,
2997-
}
2998-
29992846
/// Information about LLDP advertisements from other network entities directly
30002847
/// connected to a switch port. This structure contains both metadata about
30012848
/// when and where the neighbor was seen, as well as the specific information
@@ -3040,72 +2887,6 @@ impl SimpleIdentity for LldpNeighbor {
30402887
}
30412888
}
30422889

3043-
/// Per-port tx-eq overrides. This can be used to fine-tune the transceiver
3044-
/// equalization settings to improve signal integrity.
3045-
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
3046-
pub struct TxEqConfig {
3047-
/// Pre-cursor tap1
3048-
pub pre1: Option<i32>,
3049-
/// Pre-cursor tap2
3050-
pub pre2: Option<i32>,
3051-
/// Main tap
3052-
pub main: Option<i32>,
3053-
/// Post-cursor tap2
3054-
pub post2: Option<i32>,
3055-
/// Post-cursor tap1
3056-
pub post1: Option<i32>,
3057-
}
3058-
3059-
/// Describes the kind of an switch interface.
3060-
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
3061-
#[serde(rename_all = "snake_case")]
3062-
pub enum SwitchInterfaceKind {
3063-
/// Primary interfaces are associated with physical links. There is exactly
3064-
/// one primary interface per physical link.
3065-
Primary,
3066-
3067-
/// VLAN interfaces allow physical interfaces to be multiplexed onto
3068-
/// multiple logical links, each distinguished by a 12-bit 802.1Q Ethernet
3069-
/// tag.
3070-
Vlan,
3071-
3072-
/// Loopback interfaces are anchors for IP addresses that are not specific
3073-
/// to any particular port.
3074-
Loopback,
3075-
}
3076-
3077-
/// A switch port interface configuration for a port settings object.
3078-
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
3079-
pub struct SwitchInterfaceConfig {
3080-
/// The port settings object this switch interface configuration belongs to.
3081-
pub port_settings_id: Uuid,
3082-
3083-
/// A unique identifier for this switch interface.
3084-
pub id: Uuid,
3085-
3086-
/// The name of this switch interface.
3087-
pub interface_name: Name,
3088-
3089-
/// Whether or not IPv6 is enabled on this interface.
3090-
pub v6_enabled: bool,
3091-
3092-
/// The switch interface kind.
3093-
pub kind: SwitchInterfaceKind,
3094-
}
3095-
3096-
/// A switch port VLAN interface configuration for a port settings object.
3097-
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
3098-
pub struct SwitchVlanInterfaceConfig {
3099-
/// The switch interface configuration this VLAN interface configuration
3100-
/// belongs to.
3101-
pub interface_config_id: Uuid,
3102-
3103-
/// The virtual network id for this interface that is used for producing and
3104-
/// consuming 802.1Q Ethernet tags. This field has a maximum value of 4095
3105-
/// as 802.1Q tags are twelve bits.
3106-
pub vlan_id: u16,
3107-
}
3108-
31092890
/// A route configuration for a port settings object.
31102891
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
31112892
pub struct SwitchPortRouteConfig {

nexus/db-model/src/switch_interface.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use ipnetwork::IpNetwork;
1010
use nexus_db_schema::schema::{loopback_address, switch_vlan_interface_config};
1111
use nexus_types::external_api::networking as networking_types;
1212
use nexus_types::identity::Asset;
13-
use omicron_common::api::external;
1413
use omicron_uuid_kinds::LoopbackAddressKind;
1514
use omicron_uuid_kinds::TypedUuid;
1615
use serde::{Deserialize, Serialize};
@@ -53,20 +52,6 @@ impl From<networking_types::SwitchInterfaceKind> for DbSwitchInterfaceKind {
5352
}
5453
}
5554

56-
impl Into<external::SwitchInterfaceKind> for DbSwitchInterfaceKind {
57-
fn into(self) -> external::SwitchInterfaceKind {
58-
match self {
59-
DbSwitchInterfaceKind::Primary => {
60-
external::SwitchInterfaceKind::Primary
61-
}
62-
DbSwitchInterfaceKind::Vlan => external::SwitchInterfaceKind::Vlan,
63-
DbSwitchInterfaceKind::Loopback => {
64-
external::SwitchInterfaceKind::Loopback
65-
}
66-
}
67-
}
68-
}
69-
7055
#[derive(
7156
Queryable,
7257
Insertable,
@@ -89,9 +74,11 @@ impl SwitchVlanInterfaceConfig {
8974
}
9075
}
9176

92-
impl Into<external::SwitchVlanInterfaceConfig> for SwitchVlanInterfaceConfig {
93-
fn into(self) -> external::SwitchVlanInterfaceConfig {
94-
external::SwitchVlanInterfaceConfig {
77+
impl Into<networking_types::SwitchVlanInterfaceConfig>
78+
for SwitchVlanInterfaceConfig
79+
{
80+
fn into(self) -> networking_types::SwitchVlanInterfaceConfig {
81+
networking_types::SwitchVlanInterfaceConfig {
9582
interface_config_id: self.interface_config_id,
9683
vlan_id: self.vid.into(),
9784
}

0 commit comments

Comments
 (0)