Skip to content

Commit f3c16d2

Browse files
committed
Internal support for linking any number of IP Pools and Silos.
- Add database queries for linking any number of IP Pools to the Oxide internal Silo, rather than assuming there's just one. - Rework queries for linking / unlinking IP Pool and Silo, making them concurrency-safe and preventing deletion when there are IPs or we're trying to delete the last internal IP Pool. - The public API does not change here. We're still assuming exactly one IP Pool per IP version for internal usage, and not allowing the link or pool to appear in the API. That'll be a follow-up commit. - Fixes #8948
1 parent 11b2a66 commit f3c16d2

File tree

8 files changed

+1349
-151
lines changed

8 files changed

+1349
-151
lines changed

common/src/api/external/http_pagination.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,15 @@ pub enum PaginatedBy<'a> {
382382
Name(DataPageParams<'a, Name>),
383383
}
384384

385+
impl<'a> PaginatedBy<'a> {
386+
pub fn limit(&self) -> NonZeroU32 {
387+
match self {
388+
PaginatedBy::Id(inner) => inner.limit,
389+
PaginatedBy::Name(inner) => inner.limit,
390+
}
391+
}
392+
}
393+
385394
impl<T: Clone + Debug + DeserializeOwned + JsonSchema + PartialEq + Serialize>
386395
ScanParams for ScanByNameOrId<T>
387396
{

nexus/db-model/src/ip_pool.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ impl From<IpVersion> for shared::IpVersion {
7777
/// IP pools can be external or internal. External IP pools can be associated
7878
/// with a silo or project so that instance IP allocation draws from that pool
7979
/// instead of a system pool.
80-
#[derive(Queryable, Insertable, Selectable, Clone, Debug, Resource)]
80+
#[derive(
81+
Queryable, Insertable, Selectable, Clone, Debug, Resource, PartialEq,
82+
)]
8183
#[diesel(table_name = ip_pool)]
8284
pub struct IpPool {
8385
#[diesel(embed)]

0 commit comments

Comments
 (0)