@@ -20,6 +20,7 @@ use serde::{Deserialize, Serialize};
2020// Export this type for convenience -- this way, dependents don't have to
2121// depend on sled-hardware-types.
2222pub use sled_hardware_types:: Baseboard ;
23+ use strum:: EnumIter ;
2324use uuid:: Uuid ;
2425
2526/// Identifies information about disks which may be attached to Sleds.
@@ -381,7 +382,9 @@ impl OmicronZoneType {
381382/// the four representations if at all possible. If you must add a new one,
382383/// please add it here rather than doing something ad-hoc in the calling code
383384/// so it's more legible.
384- #[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
385+ #[ derive(
386+ Debug , Clone , Copy , PartialEq , Eq , Hash , PartialOrd , Ord , EnumIter ,
387+ ) ]
385388pub enum ZoneKind {
386389 BoundaryNtp ,
387390 Clickhouse ,
@@ -453,7 +456,7 @@ impl ZoneKind {
453456 ZoneKind :: BoundaryNtp | ZoneKind :: InternalNtp => Self :: NTP_PREFIX ,
454457 ZoneKind :: Clickhouse => "clickhouse" ,
455458 ZoneKind :: ClickhouseKeeper => "clickhouse-keeper" ,
456- ZoneKind :: ClickhouseServer => "clickhouse_server " ,
459+ ZoneKind :: ClickhouseServer => "clickhouse-server " ,
457460 // Note "cockroach" for historical reasons.
458461 ZoneKind :: CockroachDb => "cockroach" ,
459462 ZoneKind :: Crucible => "crucible" ,
@@ -486,3 +489,24 @@ impl ZoneKind {
486489 }
487490 }
488491}
492+
493+ #[ cfg( test) ]
494+ mod tests {
495+ use omicron_common:: api:: external:: Name ;
496+ use strum:: IntoEnumIterator ;
497+
498+ use super :: * ;
499+
500+ #[ test]
501+ fn test_name_prefixes ( ) {
502+ for zone_kind in ZoneKind :: iter ( ) {
503+ let name_prefix = zone_kind. name_prefix ( ) ;
504+ name_prefix. parse :: < Name > ( ) . unwrap_or_else ( |e| {
505+ panic ! (
506+ "failed to parse name prefix {:?} for zone kind {:?}: {}" ,
507+ name_prefix, zone_kind, e
508+ ) ;
509+ } ) ;
510+ }
511+ }
512+ }
0 commit comments