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
16 changes: 16 additions & 0 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use crate::api::external::{self, Error};
use crate::policy::INTERNAL_DNS_REDUNDANCY;
use daft::Diffable;
use ipnetwork::Ipv6Network;
use oxnet::{Ipv4Net, Ipv6Net};
use schemars::JsonSchema;
Expand Down Expand Up @@ -273,12 +274,19 @@ pub const SLED_RESERVED_ADDRESSES: u16 = 32;
Eq,
PartialOrd,
Ord,
Diffable,
)]
#[schemars(rename = "Ipv6Subnet")]
pub struct Ipv6Subnet<const N: u8> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, https://docs.rs/oxnet has Ipv6Net but doesn't use a const generic. Nothing to change here but an interesting inconsistency.

net: Ipv6Net,
}

impl<const N: u8> std::fmt::Display for Ipv6Subnet<N> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.net.fmt(f)
}
}

impl<const N: u8> Ipv6Subnet<N> {
pub fn new(addr: Ipv6Addr) -> Self {
// Create a network with the compile-time prefix length.
Expand All @@ -302,6 +310,14 @@ impl<const N: u8> From<Ipv6Network> for Ipv6Subnet<N> {
}
}

impl<const N: u8> From<Ipv6Subnet<N>> for Ipv6Network {
fn from(net: Ipv6Subnet<N>) -> Self {
// Ipv6Subnet::new() asserts that `N` is a valid IPv6 prefix, so it's
// okay to unwrap here.
Self::new(net.net.prefix(), N).unwrap()
}
}

// We need a custom Deserialize to ensure that the subnet is what we expect.
impl<'de, const N: u8> Deserialize<'de> for Ipv6Subnet<N> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
Expand Down
20 changes: 16 additions & 4 deletions dev-tools/omdb/tests/successes.out
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,10 @@ stdout:
blueprint ......<REDACTED_BLUEPRINT_ID>.......
parent: <none>

sled: ..........<REDACTED_UUID>........... (active, config generation 2)
sled: ..........<REDACTED_UUID>...........
state::::::::::::: active
config generation: 2
subnet:::::::::::: ::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -1591,7 +1594,10 @@ parent: <none>



sled: ..........<REDACTED_UUID>........... (active, config generation 2)
sled: ..........<REDACTED_UUID>...........
state::::::::::::: active
config generation: 2
subnet:::::::::::: ::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -1676,7 +1682,10 @@ stdout:
blueprint ......<REDACTED_BLUEPRINT_ID>.......
parent: <none>

sled: ..........<REDACTED_UUID>........... (active, config generation 2)
sled: ..........<REDACTED_UUID>...........
state::::::::::::: active
config generation: 2
subnet:::::::::::: ::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -1715,7 +1724,10 @@ parent: <none>



sled: ..........<REDACTED_UUID>........... (active, config generation 2)
sled: ..........<REDACTED_UUID>...........
state::::::::::::: active
config generation: 2
subnet:::::::::::: ::/64

host phase 2 contents:
------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ planning report:
blueprint 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1
parent: dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21

sled: 00320471-945d-413c-85e7-03e091a70b3c (active, config generation 1)
sled: 00320471-945d-413c-85e7-03e091a70b3c
state::::::::::::: active
config generation: 1
subnet:::::::::::: fd00:1122:3344:104::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -86,7 +89,10 @@ parent: dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21



sled: 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c (active, config generation 2)
sled: 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:102::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -151,7 +157,10 @@ parent: dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21



sled: 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 (active, config generation 2)
sled: 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:101::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -213,7 +222,10 @@ parent: dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21



sled: d81c6a84-79b8-4958-ae41-ea46c9b19763 (active, config generation 2)
sled: d81c6a84-79b8-4958-ae41-ea46c9b19763
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:103::/64

host phase 2 contents:
------------------------
Expand Down
35 changes: 28 additions & 7 deletions dev-tools/reconfigurator-cli/tests/output/cmds-example-stdout
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ zpools (10):
blueprint ade5749d-bdf3-4fab-a8ae-00bea01b3a5a
parent: 02697f74-b14a-4418-90f0-c28b2a3a6aa9

sled: 2eb69596-f081-4e2d-9425-9994926e0832 (active, config generation 2)
sled: 2eb69596-f081-4e2d-9425-9994926e0832
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:102::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -196,7 +199,10 @@ parent: 02697f74-b14a-4418-90f0-c28b2a3a6aa9



sled: 32d8d836-4d8a-4e54-8fa9-f31d79c42646 (active, config generation 2)
sled: 32d8d836-4d8a-4e54-8fa9-f31d79c42646
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:103::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -307,7 +313,10 @@ parent: 02697f74-b14a-4418-90f0-c28b2a3a6aa9



sled: 89d02b1b-478c-401a-8e28-7a26f74fa41b (active, config generation 2)
sled: 89d02b1b-478c-401a-8e28-7a26f74fa41b
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:101::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -497,7 +506,10 @@ zpools (4):
blueprint ade5749d-bdf3-4fab-a8ae-00bea01b3a5a
parent: 02697f74-b14a-4418-90f0-c28b2a3a6aa9

sled: 89d02b1b-478c-401a-8e28-7a26f74fa41b (active, config generation 2)
sled: 89d02b1b-478c-401a-8e28-7a26f74fa41b
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:101::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -1151,7 +1163,10 @@ T ENA ID PARENT
blueprint ade5749d-bdf3-4fab-a8ae-00bea01b3a5a
parent: 02697f74-b14a-4418-90f0-c28b2a3a6aa9

sled: 2eb69596-f081-4e2d-9425-9994926e0832 (active, config generation 2)
sled: 2eb69596-f081-4e2d-9425-9994926e0832
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:102::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -1203,7 +1218,10 @@ parent: 02697f74-b14a-4418-90f0-c28b2a3a6aa9



sled: 32d8d836-4d8a-4e54-8fa9-f31d79c42646 (active, config generation 2)
sled: 32d8d836-4d8a-4e54-8fa9-f31d79c42646
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:103::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -1255,7 +1273,10 @@ parent: 02697f74-b14a-4418-90f0-c28b2a3a6aa9



sled: 89d02b1b-478c-401a-8e28-7a26f74fa41b (active, config generation 2)
sled: 89d02b1b-478c-401a-8e28-7a26f74fa41b
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:101::/64

host phase 2 contents:
------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ loaded example system with:
blueprint 3f00b694-1b16-4aaa-8f78-e6b3a527b434
parent: 06c88262-f435-410e-ba98-101bed41ec27

sled: 711ac7f8-d19e-4572-bdb9-e9b50f6e362a (active, config generation 2)
sled: 711ac7f8-d19e-4572-bdb9-e9b50f6e362a
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:103::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -125,7 +128,10 @@ parent: 06c88262-f435-410e-ba98-101bed41ec27



sled: 9dc50690-f9bf-4520-bf80-051d0f465c2c (active, config generation 2)
sled: 9dc50690-f9bf-4520-bf80-051d0f465c2c
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:102::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -236,7 +242,10 @@ parent: 06c88262-f435-410e-ba98-101bed41ec27



sled: a88790de-5962-4871-8686-61c1fd5b7094 (active, config generation 2)
sled: a88790de-5962-4871-8686-61c1fd5b7094
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:101::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -549,7 +558,10 @@ external DNS:
blueprint 366b0b68-d80e-4bc1-abd3-dc69837847e0
parent: 3f00b694-1b16-4aaa-8f78-e6b3a527b434

sled: 711ac7f8-d19e-4572-bdb9-e9b50f6e362a (active, config generation 3)
sled: 711ac7f8-d19e-4572-bdb9-e9b50f6e362a
state::::::::::::: active
config generation: 3
subnet:::::::::::: fd00:1122:3344:103::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -663,7 +675,10 @@ parent: 3f00b694-1b16-4aaa-8f78-e6b3a527b434



sled: 9dc50690-f9bf-4520-bf80-051d0f465c2c (active, config generation 2)
sled: 9dc50690-f9bf-4520-bf80-051d0f465c2c
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:102::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -774,7 +789,10 @@ parent: 3f00b694-1b16-4aaa-8f78-e6b3a527b434



sled: a88790de-5962-4871-8686-61c1fd5b7094 (active, config generation 2)
sled: a88790de-5962-4871-8686-61c1fd5b7094
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:101::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -1112,7 +1130,10 @@ external DNS:
blueprint 9c998c1d-1a7b-440a-ae0c-40f781dea6e2
parent: 366b0b68-d80e-4bc1-abd3-dc69837847e0

sled: 711ac7f8-d19e-4572-bdb9-e9b50f6e362a (active, config generation 4)
sled: 711ac7f8-d19e-4572-bdb9-e9b50f6e362a
state::::::::::::: active
config generation: 4
subnet:::::::::::: fd00:1122:3344:103::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -1229,7 +1250,10 @@ parent: 366b0b68-d80e-4bc1-abd3-dc69837847e0



sled: 9dc50690-f9bf-4520-bf80-051d0f465c2c (active, config generation 2)
sled: 9dc50690-f9bf-4520-bf80-051d0f465c2c
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:102::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -1340,7 +1364,10 @@ parent: 366b0b68-d80e-4bc1-abd3-dc69837847e0



sled: a88790de-5962-4871-8686-61c1fd5b7094 (active, config generation 2)
sled: a88790de-5962-4871-8686-61c1fd5b7094
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:101::/64

host phase 2 contents:
------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ loaded example system with:
blueprint dbcbd3d6-41ff-48ae-ac0b-1becc9b2fd21
parent: 184f10b3-61cb-41ef-9b93-3489b2bac559

sled: 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c (active, config generation 2)
sled: 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:102::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -123,7 +126,10 @@ parent: 184f10b3-61cb-41ef-9b93-3489b2bac559



sled: 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 (active, config generation 2)
sled: 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:101::/64

host phase 2 contents:
------------------------
Expand Down Expand Up @@ -234,7 +240,10 @@ parent: 184f10b3-61cb-41ef-9b93-3489b2bac559



sled: d81c6a84-79b8-4958-ae41-ea46c9b19763 (active, config generation 2)
sled: d81c6a84-79b8-4958-ae41-ea46c9b19763
state::::::::::::: active
config generation: 2
subnet:::::::::::: fd00:1122:3344:103::/64

host phase 2 contents:
------------------------
Expand Down
Loading
Loading