Skip to content

Commit a3d0f56

Browse files
author
Levon Tarver
committed
WIP: placeholder to keep PR open
1 parent b88e966 commit a3d0f56

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

nexus/src/internal_api/http_entrypoints.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use nexus_types::internal_api::params::SwitchPutResponse;
3434
use nexus_types::internal_api::views::to_list;
3535
use nexus_types::internal_api::views::BackgroundTask;
3636
use nexus_types::internal_api::views::Saga;
37+
use nexus_types::internal_api::views::SwitchPortSettings;
3738
use omicron_common::api::external::http_pagination::data_page_params_for;
3839
use omicron_common::api::external::http_pagination::PaginatedById;
3940
use omicron_common::api::external::http_pagination::ScanById;
@@ -606,6 +607,37 @@ async fn ipv4_nat_changeset(
606607
apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await
607608
}
608609

610+
/// Fetch Port Settings
611+
///
612+
#[endpoint {
613+
method = GET,
614+
path = "/networking/switch-port-settings"
615+
}]
616+
async fn list_switch_port_settings(
617+
rqctx: RequestContext<Arc<ServerContext>>,
618+
query_params: Query<PaginatedById>,
619+
) -> Result<HttpResponseOk<ResultsPage<SwitchPortSettings>>, HttpError> {
620+
let apictx = rqctx.context();
621+
let handler = async {
622+
let nexus = &apictx.nexus;
623+
let query = query_params.into_inner();
624+
let opctx = crate::context::op_context_for_internal_api(&rqctx).await;
625+
let pagparams = data_page_params_for(&rqctx, &query)?;
626+
627+
// TODO: if we follow the same approach of dendrite calling up to get
628+
// changes instead of nexus pushing changes down, how do we differentiate
629+
// dendrite of switch 1 from dendrite of switch 2? The caller could
630+
// provide such information via a query parameter. This would require
631+
// dendrite to know which switch slot it is managing (it could get this
632+
// information // from `mgs`). On the other hand, Nexus already knows
633+
// which dendrite is which
634+
635+
// If we differentiate based on
636+
todo!()
637+
};
638+
apictx.internal_latencies.instrument_dropshot_handler(&rqctx, handler).await
639+
}
640+
609641
// APIs for managing blueprints
610642
//
611643
// These are not (yet) intended for use by any other programs. Eventually, we

nexus/types/src/internal_api/views.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ use steno::SagaResultErr;
1515
use steno::UndoActionError;
1616
use uuid::Uuid;
1717

18+
use omicron_common::api::external::{
19+
LldpServiceConfig, SwitchInterfaceConfig, SwitchPortAddressConfig,
20+
SwitchPortConfig, SwitchPortLinkConfig, SwitchPortRouteConfig,
21+
SwitchPortSettings, SwitchPortSettingsGroups, SwitchVlanInterfaceConfig,
22+
};
23+
1824
pub async fn to_list<T, U>(object_stream: ObjectStream<T>) -> Vec<U>
1925
where
2026
T: Into<U>,
@@ -296,3 +302,35 @@ pub struct LastResultCompleted {
296302
/// arbitrary datum emitted by the background task
297303
pub details: serde_json::Value,
298304
}
305+
306+
/// This structure contains a subset of port settings needed for synchronizing
307+
/// switch port configurations in `dendrite` via the internal api
308+
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
309+
pub struct SwitchPortSettings {
310+
/// The primary switch port settings handle.
311+
pub settings: SwitchPortSettings,
312+
313+
/// Switch port settings included from other switch port settings groups.
314+
pub groups: Vec<SwitchPortSettingsGroups>,
315+
316+
/// Layer 1 physical port settings.
317+
pub port: SwitchPortConfig,
318+
319+
/// Layer 2 link settings.
320+
pub links: Vec<SwitchPortLinkConfig>,
321+
322+
/// Link-layer discovery protocol (LLDP) settings.
323+
pub link_lldp: Vec<LldpServiceConfig>,
324+
325+
/// Layer 3 interface settings.
326+
pub interfaces: Vec<SwitchInterfaceConfig>,
327+
328+
/// Vlan interface settings.
329+
pub vlan_interfaces: Vec<SwitchVlanInterfaceConfig>,
330+
331+
/// IP route settings.
332+
pub routes: Vec<SwitchPortRouteConfig>,
333+
334+
/// Layer 3 IP address settings.
335+
pub addresses: Vec<SwitchPortAddressConfig>,
336+
}

0 commit comments

Comments
 (0)