Skip to content
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

6750 Add support for post-install LLDP configuration #7132

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
39 changes: 36 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ libfalcon = { git = "https://github.com/oxidecomputer/falcon", branch = "main" }
libnvme = { git = "https://github.com/oxidecomputer/libnvme", rev = "dd5bb221d327a1bc9287961718c3c10d6bd37da0" }
linear-map = "1.2.0"
live-tests-macros = { path = "live-tests/macros" }
# XXX: switch back to main branch before integration
lldpd-client = { git = "https://github.com/oxidecomputer/lldp", branch = "paginate" }
macaddr = { version = "1.0.1", features = ["serde_std"] }
maplit = "1.0.2"
mockall = "0.13"
Expand Down
7 changes: 4 additions & 3 deletions common/src/api/external/http_pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use std::num::NonZeroU32;
use uuid::Uuid;

use super::SimpleIdentity;
use super::SimpleIdentityOrName;

// General pagination infrastructure

Expand Down Expand Up @@ -140,16 +141,16 @@ pub fn marker_for_name<S, T: ObjectIdentity>(_: &S, t: &T) -> Name {
///
/// This is intended for use with [`ScanById::results_page`] with objects that
/// impl [`ObjectIdentity`].
pub fn marker_for_id<S, T: ObjectIdentity>(_: &S, t: &T) -> Uuid {
t.identity().id
pub fn marker_for_id<S, T: SimpleIdentity>(_: &S, t: &T) -> Uuid {
t.id()
}

/// Marker function that extracts the "name" or "id" from an object, depending
/// on the scan in use
///
/// This is intended for use with [`ScanByNameOrId::results_page`] with objects
/// that impl [`ObjectIdentity`].
pub fn marker_for_name_or_id<T: SimpleIdentity, Selector>(
pub fn marker_for_name_or_id<T: SimpleIdentityOrName, Selector>(
scan: &ScanByNameOrId<Selector>,
item: &T,
) -> NameOrId {
Expand Down
61 changes: 59 additions & 2 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,28 @@ pub trait ObjectIdentity {
}

/// Exists for types that don't properly implement `ObjectIdentity` but
/// still need to be paginated by name or id.
/// still need to be paginated by id.
pub trait SimpleIdentity {
fn id(&self) -> Uuid;
fn name(&self) -> &Name;
}

impl<T: ObjectIdentity> SimpleIdentity for T {
fn id(&self) -> Uuid {
self.identity().id
}
}

/// Exists for types that don't properly implement `ObjectIdentity` but
/// still need to be paginated by name or id.
pub trait SimpleIdentityOrName {
fn id(&self) -> Uuid;
fn name(&self) -> &Name;
}

impl<T: ObjectIdentity> SimpleIdentityOrName for T {
fn id(&self) -> Uuid {
self.identity().id
}

fn name(&self) -> &Name {
&self.identity().name
Expand Down Expand Up @@ -1010,6 +1022,7 @@ pub enum ResourceType {
FloatingIp,
Probe,
ProbeNetworkInterface,
LldpLinkConfig,
}

// IDENTITY METADATA
Expand Down Expand Up @@ -2555,6 +2568,50 @@ pub struct LldpLinkConfig {
pub management_ip: Option<oxnet::IpNet>,
}

/// Information about LLDP advertisements from other network entities directly
/// connected to a switch port. This structure contains both metadata about
/// when and where the neighbor was seen, as well as the specific information
/// the neighbor was advertising.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct LldpNeighbor {
// Unique ID assigned to this neighbor - only used for pagination
#[serde(skip)]
pub id: Uuid,

/// The port on which the neighbor was seen
pub local_port: String,

/// Initial sighting of this LldpNeighbor
pub first_seen: DateTime<Utc>,

/// Most recent sighting of this LldpNeighbor
pub last_seen: DateTime<Utc>,

/// The LLDP link name advertised by the neighbor
pub link_name: String,

/// The LLDP link description advertised by the neighbor
pub link_description: Option<String>,

/// The LLDP chassis identifier advertised by the neighbor
pub chassis_id: String,

/// The LLDP system name advertised by the neighbor
pub system_name: Option<String>,

/// The LLDP system description advertised by the neighbor
pub system_description: Option<String>,

/// The LLDP management IP(s) advertised by the neighbor
pub management_ip: Vec<oxnet::IpNet>,
}

impl SimpleIdentity for LldpNeighbor {
fn id(&self) -> Uuid {
self.id
}
}

/// Per-port tx-eq overrides. This can be used to fine-tune the transceiver
/// equalization settings to improve signal integrity.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
Expand Down
8 changes: 7 additions & 1 deletion dev-tools/ls-apis/api-manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# Progenitor clients or APIs, so they're left out to avoid needing to create and
# process clones of these repos:
#
# - lldp
# - pumpkind
# - thundermuffin
#
Expand Down Expand Up @@ -74,6 +73,7 @@ packages = [
# switch zone
"ddmd",
"dpd",
"lldpd",
"mgd",
"omicron-gateway",
"tfportd",
Expand Down Expand Up @@ -231,6 +231,12 @@ and exists as a client library within omicron. This is because the Dendrite \
repo is not currently open source.
"""

[[apis]]
client_package_name = "lldpd-client"
label = "LLDP daemon"
server_package_name = "lldpd"
notes = "The LLDP daemon runs in the switch zone and is deployed next to dpd."

[[apis]]
client_package_name = "gateway-client"
label = "Management Gateway Service"
Expand Down
1 change: 1 addition & 0 deletions dev-tools/ls-apis/src/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl Workspaces {
)])),
),
("maghemite", "mg-admin-client", None),
("lldp", "lldpd-client", None),
]
.into_iter()
.map(|(repo, omicron_pkg, extra_features)| {
Expand Down
3 changes: 3 additions & 0 deletions dev-tools/ls-apis/tests/api_dependencies.out
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ Management Gateway Service (client: gateway-client)
Wicketd Installinator (client: installinator-client)
consumed by: installinator (omicron/installinator) via 1 path

LLDP daemon (client: lldpd-client)
consumed by: omicron-nexus (omicron/nexus) via 1 path

Maghemite MG Admin (client: mg-admin-client)
consumed by: omicron-nexus (omicron/nexus) via 1 path
consumed by: omicron-sled-agent (omicron/sled-agent) via 1 path
Expand Down
1 change: 1 addition & 0 deletions nexus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ internal-dns-resolver.workspace = true
internal-dns-types.workspace = true
ipnetwork.workspace = true
itertools.workspace = true
lldpd-client.workspace = true
macaddr.workspace = true
# Not under "dev-dependencies"; these also need to be implemented for
# integration tests.
Expand Down
Loading
Loading