Skip to content

Commit

Permalink
[π˜€π—½π—Ώ] initial version
Browse files Browse the repository at this point in the history
Created using spr 1.3.6-beta.1
  • Loading branch information
sunshowers committed Apr 29, 2024
1 parent bca1f2d commit ef83633
Show file tree
Hide file tree
Showing 25 changed files with 1,602 additions and 1,141 deletions.
73 changes: 60 additions & 13 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ members = [
"nexus/db-model",
"nexus/db-queries",
"nexus/defaults",
"nexus/internal-api",
"nexus/inventory",
"nexus/macros-common",
"nexus/metrics-producer-gc",
Expand Down Expand Up @@ -128,6 +129,7 @@ default-members = [
"nexus/db-model",
"nexus/db-queries",
"nexus/defaults",
"nexus/internal-api",
"nexus/inventory",
"nexus/reconfigurator/execution",
"nexus/reconfigurator/planning",
Expand Down Expand Up @@ -277,6 +279,7 @@ nexus-config = { path = "nexus-config" }
nexus-db-model = { path = "nexus/db-model" }
nexus-db-queries = { path = "nexus/db-queries" }
nexus-defaults = { path = "nexus/defaults" }
nexus-internal-api = { path = "nexus/internal-api" }
nexus-inventory = { path = "nexus/inventory" }
nexus-macros-common = { path = "nexus/macros-common" }
nexus-metrics-producer-gc = { path = "nexus/metrics-producer-gc" }
Expand Down Expand Up @@ -619,8 +622,9 @@ opt-level = 3
# It's common during development to use a local copy of various complex
# dependencies. If you want to use those, uncomment one of these blocks.
#
#[patch."https://github.com/oxidecomputer/dropshot"]
[patch."https://github.com/oxidecomputer/dropshot"]
#dropshot = { path = "../dropshot/dropshot" }
dropshot = { git = "https://github.com/oxidecomputer//dropshot", branch = "sunshowers/spr/wip-prototype-for-trait-based-dropshot-servers" }
#[patch.crates-io]
#steno = { path = "../steno" }
#[patch."https://github.com/oxidecomputer/propolis"]
Expand Down
1 change: 1 addition & 0 deletions nexus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ uuid.workspace = true
nexus-defaults.workspace = true
nexus-db-model.workspace = true
nexus-db-queries.workspace = true
nexus-internal-api.workspace = true
nexus-inventory.workspace = true
nexus-metrics-producer-gc.workspace = true
nexus-reconfigurator-execution.workspace = true
Expand Down
23 changes: 23 additions & 0 deletions nexus/db-model/src/external_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use nexus_types::deployment::OmicronZoneExternalSnatIp;
use nexus_types::external_api::params;
use nexus_types::external_api::shared;
use nexus_types::external_api::views;
use nexus_types::external_api::views::ProbeExternalIp;
use nexus_types::external_api::views::ProbeIpKind;
use nexus_types::inventory::SourceNatConfig;
use omicron_common::api::external::Error;
use omicron_common::api::external::IdentityMetadata;
Expand Down Expand Up @@ -90,6 +92,16 @@ impl std::fmt::Display for IpKind {
}
}

impl From<IpKind> for ProbeIpKind {
fn from(kind: IpKind) -> ProbeIpKind {
match kind {
IpKind::Floating => ProbeIpKind::Floating,
IpKind::Ephemeral => ProbeIpKind::Ephemeral,
IpKind::SNat => ProbeIpKind::Snat,
}
}
}

/// The main model type for external IP addresses for instances
/// and externally-facing services.
///
Expand Down Expand Up @@ -140,6 +152,17 @@ pub struct ExternalIp {
pub is_probe: bool,
}

impl From<ExternalIp> for ProbeExternalIp {
fn from(ip: ExternalIp) -> Self {
Self {
ip: ip.ip.ip(),
first_port: ip.first_port.0,
last_port: ip.last_port.0,
kind: ip.kind.into(),
}
}
}

#[derive(Debug, thiserror::Error, SlogInlineError)]
pub enum OmicronZoneExternalIpError {
#[error("database IP is for an instance")]
Expand Down
18 changes: 1 addition & 17 deletions nexus/db-model/src/ipv4_nat_entry.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use std::net::{Ipv4Addr, Ipv6Addr};

use super::MacAddr;
use crate::{
schema::ipv4_nat_changes, schema::ipv4_nat_entry, Ipv4Net, Ipv6Net, SqlU16,
Vni,
};
use chrono::{DateTime, Utc};
use omicron_common::api::external;
use schemars::JsonSchema;
use nexus_types::internal_api::views::Ipv4NatEntryView;
use serde::Deserialize;
use serde::Serialize;
use uuid::Uuid;
Expand Down Expand Up @@ -65,19 +62,6 @@ pub struct Ipv4NatChange {
pub deleted: bool,
}

/// NAT Record
#[derive(Clone, Debug, Serialize, JsonSchema)]
pub struct Ipv4NatEntryView {
pub external_address: Ipv4Addr,
pub first_port: u16,
pub last_port: u16,
pub sled_address: Ipv6Addr,
pub vni: external::Vni,
pub mac: external::MacAddr,
pub gen: i64,
pub deleted: bool,
}

impl From<Ipv4NatChange> for Ipv4NatEntryView {
fn from(value: Ipv4NatChange) -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/datastore/ipv4_nat_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use diesel::prelude::*;
use diesel::sql_types::BigInt;
use nexus_db_model::ExternalIp;
use nexus_db_model::Ipv4NatChange;
use nexus_db_model::Ipv4NatEntryView;
use nexus_types::internal_api::views::Ipv4NatEntryView;
use omicron_common::api::external::CreateResult;
use omicron_common::api::external::DeleteResult;
use omicron_common::api::external::Error;
Expand Down
1 change: 0 additions & 1 deletion nexus/db-queries/src/db/datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ pub use dns::DnsVersionUpdateBuilder;
pub use instance::InstanceAndActiveVmm;
pub use inventory::DataStoreInventoryTest;
use nexus_db_model::AllSchemaVersions;
pub use probe::ProbeInfo;
pub use rack::RackInit;
pub use silo::Discoverability;
pub use switch_port::SwitchPortSettingsCombinedResult;
Expand Down
51 changes: 1 addition & 50 deletions nexus/db-queries/src/db/datastore/probe.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::net::IpAddr;

use crate::authz;
use crate::context::OpContext;
use crate::db;
Expand All @@ -16,6 +14,7 @@ use nexus_db_model::IncompleteNetworkInterface;
use nexus_db_model::Probe;
use nexus_db_model::VpcSubnet;
use nexus_types::external_api::params;
use nexus_types::external_api::views::ProbeInfo;
use nexus_types::identity::Resource;
use omicron_common::api::external::http_pagination::PaginatedBy;
use omicron_common::api::external::CreateResult;
Expand All @@ -29,56 +28,8 @@ use omicron_common::api::external::NameOrId;
use omicron_common::api::external::ResourceType;
use omicron_common::api::internal::shared::NetworkInterface;
use ref_cast::RefCast;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

#[derive(Debug, Clone, JsonSchema, Serialize, Deserialize)]
pub struct ProbeInfo {
pub id: Uuid,
pub name: Name,
sled: Uuid,
pub external_ips: Vec<ProbeExternalIp>,
pub interface: NetworkInterface,
}

#[derive(Debug, Clone, JsonSchema, Serialize, Deserialize)]
pub struct ProbeExternalIp {
ip: IpAddr,
first_port: u16,
last_port: u16,
kind: IpKind,
}

impl From<nexus_db_model::ExternalIp> for ProbeExternalIp {
fn from(value: nexus_db_model::ExternalIp) -> Self {
Self {
ip: value.ip.ip(),
first_port: value.first_port.0,
last_port: value.last_port.0,
kind: value.kind.into(),
}
}
}

#[derive(Debug, Clone, JsonSchema, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum IpKind {
Snat,
Floating,
Ephemeral,
}

impl From<nexus_db_model::IpKind> for IpKind {
fn from(value: nexus_db_model::IpKind) -> Self {
match value {
nexus_db_model::IpKind::SNat => Self::Snat,
nexus_db_model::IpKind::Ephemeral => Self::Ephemeral,
nexus_db_model::IpKind::Floating => Self::Floating,
}
}
}

impl super::DataStore {
/// List the probes for the given project.
pub async fn probe_list(
Expand Down
Loading

0 comments on commit ef83633

Please sign in to comment.