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
105 changes: 0 additions & 105 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2894,39 +2894,6 @@ pub struct SwitchPortSettingsIdentity {
pub identity: IdentityMetadata,
}

/// This structure contains all port settings information in one place. It's a
/// convenience data structure for getting a complete view of a particular
/// port's settings.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct SwitchPortSettings {
#[serde(flatten)]
pub identity: IdentityMetadata,

/// Switch port settings included from other switch port settings groups.
pub groups: Vec<SwitchPortSettingsGroups>,

/// Layer 1 physical port settings.
pub port: SwitchPortConfig,

/// Layer 2 link settings.
pub links: Vec<SwitchPortLinkConfig>,

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

/// Vlan interface settings.
pub vlan_interfaces: Vec<SwitchVlanInterfaceConfig>,

/// IP route settings.
pub routes: Vec<SwitchPortRouteConfig>,

/// BGP peer settings.
pub bgp_peers: Vec<BgpPeer>,

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

/// This structure maps a port settings object to a port settings groups. Port
/// settings objects may inherit settings from groups. This mapping defines the
/// relationship between settings objects and the groups they reference.
Expand Down Expand Up @@ -3236,78 +3203,6 @@ pub struct SwitchPortRouteConfig {
pub rib_priority: Option<u8>,
}

/// A BGP peer configuration for an interface. Includes the set of announcements
/// that will be advertised to the peer identified by `addr`. The `bgp_config`
/// parameter is a reference to global BGP parameters. The `interface_name`
/// indicates what interface the peer should be contacted on.
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
pub struct BgpPeer {
/// The global BGP configuration used for establishing a session with this
/// peer.
pub bgp_config: NameOrId,

/// The name of interface to peer on. This is relative to the port
/// configuration this BGP peer configuration is a part of. For example this
/// value could be phy0 to refer to a primary physical interface. Or it
/// could be vlan47 to refer to a VLAN interface.
pub interface_name: Name,

/// The address of the host to peer with. If not provided, this is an
/// unnumbered BGP session that will be established over the interface
/// specified by `interface_name`.
pub addr: Option<IpAddr>,

/// How long to hold peer connections between keepalives (seconds).
pub hold_time: u32,

/// How long to hold a peer in idle before attempting a new session
/// (seconds).
pub idle_hold_time: u32,

/// How long to delay sending an open request after establishing a TCP
/// session (seconds).
pub delay_open: u32,

/// How long to to wait between TCP connection retries (seconds).
pub connect_retry: u32,

/// How often to send keepalive requests (seconds).
pub keepalive: u32,

/// Require that a peer has a specified ASN.
pub remote_asn: Option<u32>,

/// Require messages from a peer have a minimum IP time to live field.
pub min_ttl: Option<u8>,

/// Use the given key for TCP-MD5 authentication with the peer.
pub md5_auth_key: Option<String>,

/// Apply the provided multi-exit discriminator (MED) updates sent to the peer.
pub multi_exit_discriminator: Option<u32>,

/// Include the provided communities in updates sent to the peer.
pub communities: Vec<u32>,

/// Apply a local preference to routes received from this peer.
pub local_pref: Option<u32>,

/// Enforce that the first AS in paths received from this peer is the peer's AS.
pub enforce_first_as: bool,

/// Define import policy for a peer.
pub allowed_import: ImportExportPolicy,

/// Define export policy for a peer.
pub allowed_export: ImportExportPolicy,

/// Associate a VLAN ID with a peer.
pub vlan_id: Option<u16>,

/// Router lifetime in seconds for unnumbered BGP peers.
pub router_lifetime: u16,
}

