@@ -48,19 +48,35 @@ pub enum Switch {
4848 SoftNpu ,
4949}
5050
51+ /// Topology of the sleds within the rack.
52+ #[ derive( Clone , Debug , strum:: EnumString , strum:: Display , ValueEnum ) ]
53+ #[ strum( serialize_all = "kebab-case" ) ]
54+ #[ clap( rename_all = "kebab-case" ) ]
55+ pub enum RackTopology {
56+ /// Use configurations suitable for a multi-sled deployment, such as dogfood
57+ /// and production racks.
58+ MultiSled ,
59+
60+ /// Use configurations suitable for a single-sled deployment, such as CI and
61+ /// dev machines.
62+ SingleSled ,
63+ }
64+
5165/// A strongly-typed variant of [Target].
5266#[ derive( Clone , Debug ) ]
5367pub struct KnownTarget {
5468 image : Image ,
5569 machine : Option < Machine > ,
5670 switch : Option < Switch > ,
71+ rack_topology : Option < RackTopology > ,
5772}
5873
5974impl KnownTarget {
6075 pub fn new (
6176 image : Image ,
6277 machine : Option < Machine > ,
6378 switch : Option < Switch > ,
79+ rack_topology : Option < RackTopology > ,
6480 ) -> Result < Self > {
6581 if matches ! ( image, Image :: Trampoline ) {
6682 if machine. is_some ( ) {
@@ -77,7 +93,7 @@ impl KnownTarget {
7793 bail ! ( "'switch=asic' is only valid with 'machine=gimlet'" ) ;
7894 }
7995
80- Ok ( Self { image, machine, switch } )
96+ Ok ( Self { image, machine, switch, rack_topology } )
8197 }
8298}
8399
@@ -87,6 +103,7 @@ impl Default for KnownTarget {
87103 image : Image :: Standard ,
88104 machine : Some ( Machine :: NonGimlet ) ,
89105 switch : Some ( Switch :: Stub ) ,
106+ rack_topology : Some ( RackTopology :: MultiSled ) ,
90107 }
91108 }
92109}
@@ -101,6 +118,9 @@ impl From<KnownTarget> for Target {
101118 if let Some ( switch) = kt. switch {
102119 map. insert ( "switch" . to_string ( ) , switch. to_string ( ) ) ;
103120 }
121+ if let Some ( rack_topology) = kt. rack_topology {
122+ map. insert ( "rack-topology" . to_string ( ) , rack_topology. to_string ( ) ) ;
123+ }
104124 Target ( map)
105125 }
106126}
@@ -121,6 +141,7 @@ impl std::str::FromStr for KnownTarget {
121141 let mut image = Self :: default ( ) . image ;
122142 let mut machine = None ;
123143 let mut switch = None ;
144+ let mut rack_topology = None ;
124145
125146 for ( k, v) in target. 0 . into_iter ( ) {
126147 match k. as_str ( ) {
@@ -133,6 +154,9 @@ impl std::str::FromStr for KnownTarget {
133154 "switch" => {
134155 switch = Some ( v. parse ( ) ?) ;
135156 }
157+ "rack-topology" => {
158+ rack_topology = Some ( v. parse ( ) ?) ;
159+ }
136160 _ => {
137161 bail ! (
138162 "Unknown target key {k}\n Valid keys include: [{}]" ,
@@ -146,6 +170,6 @@ impl std::str::FromStr for KnownTarget {
146170 }
147171 }
148172 }
149- KnownTarget :: new ( image, machine, switch)
173+ KnownTarget :: new ( image, machine, switch, rack_topology )
150174 }
151175}
0 commit comments