-
Notifications
You must be signed in to change notification settings - Fork 52
/
GetStormTopologySummary.ps1
46 lines (38 loc) · 1.85 KB
/
GetStormTopologySummary.ps1
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
[CmdletBinding(PositionalBinding=$True)]
Param(
[Parameter(Mandatory = $true)]
[String]$ClusterUrl,
[Parameter(Mandatory = $true)]
[String]$ClusterUsername,
[Parameter(Mandatory = $true)]
[String]$ClusterPassword,
[Parameter(Mandatory = $true)]
[String]$TopologyName
)
###########################################################
# Start - Initialization - Invocation, Logging etc
###########################################################
$VerbosePreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
$scriptPath = $MyInvocation.MyCommand.Path
$scriptDir = Split-Path $scriptPath
& "$scriptDir\..\init.ps1"
if(-not $?)
{
throw "Initialization failure."
exit -9999
}
###########################################################
# End - Initialization - Invocation, Logging etc
###########################################################
$secureClusterPassword = ConvertTo-SecureString $ClusterPassword -AsPlainText -Force
$clusterCreds = New-Object System.Management.Automation.PSCredential ($ClusterUsername, $secureClusterPassword)
$clusterUri = new-object Uri($ClusterUrl)
$topologySummaryUri = new-object Uri($clusterUri, "stormui/api/v1/topology/summary")
$response = Invoke-RestMethod -Uri $topologySummaryUri.AbsoluteUri -Method Get -Credential $clusterCreds
$response = $response.topologies | Out-String
Write-InfoLog ("Topology Summary: " + $topologySummaryUri.AbsoluteUri + "`r`n" + $response) (Get-ScriptName) (Get-ScriptLineNumber)
$topology = $response.topologies | ? { $_.Name -eq $TopologyName }
$topologyUri = new-object Uri($clusterUri, "stormui/api/v1/topology/" + $topology.Id)
$response = Invoke-RestMethod -Uri $topologyUri.AbsoluteUri -Method Get -Credential $clusterCreds
Write-InfoLog ("$TopologyName Topology Summary: " + $topologyUri.AbsoluteUri + "`r`n" + $response) (Get-ScriptName) (Get-ScriptLineNumber)