Skip to content

Commit 7589838

Browse files
committed
Updated grid networks Cmdlets to support profiles
1 parent 20606d3 commit 7589838

1 file changed

Lines changed: 45 additions & 5 deletions

File tree

src/StorageGRID-Webscale.psm1

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7906,7 +7906,7 @@ function Global:Reset-SgwExpansionNode {
79067906

79077907
## expansion-sites ##
79087908

7909-
# complete as of API 2.1
7909+
# complete as of API 2.2
79107910

79117911
<#
79127912
.SYNOPSIS
@@ -8272,24 +8272,42 @@ function Global:Update-SgwExpansionSite {
82728272

82738273
## grid-networks ##
82748274

8275-
# complete as of API 2.1
8275+
# complete as of API 2.2
82768276

82778277
<#
82788278
.SYNOPSIS
82798279
Lists the current Grid Networks
82808280
.DESCRIPTION
82818281
Lists the current Grid Networks
8282+
.PARAMETER Server
8283+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
8284+
.PARAMETER ProfileName
8285+
StorageGRID Profile to use for connection.
82828286
#>
82838287
function Global:Get-SgwGridNetworks {
82848288
[CmdletBinding()]
82858289

82868290
PARAM (
82878291
[parameter(Mandatory = $False,
82888292
Position = 0,
8289-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
8293+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
8294+
[parameter(Mandatory = $False,
8295+
Position = 1,
8296+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName
82908297
)
82918298

82928299
Begin {
8300+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
8301+
$ProfileName = "default"
8302+
}
8303+
if ($ProfileName) {
8304+
$Profile = Get-SgwProfile -ProfileName $ProfileName
8305+
if (!$Profile.Name) {
8306+
Throw "Profile $ProfileName not found. Create a profile using New-SgwProfile or connect to a StorageGRID Server using Connect-SgwServer"
8307+
}
8308+
$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
8309+
}
8310+
82938311
if (!$Server) {
82948312
$Server = $Global:CurrentSgwServer
82958313
}
@@ -8322,6 +8340,14 @@ function Global:Get-SgwGridNetworks {
83228340
Change the Grid Network list
83238341
.DESCRIPTION
83248342
Change the Grid Network list
8343+
.PARAMETER Server
8344+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
8345+
.PARAMETER ProfileName
8346+
StorageGRID Profile to use for connection.
8347+
.PARAMETER Subnets
8348+
List of grid network Subnets in CIDR format (e.g. 10.0.0.0/16).
8349+
.PARAMETER Passphrase
8350+
StorageGRID Passphrase.
83258351
#>
83268352
function Global:Update-SgwGridNetworks {
83278353
[CmdletBinding()]
@@ -8330,15 +8356,29 @@ function Global:Update-SgwGridNetworks {
83308356
[parameter(Mandatory = $False,
83318357
Position = 0,
83328358
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
8333-
[parameter(Mandatory = $True,
8359+
[parameter(Mandatory = $False,
83348360
Position = 1,
8335-
HelpMessage = "List of grid network Subnets in CIDR format (e.g. 10.0.0.0/16).")][String[]]$Subnets,
8361+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName,
83368362
[parameter(Mandatory = $True,
83378363
Position = 2,
8364+
HelpMessage = "List of grid network Subnets in CIDR format (e.g. 10.0.0.0/16).")][String[]]$Subnets,
8365+
[parameter(Mandatory = $True,
8366+
Position = 3,
83388367
HelpMessage = "StorageGRID Passphrase.")][String]$Passphrase
83398368
)
83408369

83418370
Begin {
8371+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
8372+
$ProfileName = "default"
8373+
}
8374+
if ($ProfileName) {
8375+
$Profile = Get-SgwProfile -ProfileName $ProfileName
8376+
if (!$Profile.Name) {
8377+
Throw "Profile $ProfileName not found. Create a profile using New-SgwProfile or connect to a StorageGRID Server using Connect-SgwServer"
8378+
}
8379+
$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
8380+
}
8381+
83428382
if (!$Server) {
83438383
$Server = $Global:CurrentSgwServer
83448384
}

0 commit comments

Comments
 (0)