Skip to content
Open
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
34 changes: 17 additions & 17 deletions nexus/db-model/src/ip_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl std::fmt::Display for IpRangeConversionError {
impl std::error::Error for IpRangeConversionError {}

impl_enum_type!(
IpPoolReservationTypeEnum:
IpPoolAssignmentEnum:

#[derive(
AsExpression,
Expand All @@ -62,17 +62,17 @@ impl_enum_type!(
serde::Deserialize,
serde::Serialize,
)]
pub enum IpPoolReservationType;
pub enum IpPoolAssignment;

ExternalSilos => b"external_silos"
OxideInternal => b"oxide_internal"
Silos => b"silos"
SystemServices => b"system_services"
);

impl ::std::fmt::Display for IpPoolReservationType {
impl ::std::fmt::Display for IpPoolAssignment {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match self {
IpPoolReservationType::ExternalSilos => "external_silos",
IpPoolReservationType::OxideInternal => "oxide_internal",
IpPoolAssignment::Silos => "silos",
IpPoolAssignment::SystemServices => "system_services",
};
f.write_str(s)
}
Expand Down Expand Up @@ -163,8 +163,8 @@ pub struct IpPool {
/// the contained ranges.
pub rcgen: i64,

/// Indicates what the pool is reserved for.
pub reservation_type: IpPoolReservationType,
/// Indicates what the pool is assigned for.
pub assignment: IpPoolAssignment,
/// Pool type for unicast (default) vs multicast pools.
pub pool_type: IpPoolType,
}
Expand All @@ -176,7 +176,7 @@ impl IpPool {
pub fn new(
pool_identity: &external::IdentityMetadataCreateParams,
ip_version: IpVersion,
reservation_type: IpPoolReservationType,
assignment: IpPoolAssignment,
) -> Self {
Self {
identity: IpPoolIdentity::new(
Expand All @@ -186,15 +186,15 @@ impl IpPool {
ip_version,
pool_type: IpPoolType::Unicast,
rcgen: 0,
reservation_type,
assignment,
}
}

/// Creates a new multicast IP pool.
pub fn new_multicast(
pool_identity: &external::IdentityMetadataCreateParams,
ip_version: IpVersion,
reservation_type: IpPoolReservationType,
assignment: IpPoolAssignment,
) -> Self {
Self {
identity: IpPoolIdentity::new(
Expand All @@ -204,24 +204,24 @@ impl IpPool {
ip_version,
pool_type: IpPoolType::Multicast,
rcgen: 0,
reservation_type,
assignment,
}
}

/// Create a new IPv4 IP Pool.
pub fn new_v4(
pool_identity: &external::IdentityMetadataCreateParams,
reservation_type: IpPoolReservationType,
assignment: IpPoolAssignment,
) -> Self {
Self::new(pool_identity, IpVersion::V4, reservation_type)
Self::new(pool_identity, IpVersion::V4, assignment)
}

/// Create a new IPv6 IP Pool.
pub fn new_v6(
pool_identity: &external::IdentityMetadataCreateParams,
reservation_type: IpPoolReservationType,
assignment: IpPoolAssignment,
) -> Self {
Self::new(pool_identity, IpVersion::V6, reservation_type)
Self::new(pool_identity, IpVersion::V6, assignment)
}
}

Expand Down
3 changes: 2 additions & 1 deletion nexus/db-model/src/schema_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
///
/// This must be updated when you change the database schema. Refer to
/// schema/crdb/README.adoc in the root of this repository for details.
pub const SCHEMA_VERSION: Version = Version::new(261, 0, 0);
pub const SCHEMA_VERSION: Version = Version::new(262, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -28,6 +28,7 @@ pub static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
// | leaving the first copy as an example for the next person.
// v
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
KnownVersion::new(262, "rename-ip-pool-reservation-type"),
KnownVersion::new(261, "remove-add-zones-with-mupdate-override"),
KnownVersion::new(260, "ereport-trim-serial-trailing-nulls"),
KnownVersion::new(259, "vmm-failure-reason"),
Expand Down
10 changes: 5 additions & 5 deletions nexus/db-queries/src/db/datastore/external_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ mod tests {
};
use nexus_db_model::IpPoolResourceType;
use nexus_db_model::IpVersion;
use nexus_db_model::{Generation, IpPoolReservationType, Ipv4Net, Ipv6Net};
use nexus_db_model::{Generation, IpPoolAssignment, Ipv4Net, Ipv6Net};
use nexus_db_model::{
IncompleteIpPoolResource, IncompleteNetworkInterface, IncompleteVpc,
VpcSubnet,
Expand Down Expand Up @@ -1588,7 +1588,7 @@ mod tests {
description: "Multicast default pool".to_string(),
},
IpVersion::V4,
IpPoolReservationType::ExternalSilos,
IpPoolAssignment::Silos,
),
)
.await
Expand Down Expand Up @@ -1660,7 +1660,7 @@ mod tests {
description: "Unicast default pool".to_string(),
},
IpVersion::V4,
IpPoolReservationType::ExternalSilos,
IpPoolAssignment::Silos,
),
)
.await
Expand Down Expand Up @@ -1842,7 +1842,7 @@ mod tests {
description: "Multicast default pool".to_string(),
},
IpVersion::V4,
IpPoolReservationType::ExternalSilos,
IpPoolAssignment::Silos,
),
)
.await
Expand Down Expand Up @@ -1914,7 +1914,7 @@ mod tests {
description: "Unicast default pool".to_string(),
},
IpVersion::V4,
IpPoolReservationType::ExternalSilos,
IpPoolAssignment::Silos,
),
)
.await
Expand Down
4 changes: 2 additions & 2 deletions nexus/db-queries/src/db/datastore/external_subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ mod tests {
use nexus_auth::authz;
use nexus_db_model::IpAttachState;
use nexus_db_model::IpPool;
use nexus_db_model::IpPoolReservationType;
use nexus_db_model::IpPoolAssignment;
use nexus_db_model::Name;
use nexus_db_model::Project;
use nexus_db_model::SubnetPool;
Expand Down Expand Up @@ -4152,7 +4152,7 @@ mod tests {
IpPool::new(
&identity,
IpVersion::V6.into(),
IpPoolReservationType::ExternalSilos,
IpPoolAssignment::Silos,
),
)
.await
Expand Down
Loading
Loading