@@ -32,7 +32,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClusterStatusCommand do
32
32
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
33
33
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
34
34
35
- def run ( [ ] , % { node: node_name , timeout: timeout } ) do
35
+ def run ( [ ] , % { node: node_name , timeout: timeout } = opts ) do
36
36
status =
37
37
case :rabbit_misc . rpc_call ( node_name , :rabbit_db_cluster , :cli_cluster_status , [ ] ) do
38
38
{ :badrpc , { :EXIT , { :undef , _ } } } ->
@@ -72,7 +72,7 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClusterStatusCommand do
72
72
maintenance_status_by_node =
73
73
Enum . map (
74
74
nodes ,
75
- fn n -> maintenance_status_by_node ( n , per_node_timeout ( timeout , count ) ) end
75
+ fn n -> maintenance_status_by_node ( n , per_node_timeout ( timeout , count ) , opts ) end
76
76
)
77
77
78
78
cpu_cores_by_node =
@@ -340,26 +340,26 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ClusterStatusCommand do
340
340
} }
341
341
end
342
342
343
- defp maintenance_status_by_node ( node , timeout ) do
343
+ defp maintenance_status_by_node ( node , timeout , opts ) do
344
344
target = to_atom ( node )
345
+ formatter = Map . get ( opts , :formatter )
346
+
347
+ rpc_result =
348
+ :rabbit_misc . rpc_call ( target , :rabbit_maintenance , :status_local_read , [ target ] , timeout )
345
349
346
350
result =
347
- case :rabbit_misc . rpc_call (
348
- target ,
349
- :rabbit_maintenance ,
350
- :status_local_read ,
351
- [ target ] ,
352
- timeout
353
- ) do
354
- { :badrpc , _ } -> "unknown"
355
- :regular -> "not under maintenance"
356
- :draining -> magenta ( "marked for maintenance" )
351
+ case { rpc_result , formatter } do
352
+ { { :badrpc , _ } , _ } -> "unknown"
353
+ { :regular , _ } -> "not under maintenance"
354
+ { :draining , "json" } -> "marked for maintenance"
355
+ { :draining , _ } -> magenta ( "marked for maintenance" )
357
356
# forward compatibility: should we figure out a way to know when
358
357
# draining completes (it involves inherently asynchronous cluster
359
358
# operations such as quorum queue leader re-election), we'd introduce
360
359
# a new state
361
- :drained -> magenta ( "marked for maintenance" )
362
- value -> to_string ( value )
360
+ { :drained , "json" } -> "marked for maintenance"
361
+ { :drained , _ } -> magenta ( "marked for maintenance" )
362
+ { value , _ } -> to_string ( value )
363
363
end
364
364
365
365
{ node , result }
0 commit comments