1## This Source Code Form is subject to the terms of the Mozilla Public 2## License, v. 2.0. If a copy of the MPL was not distributed with this 3## file, You can obtain one at https://mozilla.org/MPL/2.0/. 4## 5## Copyright (c) 2007-2021 VMware, Inc. or its affiliates. All rights reserved. 6 7defmodule RabbitMQ.CLI.Diagnostics.Commands.DiscoverPeersCommand do 8 @behaviour RabbitMQ.CLI.CommandBehaviour 9 10 use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout 11 use RabbitMQ.CLI.Core.MergesNoDefaults 12 use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments 13 use RabbitMQ.CLI.Core.RequiresRabbitAppRunning 14 15 def run([], %{node: node_name, timeout: timeout}) do 16 :rabbit_misc.rpc_call(node_name, :rabbit_peer_discovery, :discover_cluster_nodes, [], timeout) 17 end 18 19 def output({:ok, {[], _}}, _options) do 20 {:ok, "No peers discovered"} 21 end 22 23 def output({:ok, {nodes, _}}, _options) do 24 {:ok, nodes} 25 end 26 27 use RabbitMQ.CLI.DefaultOutput 28 29 def help_section(), do: :observability_and_health_checks 30 31 def description(), do: "Performs peer discovery and lists discovered nodes, if any" 32 33 def usage, do: "discover_peers" 34 35 def banner(_, _), do: "Discovering peers nodes ..." 36end 37