Skip to content

Commit 98e4d4c

Browse files
committed
Updated and improved health Cmdlets
1 parent 2928e98 commit 98e4d4c

1 file changed

Lines changed: 50 additions & 3 deletions

File tree

src/StorageGRID-Webscale.psm1

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11654,24 +11654,42 @@ function Global:Get-SgwAccountGroups {
1165411654

1165511655
## health ##
1165611656

11657-
# complete as of API 2.1
11657+
# complete as of API 2.2
1165811658

1165911659
<#
1166011660
.SYNOPSIS
1166111661
Retrieve StorageGRID Health Status
1166211662
.DESCRIPTION
1166311663
Retrieve StorageGRID Health Status
11664+
.PARAMETER Server
11665+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
11666+
.PARAMETER ProfileName
11667+
StorageGRID Profile to use for connection.
1166411668
#>
1166511669
function Global:Get-SgwHealth {
1166611670
[CmdletBinding()]
1166711671

1166811672
PARAM (
1166911673
[parameter(Mandatory = $False,
1167011674
Position = 0,
11671-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
11675+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
11676+
[parameter(Mandatory = $False,
11677+
Position = 1,
11678+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName
1167211679
)
1167311680

1167411681
Begin {
11682+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
11683+
$ProfileName = "default"
11684+
}
11685+
if ($ProfileName) {
11686+
$Profile = Get-SgwProfile -ProfileName $ProfileName
11687+
if (!$Profile.Name) {
11688+
Throw "Profile $ProfileName not found. Create a profile using New-SgwProfile or connect to a StorageGRID Server using Connect-SgwServer"
11689+
}
11690+
$Server = Connect-SgwServer -Name $Profile.Name -Credential $Profile.Credential -AccountId $Profile.AccountId -SkipCertificateCheck:$Profile.SkipCertificateCheck -DisableAutomaticAccessKeyGeneration:$Profile.disalble_automatic_access_key_generation -TemporaryAccessKeyExpirationTime $Profile.temporary_access_key_expiration_time -S3EndpointUrl $Profile.S3EndpointUrl -SwiftEndpointUrl $Profile.SwiftEndpointUrl -Transient
11691+
}
11692+
1167511693
if (!$Server) {
1167611694
$Server = $Global:CurrentSgwServer
1167711695
}
@@ -11699,11 +11717,18 @@ function Global:Get-SgwHealth {
1169911717
}
1170011718
}
1170111719

11720+
Set-Alias -Name Get-SgwTopology -Value Get-SgwTopologyHealth
1170211721
<#
1170311722
.SYNOPSIS
1170411723
Retrieve StorageGRID Topology with Health Status
1170511724
.DESCRIPTION
1170611725
Retrieve StorageGRID Topology with Health Status
11726+
.PARAMETER Server
11727+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
11728+
.PARAMETER ProfileName
11729+
StorageGRID Profile to use for connection.
11730+
.PARAMETER Depth
11731+
Topology depth level to provide (default=node).
1170711732
#>
1170811733
function Global:Get-SgwTopologyHealth {
1170911734
[CmdletBinding()]
@@ -11712,12 +11737,26 @@ function Global:Get-SgwTopologyHealth {
1171211737
[parameter(Mandatory = $False,
1171311738
Position = 0,
1171411739
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
11740+
[parameter(Mandatory = $False,
11741+
Position = 1,
11742+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName,
1171511743
[parameter(Mandatory = $False,
1171611744
Position = 0,
1171711745
HelpMessage = "Topology depth level to provide (default=node).")][String][ValidateSet("grid", "site", "node", "component", "subcomponent")]$Depth = "node"
1171811746
)
1171911747

1172011748
Begin {
11749+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
11750+
$ProfileName = "default"
11751+
}
11752+
if ($ProfileName) {
11753+
$Profile = Get-SgwProfile -ProfileName $ProfileName
11754+
if (!$Profile.Name) {
11755+
Throw "Profile $ProfileName not found. Create a profile using New-SgwProfile or connect to a StorageGRID Server using Connect-SgwServer"
11756+
}
11757+
$Server = Connect-SgwServer -Name $Profile.Name -Credential $Profile.Credential -AccountId $Profile.AccountId -SkipCertificateCheck:$Profile.SkipCertificateCheck -DisableAutomaticAccessKeyGeneration:$Profile.disalble_automatic_access_key_generation -TemporaryAccessKeyExpirationTime $Profile.temporary_access_key_expiration_time -S3EndpointUrl $Profile.S3EndpointUrl -SwiftEndpointUrl $Profile.SwiftEndpointUrl -Transient
11758+
}
11759+
1172111760
if (!$Server) {
1172211761
$Server = $Global:CurrentSgwServer
1172311762
}
@@ -11741,7 +11780,15 @@ function Global:Get-SgwTopologyHealth {
1174111780
Throw "$Method to $Uri failed with Exception $( $_.Exception.Message ) `n $responseBody"
1174211781
}
1174311782

11744-
Write-Output $Response.Json.data
11783+
$Topology = $Response.Json.data
11784+
if ($Depth -match "site|node|component") {
11785+
$Topology | Add-Member -MemberType ScriptProperty -Name Sites -Value { $this.children }
11786+
}
11787+
if ($Depth -match "node","component") {
11788+
$Topology | Add-Member -MemberType ScriptProperty -Name Nodes -Value { $this.children.children }
11789+
}
11790+
11791+
Write-Output $Topology
1174511792
}
1174611793
}
1174711794

0 commit comments

Comments
 (0)