@@ -15,14 +15,14 @@ use colored::*;
15
15
use structopt:: * ;
16
16
use tabwriter:: TabWriter ;
17
17
18
- use common:: ports:: PortId ;
18
+ use common:: ports:: { PortId , QsfpPort } ;
19
19
use dpd_client:: types:: {
20
20
self , CmisDatapath , CmisLaneStatus , Sff8636Datapath , SffComplianceCode ,
21
21
} ;
22
22
use dpd_client:: Client ;
23
23
24
- use crate :: parse_port_id;
25
24
use crate :: LinkPath ;
25
+ use crate :: { parse_port_id, parse_qsfp_port_id} ;
26
26
27
27
// Newtype needed to convince `structopt` to parse a list of fields.
28
28
#[ derive( Clone , Debug ) ]
@@ -164,6 +164,37 @@ pub enum SwitchPort {
164
164
Transceiver ( Transceiver ) ,
165
165
/// Manage the attention LEDs on the Sidecar QSFP switch ports.
166
166
Led ( Led ) ,
167
+ /// Get the management mode for a switch port's transceiver.
168
+ ///
169
+ /// In most situations, QSFP switch ports are managed automatically, meaning
170
+ /// their power is controlled autonomously. The modules will remain in low
171
+ /// power until a link is created on them. Modules will also be turned off
172
+ /// if they cannot be supported.
173
+ ///
174
+ /// Modules may be turned to manual management mode, which allows the
175
+ /// operator to explicitly control their power. The software will not change
176
+ /// the power of such a module automatically.
177
+ #[ structopt( visible_aliases = & [ "mgmt" , "mode" ] ) ]
178
+ ManagementMode {
179
+ /// The QSFP port to operate on.
180
+ #[ structopt( parse( try_from_str = parse_qsfp_port_id) ) ]
181
+ port_id : QsfpPort ,
182
+ } ,
183
+ /// Set the management mode for a switch port's transceiver.
184
+ ///
185
+ /// See the help for `management-mode` for details.
186
+ #[ structopt( visible_aliases = & [ "set-mgmt" , "set-mode" ] ) ]
187
+ SetManagementMode {
188
+ /// The QSFP port to operate on.
189
+ #[ structopt( parse( try_from_str = parse_qsfp_port_id) ) ]
190
+ port_id : QsfpPort ,
191
+ /// The management mode to set the port to.
192
+ #[ structopt(
193
+ possible_values = & [ "automatic" , "auto" , "manual" ] ,
194
+ parse( try_from_str = parse_management_mode)
195
+ ) ]
196
+ mode : types:: ManagementMode ,
197
+ } ,
167
198
/// Return the backplane map.
168
199
BackplaneMap {
169
200
/// If true, provide parseable ouptut, separated by a `,`.
@@ -222,37 +253,6 @@ pub enum Transceiver {
222
253
#[ structopt( parse( try_from_str = parse_port_id) ) ]
223
254
port_id : PortId ,
224
255
} ,
225
- /// Get the management mode for the transceiver.
226
- ///
227
- /// In most situations, QSFP switch ports are managed automatically, meaning
228
- /// their power is controlled autonomously. The modules will remain in low
229
- /// power until a link is created on them. Modules will also be turned off
230
- /// if they cannot be supported.
231
- ///
232
- /// Modules may be turned to manual management mode, which allows the
233
- /// operator to explicitly control their power. The software will not change
234
- /// the power of such a module automatically.
235
- #[ structopt( visible_alias = "mgmt" ) ]
236
- ManagementMode {
237
- /// The QSFP port to operate on.
238
- #[ structopt( parse( try_from_str = parse_port_id) ) ]
239
- port_id : PortId ,
240
- } ,
241
- /// Set the management mode for the transceiver.
242
- ///
243
- /// See the help for `management-mode` for details.
244
- #[ structopt( visible_alias = "set-mgmt" ) ]
245
- SetManagementMode {
246
- /// The QSFP port to operate on.
247
- #[ structopt( parse( try_from_str = parse_port_id) ) ]
248
- port_id : PortId ,
249
- /// The management mode to set the port to.
250
- #[ structopt(
251
- possible_values = & [ "automatic" , "auto" , "manual" ] ,
252
- parse( try_from_str = parse_management_mode)
253
- ) ]
254
- mode : types:: ManagementMode ,
255
- } ,
256
256
}
257
257
258
258
fn parse_management_mode ( s : & str ) -> anyhow:: Result < types:: ManagementMode > {
@@ -614,13 +614,6 @@ async fn transceivers_cmd(
614
614
println ! ( "{:>WIDTH$}: {UNSUPPORTED}" , "Aux 3" ) ;
615
615
}
616
616
}
617
- Transceiver :: ManagementMode { port_id } => {
618
- let mode = client. management_mode_get ( & port_id) . await ?. into_inner ( ) ;
619
- println ! ( "{mode:?}" ) ;
620
- }
621
- Transceiver :: SetManagementMode { port_id, mode } => {
622
- client. management_mode_set ( & port_id, mode) . await ?;
623
- }
624
617
Transceiver :: Datapath { port_id } => {
625
618
let datapath = client
626
619
. transceiver_datapath_get ( & port_id)
@@ -932,6 +925,18 @@ pub async fn switch_cmd(
932
925
}
933
926
}
934
927
SwitchPort :: Transceiver ( xcvr) => transceivers_cmd ( client, xcvr) . await ?,
928
+ SwitchPort :: ManagementMode { port_id } => {
929
+ let mode = client
930
+ . management_mode_get ( & PortId :: Qsfp ( port_id) )
931
+ . await ?
932
+ . into_inner ( ) ;
933
+ println ! ( "{mode:?}" ) ;
934
+ }
935
+ SwitchPort :: SetManagementMode { port_id, mode } => {
936
+ client
937
+ . management_mode_set ( & PortId :: Qsfp ( port_id) , mode)
938
+ . await ?;
939
+ }
935
940
SwitchPort :: Led ( led) => led_cmd ( client, led) . await ?,
936
941
SwitchPort :: BackplaneMap {
937
942
parseable,
0 commit comments