Skip to content

Commit

Permalink
add monitors to port status info
Browse files Browse the repository at this point in the history
  • Loading branch information
rcgoodfellow committed May 3, 2024
1 parent 5c5d23d commit 2e8f25f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
12 changes: 9 additions & 3 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2694,11 +2694,17 @@ pub struct SwitchPortAddressConfig {
/// Opaque object representing link state. The contents of this object are not
/// yet stable.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SwitchLinkState(dpd_client::types::Link);
pub struct SwitchLinkState {
link: dpd_client::types::Link,
monitors: Option<dpd_client::types::Monitors>,
}

impl SwitchLinkState {
pub fn new(arg: dpd_client::types::Link) -> Self {
Self(arg)
pub fn new(
link: dpd_client::types::Link,
monitors: Option<dpd_client::types::Monitors>,
) -> Self {
Self { link, monitors }
}
}

Expand Down
32 changes: 14 additions & 18 deletions nexus/src/app/switch_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,24 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//XXX
#![allow(unused_imports)]

use crate::app::sagas;
use crate::external_api::params;
use db::datastore::SwitchPortSettingsCombinedResult;
use dpd_client::types::LinkId;
use dpd_client::types::PortId;
use dpd_client::types::Qsfp;
use dropshot::HttpError;
use http::StatusCode;
use ipnetwork::IpNetwork;
use nexus_db_model::{SwitchLinkFec, SwitchLinkSpeed};
use nexus_db_queries::authn;
use nexus_db_queries::authz;
use nexus_db_queries::context::OpContext;
use nexus_db_queries::db;
use nexus_db_queries::db::datastore::UpdatePrecondition;
use nexus_db_queries::db::model::{SwitchPort, SwitchPortSettings};
use nexus_db_queries::db::DataStore;
use nexus_types::identity::Resource;
use omicron_common::api::external::http_pagination::PaginatedBy;
use omicron_common::api::external::SwitchLinkState;
use omicron_common::api::external::SwitchLocation;
use omicron_common::api::external::{
self, CreateResult, DataPageParams, DeleteResult, Error, ListResultVec,
LookupResult, Name, NameOrId, UpdateResult,
};
use sled_agent_client::types::BgpConfig;
use sled_agent_client::types::BgpPeerConfig;
use sled_agent_client::types::{
EarlyNetworkConfig, PortConfigV1, RackNetworkConfigV1, RouteConfig,
};
use std::ops::Deref;
use std::sync::mpsc::RecvError;
use std::sync::Arc;
use uuid::Uuid;

Expand Down Expand Up @@ -336,7 +319,20 @@ impl super::Nexus {
})?
.into_inner();

Ok(SwitchLinkState::new(status))
let monitors = match dpd.transceiver_monitors_get(&port_id).await {
Ok(resp) => Some(resp.into_inner()),
Err(e) => {
if let Some(StatusCode::NOT_FOUND) = e.status() {
None
} else {
return Err(Error::internal_error(&format!(
"failed to get txr monitors for {port} {e}"
)));
}
}
};

Ok(SwitchLinkState::new(status, monitors))
}
}

Expand Down

0 comments on commit 2e8f25f

Please sign in to comment.