/// A base BGP configuration.
#[derive(
ObjectIdentity, Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq,
Expand Down
4 changes: 2 additions & 2 deletions nexus/db-model/src/switch_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use nexus_db_schema::schema::{
use nexus_types::external_api::networking as networking_types;
use nexus_types::identity::Resource;
use omicron_common::api::external;
use omicron_common::api::external::{BgpPeer, ImportExportPolicy};
use omicron_common::api::external::ImportExportPolicy;
use omicron_common::api::internal::shared::{PortFec, PortSpeed};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
Expand Down Expand Up @@ -741,7 +741,7 @@ impl SwitchPortBgpPeerConfig {
port_settings_id: Uuid,
bgp_config_id: Uuid,
interface_name: Name,
p: &BgpPeer,
p: &networking_types::BgpPeer,
) -> Self {
Self {
id: Uuid::new_v4(),
Expand Down
19 changes: 9 additions & 10 deletions nexus/db-queries/src/db/datastore/switch_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ pub struct BgpPeerConfig {
pub router_lifetime: SqlU16,
}

impl Into<external::BgpPeer> for BgpPeerConfig {
fn into(self) -> external::BgpPeer {
external::BgpPeer {
impl Into<networking::BgpPeer> for BgpPeerConfig {
fn into(self) -> networking::BgpPeer {
networking::BgpPeer {
bgp_config: self.bgp_config_id.into(),
interface_name: self.interface_name.into(),
addr: self.addr.map(|a| a.ip()),
Expand Down Expand Up @@ -131,9 +131,9 @@ impl SwitchPortSettingsCombinedResult {
}
}

impl Into<external::SwitchPortSettings> for SwitchPortSettingsCombinedResult {
fn into(self) -> external::SwitchPortSettings {
external::SwitchPortSettings {
impl Into<networking::SwitchPortSettings> for SwitchPortSettingsCombinedResult {
fn into(self) -> networking::SwitchPortSettings {
networking::SwitchPortSettings {
identity: self.settings.identity(),
port: self.port.into(),
groups: self.groups.into_iter().map(Into::into).collect(),
Expand Down Expand Up @@ -1398,7 +1398,7 @@ async fn do_switch_port_settings_create(
.get_results_async(conn)
.await?;

let mut peer_by_addr: BTreeMap<IpAddr, &external::BgpPeer> =
let mut peer_by_addr: BTreeMap<IpAddr, &networking::BgpPeer> =
BTreeMap::new();

let mut bgp_peer_config = Vec::new();
Expand Down Expand Up @@ -1869,12 +1869,11 @@ mod test {
use crate::db::datastore::UpdatePrecondition;
use crate::db::pub_test_utils::TestDatabase;
use nexus_types::external_api::networking::{
BgpAnnounceSetCreate, BgpConfigCreate, BgpPeerConfig,
BgpAnnounceSetCreate, BgpConfigCreate, BgpPeer, BgpPeerConfig,
SwitchPortConfigCreate, SwitchPortGeometry, SwitchPortSettingsCreate,
};
use omicron_common::api::external::{
BgpPeer, IdentityMetadataCreateParams, ImportExportPolicy, Name,
NameOrId,
IdentityMetadataCreateParams, ImportExportPolicy, Name, NameOrId,
};
use omicron_test_utils::dev;
use std::{collections::HashMap, str::FromStr};
Expand Down
7 changes: 5 additions & 2 deletions nexus/external-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4325,7 +4325,10 @@ pub trait NexusExternalApi {
async fn networking_switch_port_settings_create(
rqctx: RequestContext<Self::Context>,
new_settings: TypedBody<latest::networking::SwitchPortSettingsCreate>,
) -> Result<HttpResponseCreated<SwitchPortSettings>, HttpError>;
) -> Result<
HttpResponseCreated<latest::networking::SwitchPortSettings>,
HttpError,
>;

/// Create switch port settings (old version with required BgpPeer.addr)
#[endpoint {
Expand Down Expand Up @@ -4394,7 +4397,7 @@ pub trait NexusExternalApi {
async fn networking_switch_port_settings_view(
rqctx: RequestContext<Self::Context>,
path_params: Path<latest::networking::SwitchPortSettingsInfoSelector>,
) -> Result<HttpResponseOk<SwitchPortSettings>, HttpError>;
) -> Result<HttpResponseOk<latest::networking::SwitchPortSettings>, HttpError>;

/// Get information about switch port (old version with required BgpPeer.addr)
#[endpoint {
Expand Down
5 changes: 2 additions & 3 deletions nexus/src/app/rack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use nexus_types::inventory::SpType;
use nexus_types::silo::silo_dns_name;
use omicron_common::address::{Ipv6Subnet, RACK_PREFIX, get_64_subnet};
use omicron_common::api::external::AddressLotKind;
use omicron_common::api::external::BgpPeer;
use omicron_common::api::external::DataPageParams;
use omicron_common::api::external::Error;
use omicron_common::api::external::IdentityMetadataCreateParams;
Expand Down Expand Up @@ -595,10 +594,10 @@ impl super::Nexus {
routes,
});

let peers: Vec<BgpPeer> = uplink_config
let peers: Vec<networking::BgpPeer> = uplink_config
.bgp_peers
.iter()
.map(|r| BgpPeer {
.map(|r| networking::BgpPeer {
bgp_config: NameOrId::Name(
format!("as{}", r.asn).parse().unwrap(),
),
Expand Down
8 changes: 4 additions & 4 deletions nexus/src/external_api/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ use omicron_common::api::external::RouterRoute;
use omicron_common::api::external::RouterRouteKind;
use omicron_common::api::external::ServiceIcmpConfig;
use omicron_common::api::external::SwitchPort;
use omicron_common::api::external::SwitchPortSettings;
use omicron_common::api::external::SwitchPortSettingsIdentity;
use omicron_common::api::external::VpcFirewallRuleUpdateParams;
use omicron_common::api::external::VpcFirewallRules;
Expand Down Expand Up @@ -4056,12 +4055,13 @@ impl NexusExternalApi for NexusExternalApiImpl {
async fn networking_switch_port_settings_create(
rqctx: RequestContext<ApiContext>,
new_settings: TypedBody<networking::SwitchPortSettingsCreate>,
) -> Result<HttpResponseCreated<SwitchPortSettings>, HttpError> {
) -> Result<HttpResponseCreated<networking::SwitchPortSettings>, HttpError>
{
audit_and_time(&rqctx, |opctx, nexus| async move {
let params = new_settings.into_inner();
let result =
nexus.switch_port_settings_post(&opctx, params).await?;
let settings: SwitchPortSettings = result.into();
let settings: networking::SwitchPortSettings = result.into();
Ok(HttpResponseCreated(settings))
})
.await
Expand Down Expand Up @@ -4120,7 +4120,7 @@ impl NexusExternalApi for NexusExternalApiImpl {
async fn networking_switch_port_settings_view(
rqctx: RequestContext<ApiContext>,
path_params: Path<networking::SwitchPortSettingsInfoSelector>,
) -> Result<HttpResponseOk<SwitchPortSettings>, HttpError> {
) -> Result<HttpResponseOk<networking::SwitchPortSettings>, HttpError> {
let apictx = rqctx.context();
let handler = async {
let nexus = &apictx.context.nexus;
Expand Down
8 changes: 4 additions & 4 deletions nexus/tests/integration_tests/switch_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ use nexus_test_utils::http_testing::{AuthnMode, NexusRequest, RequestBuilder};
use nexus_test_utils_macros::nexus_test;
use nexus_types::external_api::networking::{
Address, AddressConfig, AddressLotBlockCreate, AddressLotCreate,
BgpAnnounceSetCreate, BgpAnnouncementCreate, BgpConfigCreate,
BgpAnnounceSetCreate, BgpAnnouncementCreate, BgpConfigCreate, BgpPeer,
BgpPeerConfig, LinkConfigCreate, LldpLinkConfigCreate, Route, RouteConfig,
SwitchInterfaceConfigCreate, SwitchInterfaceKind, SwitchPortApplySettings,
SwitchPortSettingsCreate,
SwitchPortSettings, SwitchPortSettingsCreate,
};
use nexus_types::external_api::rack::Rack;
use omicron_common::api::external::{
self, AddressLotKind, BgpPeer, IdentityMetadataCreateParams, LinkFec,
LinkSpeed, NameOrId, SwitchLocation, SwitchPort, SwitchPortSettings,
self, AddressLotKind, IdentityMetadataCreateParams, LinkFec, LinkSpeed,
NameOrId, SwitchLocation, SwitchPort,
};
use omicron_common::api::external::{ImportExportPolicy, Name};
use oxnet::IpNet;
Expand Down
Loading
Loading