-
Notifications
You must be signed in to change notification settings - Fork 43
Improve usability of switch port settings #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
base: main
Are you sure you want to change the base?
Changes from all commits
8290e75
8af5ce9
334ba30
0e59683
174667d
9b54b3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2465,7 +2465,7 @@ pub struct SwitchPort { | |
#[derive( | ||
ObjectIdentity, Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq, | ||
)] | ||
pub struct SwitchPortSettings { | ||
pub struct SwitchPortSettingsIdentity { | ||
#[serde(flatten)] | ||
pub identity: IdentityMetadata, | ||
} | ||
|
@@ -2474,9 +2474,9 @@ pub struct SwitchPortSettings { | |
/// convenience data structure for getting a complete view of a particular | ||
/// port's settings. | ||
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)] | ||
pub struct SwitchPortSettingsView { | ||
/// The primary switch port settings handle. | ||
pub settings: SwitchPortSettings, | ||
pub struct SwitchPortSettings { | ||
#[serde(flatten)] | ||
pub identity: IdentityMetadata, | ||
|
||
/// Switch port settings included from other switch port settings groups. | ||
pub groups: Vec<SwitchPortSettingsGroups>, | ||
|
@@ -2487,13 +2487,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>, | ||
|
||
|
@@ -2507,7 +2500,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 | ||
|
@@ -2632,13 +2625,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, | ||
|
||
|
@@ -2655,6 +2641,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. | ||
|
@@ -2745,18 +2738,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")] | ||
|
@@ -2824,7 +2805,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. | ||
|
@@ -2980,6 +2961,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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see this matches up with
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Giving this a try now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the existing Would There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. That's a naming conundrum. I don't think we distinguish the full view from the list item anywhere else, so we are inventing the convention here. Yet another option would be to return the full thing for the list as well, but you weren't kidding about it being a lot, so we probably shouldn't do that. @ahl what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated these type names to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, I think it looks good. |
||
/// 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")] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mistakenly added file? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why can this go from
IpNet
toIpAddr
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was likely never supposed to be an
IpNet
. The user provides anIpAddr
when they create the configuration:omicron/nexus/types/src/external_api/params.rs
Line 1900 in abc98f2
The DB stores singular ipv4 addresses as a full CIDR with /32, so that's probably how we ended up returning an
IpNet
instead of anIpAddr
like what the user supplied.