@@ -196,6 +196,16 @@ pub fn subcommands() -> Command {
196
196
. help ( "uuid of nexus" ) ,
197
197
) ;
198
198
199
+ let resize = Command :: new ( "resize" )
200
+ . about ( "Resize nexus" )
201
+ . arg ( Arg :: new ( "uuid" ) . required ( true ) . index ( 1 ) . help ( "Nexus uuid" ) )
202
+ . arg (
203
+ Arg :: new ( "size" )
204
+ . required ( true )
205
+ . index ( 2 )
206
+ . help ( "Requested new size of the nexus" ) ,
207
+ ) ;
208
+
199
209
Command :: new ( "nexus" )
200
210
. subcommand_required ( true )
201
211
. arg_required_else_help ( true )
@@ -210,6 +220,7 @@ pub fn subcommands() -> Command {
210
220
. subcommand ( ana_state)
211
221
. subcommand ( list)
212
222
. subcommand ( children)
223
+ . subcommand ( resize)
213
224
. subcommand ( nexus_child_cli:: subcommands ( ) )
214
225
}
215
226
@@ -220,6 +231,7 @@ pub async fn handler(ctx: Context, matches: &ArgMatches) -> crate::Result<()> {
220
231
( "shutdown" , args) => nexus_shutdown ( ctx, args) . await ,
221
232
( "list" , args) => nexus_list ( ctx, args) . await ,
222
233
( "children" , args) => nexus_children_2 ( ctx, args) . await ,
234
+ ( "resize" , args) => nexus_resize ( ctx, args) . await ,
223
235
( "publish" , args) => nexus_publish ( ctx, args) . await ,
224
236
( "unpublish" , args) => nexus_unpublish ( ctx, args) . await ,
225
237
( "ana_state" , args) => nexus_nvme_ana_state ( ctx, args) . await ,
@@ -564,6 +576,54 @@ async fn nexus_children_2(
564
576
Ok ( ( ) )
565
577
}
566
578
579
+ async fn nexus_resize (
580
+ mut ctx : Context ,
581
+ matches : & ArgMatches ,
582
+ ) -> crate :: Result < ( ) > {
583
+ let uuid = matches
584
+ . get_one :: < String > ( "uuid" )
585
+ . ok_or_else ( || ClientError :: MissingValue {
586
+ field : "uuid" . to_string ( ) ,
587
+ } ) ?
588
+ . to_owned ( ) ;
589
+
590
+ let requested_size =
591
+ parse_size ( matches. get_one :: < String > ( "size" ) . ok_or_else ( || {
592
+ ClientError :: MissingValue {
593
+ field : "size" . to_string ( ) ,
594
+ }
595
+ } ) ?)
596
+ . map_err ( |s| Status :: invalid_argument ( format ! ( "Bad size '{s}'" ) ) )
597
+ . context ( GrpcStatus ) ?;
598
+
599
+ let response = ctx
600
+ . v1
601
+ . nexus
602
+ . resize_nexus ( v1:: nexus:: ResizeNexusRequest {
603
+ uuid : uuid. clone ( ) ,
604
+ requested_size : requested_size. get_bytes ( ) as u64 ,
605
+ } )
606
+ . await
607
+ . context ( GrpcStatus ) ?;
608
+
609
+ match ctx. output {
610
+ OutputFormat :: Json => {
611
+ println ! (
612
+ "{}" ,
613
+ serde_json:: to_string_pretty( & response. get_ref( ) )
614
+ . unwrap( )
615
+ . to_colored_json_auto( )
616
+ . unwrap( )
617
+ ) ;
618
+ }
619
+ OutputFormat :: Default => {
620
+ println ! ( "Resized nexus {uuid} to {requested_size}" ) ;
621
+ }
622
+ } ;
623
+
624
+ Ok ( ( ) )
625
+ }
626
+
567
627
async fn nexus_publish (
568
628
mut ctx : Context ,
569
629
matches : & ArgMatches ,
0 commit comments