forked from RamblingCookieMonster/RabbitMQTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-RabbitMQNode.ps1
More file actions
89 lines (65 loc) · 2.53 KB
/
Get-RabbitMQNode.ps1
File metadata and controls
89 lines (65 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<#
.Synopsis
Gets RabbitMQ Nodes.
.DESCRIPTION
The Get-RabbitMQNode cmdlet gets nodes in RabbitMQ cluster.
The cmdlet allows you to show list of cluster nodes or filter them by name using wildcards.
The result may be zero, one or many RabbitMQ.Node objects.
To get Nodes from remote server you need to provide -HostName parameter.
The cmdlet is using REST Api provided by RabbitMQ Management Plugin. For more information go to: https://www.rabbitmq.com/management.html
.EXAMPLE
Get-RabbitMQNode
This command gets a list of nodes in RabbitMQ cluster.
.EXAMPLE
Get-RabbitMQNode -HostName myrabbitmq.servers.com
This command gets a list of nodes in the cluster on myrabbitmq.servers.com server.
.EXAMPLE
Get-RabbitMQNode second*
This command gets a list of nodes in a cluster which name starts with "second".
.EXAMPLE
Get-RabbitMQNode secondary*, primary
This command gets cluster nodes which name is either "primary" or starts with "secondary".
.EXAMPLE
@("primary", "secondary") | Get-RabbitMQNode
This command pipes node name filters to Get-RabbitMQNode cmdlet.
.INPUTS
You can pipe Name to filter the results.
.OUTPUTS
By default, the cmdlet returns list of RabbitMQ.Node objects which describe cluster nodes.
.LINK
https://www.rabbitmq.com/management.html - information about RabbitMQ management plugin.
#>
function Get-RabbitMQNode
{
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='None')]
Param
(
# Name of RabbitMQ Node.
[parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[Alias("Node", "NodeName")]
[string[]]$Name = "",
# Name of the computer hosting RabbitMQ server. Defalut value is localhost.
[parameter(ValueFromPipelineByPropertyName=$true)]
[Alias("HostName", "hn", "cn")]
[string]$BaseUri = $defaultComputerName,
# Credentials to use when logging to RabbitMQ server.
[Parameter(Mandatory=$false)]
[PSCredential]$Credentials = $defaultCredentials
)
Begin
{
}
Process
{
if ($pscmdlet.ShouldProcess("server $BaseUri", "Get node(s): $(NamesToString $Name '(all)')"))
{
$result = GetItemsFromRabbitMQApi -BaseUri $BaseUri $Credentials "nodes"
$result = ApplyFilter $result 'name' $Name
$result | Add-Member -NotePropertyName "HostName" -NotePropertyValue $BaseUri
SendItemsToOutput $result "RabbitMQ.Node"
}
}
End
{
}
}