Skip to content

Commit c472464

Browse files
authored
Adding ip pool id to view (#5734)
Fixes #5716 This PR adds the IP Pool's ID to the Floating IP view, so we can use it on the frontend. Adds a few test assertions as well to existing tests.
1 parent cbb8dbf commit c472464

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

nexus/db-model/src/external_ip.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ impl From<FloatingIp> for views::FloatingIp {
590590

591591
views::FloatingIp {
592592
ip: ip.ip.ip(),
593+
ip_pool_id: ip.ip_pool_id,
593594
identity,
594595
project_id: ip.project_id,
595596
instance_id: ip.parent_id,

nexus/tests/integration_tests/external_ips.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ async fn test_floating_ip_create(cptestctx: &ControlPlaneTestContext) {
153153
let client = &cptestctx.external_client;
154154

155155
// automatically linked to current silo
156-
create_default_ip_pool(&client).await;
156+
let default_pool = create_default_ip_pool(&client).await;
157157

158158
assert_ip_pool_utilization(client, "default", 0, 65536, 0, 0).await;
159159

@@ -162,7 +162,8 @@ async fn test_floating_ip_create(cptestctx: &ControlPlaneTestContext) {
162162
.unwrap(),
163163
);
164164
// not automatically linked to currently silo. see below
165-
create_ip_pool(&client, "other-pool", Some(other_pool_range)).await;
165+
let (other_pool, ..) =
166+
create_ip_pool(&client, "other-pool", Some(other_pool_range)).await;
166167

167168
assert_ip_pool_utilization(client, "other-pool", 0, 5, 0, 0).await;
168169

@@ -182,6 +183,7 @@ async fn test_floating_ip_create(cptestctx: &ControlPlaneTestContext) {
182183
assert_eq!(fip.project_id, project.identity.id);
183184
assert_eq!(fip.instance_id, None);
184185
assert_eq!(fip.ip, IpAddr::from(Ipv4Addr::new(10, 0, 0, 0)));
186+
assert_eq!(fip.ip_pool_id, default_pool.identity.id);
185187

186188
assert_ip_pool_utilization(client, "default", 1, 65536, 0, 0).await;
187189

@@ -200,6 +202,7 @@ async fn test_floating_ip_create(cptestctx: &ControlPlaneTestContext) {
200202
assert_eq!(fip.project_id, project.identity.id);
201203
assert_eq!(fip.instance_id, None);
202204
assert_eq!(fip.ip, ip_addr);
205+
assert_eq!(fip.ip_pool_id, default_pool.identity.id);
203206

204207
assert_ip_pool_utilization(client, "default", 2, 65536, 0, 0).await;
205208

@@ -230,10 +233,11 @@ async fn test_floating_ip_create(cptestctx: &ControlPlaneTestContext) {
230233
assert_eq!(fip.project_id, project.identity.id);
231234
assert_eq!(fip.instance_id, None);
232235
assert_eq!(fip.ip, IpAddr::from(Ipv4Addr::new(10, 1, 0, 1)));
236+
assert_eq!(fip.ip_pool_id, other_pool.identity.id);
233237

234238
assert_ip_pool_utilization(client, "other-pool", 1, 5, 0, 0).await;
235239

236-
// Create with chosen IP from fleet-scoped named pool.
240+
// Create with chosen IP from non-default pool.
237241
let fip_name = FIP_NAMES[3];
238242
let ip_addr = "10.1.0.5".parse().unwrap();
239243
let fip = create_floating_ip(
@@ -248,6 +252,7 @@ async fn test_floating_ip_create(cptestctx: &ControlPlaneTestContext) {
248252
assert_eq!(fip.project_id, project.identity.id);
249253
assert_eq!(fip.instance_id, None);
250254
assert_eq!(fip.ip, ip_addr);
255+
assert_eq!(fip.ip_pool_id, other_pool.identity.id);
251256

252257
assert_ip_pool_utilization(client, "other-pool", 2, 5, 0, 0).await;
253258
}

nexus/types/src/external_api/views.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ pub struct FloatingIp {
450450
pub identity: IdentityMetadata,
451451
/// The IP address held by this resource.
452452
pub ip: IpAddr,
453+
/// The ID of the IP pool this resource belongs to.
454+
pub ip_pool_id: Uuid,
453455
/// The project this resource exists within.
454456
pub project_id: Uuid,
455457
/// The ID of the instance that this Floating IP is attached to,

openapi/nexus.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12420,6 +12420,11 @@
1242012420
"type": "string",
1242112421
"format": "ip"
1242212422
},
12423+
"ip_pool_id": {
12424+
"description": "The ID of the IP pool this resource belongs to.",
12425+
"type": "string",
12426+
"format": "uuid"
12427+
},
1242312428
"kind": {
1242412429
"type": "string",
1242512430
"enum": [
@@ -12454,6 +12459,7 @@
1245412459
"description",
1245512460
"id",
1245612461
"ip",
12462+
"ip_pool_id",
1245712463
"kind",
1245812464
"name",
1245912465
"project_id",
@@ -12896,6 +12902,11 @@
1289612902
"type": "string",
1289712903
"format": "ip"
1289812904
},
12905+
"ip_pool_id": {
12906+
"description": "The ID of the IP pool this resource belongs to.",
12907+
"type": "string",
12908+
"format": "uuid"
12909+
},
1289912910
"name": {
1290012911
"description": "unique, mutable, user-controlled identifier for each resource",
1290112912
"allOf": [
@@ -12924,6 +12935,7 @@
1292412935
"description",
1292512936
"id",
1292612937
"ip",
12938+
"ip_pool_id",
1292712939
"name",
1292812940
"project_id",
1292912941
"time_created",

0 commit comments

Comments
 (0)