Skip to content

Commit 2d5ca0e

Browse files
committed
Updated and fixed Expansion Site Cmdlets
1 parent cc9a9c1 commit 2d5ca0e

1 file changed

Lines changed: 141 additions & 30 deletions

File tree

src/StorageGRID-Webscale.psm1

Lines changed: 141 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7840,6 +7840,12 @@ function Global:Remove-SgwExpansionNode {
78407840
Resets a grid node's configuration and returns it back to pending state
78417841
.DESCRIPTION
78427842
Resets a grid node's configuration and returns it back to pending state
7843+
.PARAMETER Server
7844+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
7845+
.PARAMETER ProfileName
7846+
StorageGRID Profile to use for connection.
7847+
.PARAMETER Id
7848+
ID of a StorageGRID node eligible for expansion.
78437849
#>
78447850
function Global:Reset-SgwExpansionNode {
78457851
[CmdletBinding()]
@@ -7907,17 +7913,35 @@ function Global:Reset-SgwExpansionNode {
79077913
Retrieves the list of existing and new sites (empty until expansion is started)
79087914
.DESCRIPTION
79097915
Retrieves the list of existing and new sites (empty until expansion is started)
7916+
.PARAMETER Server
7917+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
7918+
.PARAMETER ProfileName
7919+
StorageGRID Profile to use for connection.
79107920
#>
79117921
function Global:Get-SgwExpansionSites {
79127922
[CmdletBinding()]
79137923

79147924
PARAM (
79157925
[parameter(Mandatory = $False,
79167926
Position = 0,
7917-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
7927+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
7928+
[parameter(Mandatory = $False,
7929+
Position = 1,
7930+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName
79187931
)
79197932

79207933
Begin {
7934+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
7935+
$ProfileName = "default"
7936+
}
7937+
if ($ProfileName) {
7938+
$Profile = Get-SgwProfile -ProfileName $ProfileName
7939+
if (!$Profile.Name) {
7940+
Throw "Profile $ProfileName not found. Create a profile using New-SgwProfile or connect to a StorageGRID Server using Connect-SgwServer"
7941+
}
7942+
$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
7943+
}
7944+
79217945
if (!$Server) {
79227946
$Server = $Global:CurrentSgwServer
79237947
}
@@ -7950,23 +7974,43 @@ function Global:Get-SgwExpansionSites {
79507974
Adds a new site
79517975
.DESCRIPTION
79527976
Adds a new site
7977+
.PARAMETER Server
7978+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
7979+
.PARAMETER ProfileName
7980+
StorageGRID Profile to use for connection.
7981+
.PARAMETER Name
7982+
Name of the new site
79537983
#>
79547984
function Global:New-SgwExpansionSite {
79557985
[CmdletBinding()]
79567986

79577987
PARAM (
7988+
[parameter(Mandatory = $False,
7989+
Position = 0,
7990+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
7991+
[parameter(Mandatory = $False,
7992+
Position = 1,
7993+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName,
79587994
[parameter(
79597995
Mandatory = $True,
7960-
Position = 0,
7961-
HelpMessage = "Name of new site.",
7996+
Position = 2,
7997+
HelpMessage = "Name of the new site.",
79627998
ValueFromPipeline = $True,
7963-
ValueFromPipelineByPropertyName = $True)][String]$Name,
7964-
[parameter(Mandatory = $False,
7965-
Position = 0,
7966-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
7999+
ValueFromPipelineByPropertyName = $True)][String]$Name
79678000
)
79688001

79698002
Begin {
8003+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
8004+
$ProfileName = "default"
8005+
}
8006+
if ($ProfileName) {
8007+
$Profile = Get-SgwProfile -ProfileName $ProfileName
8008+
if (!$Profile.Name) {
8009+
Throw "Profile $ProfileName not found. Create a profile using New-SgwProfile or connect to a StorageGRID Server using Connect-SgwServer"
8010+
}
8011+
$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
8012+
}
8013+
79708014
if (!$Server) {
79718015
$Server = $Global:CurrentSgwServer
79728016
}
@@ -7979,7 +8023,7 @@ function Global:New-SgwExpansionSite {
79798023
}
79808024

79818025
Process {
7982-
$Uri = $Server.BaseURI + "/grid/expansion/site"
8026+
$Uri = $Server.BaseURI + "/grid/expansion/sites"
79838027
$Method = "POST"
79848028

79858029
$Body = ConvertTo-Json -InputObject @{ name = $Name }
@@ -8001,23 +8045,43 @@ function Global:New-SgwExpansionSite {
80018045
Delete a site
80028046
.DESCRIPTION
80038047
Delete a site
8048+
.PARAMETER Server
8049+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
8050+
.PARAMETER ProfileName
8051+
StorageGRID Profile to use for connection.
8052+
.PARAMETER Id
8053+
ID of a StorageGRID Webscale site to remove from expansion.
80048054
#>
80058055
function Global:Remove-SgwExpansionSite {
80068056
[CmdletBinding()]
80078057

80088058
PARAM (
8059+
[parameter(Mandatory = $False,
8060+
Position = 0,
8061+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
8062+
[parameter(Mandatory = $False,
8063+
Position = 1,
8064+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName,
80098065
[parameter(
80108066
Mandatory = $True,
8011-
Position = 0,
8067+
Position = 2,
80128068
HelpMessage = "ID of a StorageGRID Webscale site to remove from expansion.",
80138069
ValueFromPipeline = $True,
8014-
ValueFromPipelineByPropertyName = $True)][String]$id,
8015-
[parameter(Mandatory = $False,
8016-
Position = 1,
8017-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
8070+
ValueFromPipelineByPropertyName = $True)][String]$Id
80188071
)
80198072

80208073
Begin {
8074+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
8075+
$ProfileName = "default"
8076+
}
8077+
if ($ProfileName) {
8078+
$Profile = Get-SgwProfile -ProfileName $ProfileName
8079+
if (!$Profile.Name) {
8080+
Throw "Profile $ProfileName not found. Create a profile using New-SgwProfile or connect to a StorageGRID Server using Connect-SgwServer"
8081+
}
8082+
$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
8083+
}
8084+
80218085
if (!$Server) {
80228086
$Server = $Global:CurrentSgwServer
80238087
}
@@ -8050,23 +8114,43 @@ function Global:Remove-SgwExpansionSite {
80508114
Retrieve a site
80518115
.DESCRIPTION
80528116
Retrieve a site
8117+
.PARAMETER Server
8118+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
8119+
.PARAMETER ProfileName
8120+
StorageGRID Profile to use for connection.
8121+
.PARAMETER Id
8122+
ID of a StorageGRID Webscale site.
80538123
#>
80548124
function Global:Get-SgwExpansionSite {
80558125
[CmdletBinding()]
80568126

80578127
PARAM (
8128+
[parameter(Mandatory = $False,
8129+
Position = 0,
8130+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
8131+
[parameter(Mandatory = $False,
8132+
Position = 1,
8133+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName,
80588134
[parameter(
80598135
Mandatory = $True,
8060-
Position = 0,
8061-
HelpMessage = "ID of a StorageGRID site.",
8136+
Position = 2,
8137+
HelpMessage = "ID of a StorageGRID Webscale site.",
80628138
ValueFromPipeline = $True,
8063-
ValueFromPipelineByPropertyName = $True)][String]$id,
8064-
[parameter(Mandatory = $False,
8065-
Position = 0,
8066-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
8139+
ValueFromPipelineByPropertyName = $True)][String]$id
80678140
)
80688141

80698142
Begin {
8143+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
8144+
$ProfileName = "default"
8145+
}
8146+
if ($ProfileName) {
8147+
$Profile = Get-SgwProfile -ProfileName $ProfileName
8148+
if (!$Profile.Name) {
8149+
Throw "Profile $ProfileName not found. Create a profile using New-SgwProfile or connect to a StorageGRID Server using Connect-SgwServer"
8150+
}
8151+
$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
8152+
}
8153+
80708154
if (!$Server) {
80718155
$Server = $Global:CurrentSgwServer
80728156
}
@@ -8099,29 +8183,53 @@ function Global:Get-SgwExpansionSite {
80998183
Updates the details of a site
81008184
.DESCRIPTION
81018185
Updates the details of a site
8186+
.PARAMETER Server
8187+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
8188+
.PARAMETER ProfileName
8189+
StorageGRID Profile to use for connection.
8190+
.PARAMETER Id
8191+
ID of a StorageGRID site to be updated.
8192+
.PARAMETER NewId
8193+
New ID for the StorageGRID site.
8194+
.PARAMETER Name
8195+
New name for the StorageGRID site.
81028196
#>
81038197
function Global:Update-SgwExpansionSite {
81048198
[CmdletBinding()]
81058199

81068200
PARAM (
8107-
[parameter(
8108-
Mandatory = $True,
8201+
[parameter(Mandatory = $False,
81098202
Position = 0,
8110-
HelpMessage = "ID of a StorageGRID site to be updated.")][String]$ID,
8111-
[parameter(
8112-
Mandatory = $True,
8203+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
8204+
[parameter(Mandatory = $False,
81138205
Position = 1,
8114-
HelpMessage = "New ID for the StorageGRID site.")][String]$NewID,
8206+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName,
81158207
[parameter(
81168208
Mandatory = $True,
81178209
Position = 2,
8118-
HelpMessage = "New name for the StorageGRID site.")][String]$Name,
8119-
[parameter(Mandatory = $False,
8210+
HelpMessage = "ID of a StorageGRID site to be updated.")][String]$Id,
8211+
[parameter(
8212+
Mandatory = $False,
81208213
Position = 3,
8121-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
8214+
HelpMessage = "New ID for the StorageGRID site.")][String]$NewId,
8215+
[parameter(
8216+
Mandatory = $True,
8217+
Position = 4,
8218+
HelpMessage = "New name for the StorageGRID site.")][String]$Name
81228219
)
81238220

81248221
Begin {
8222+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
8223+
$ProfileName = "default"
8224+
}
8225+
if ($ProfileName) {
8226+
$Profile = Get-SgwProfile -ProfileName $ProfileName
8227+
if (!$Profile.Name) {
8228+
Throw "Profile $ProfileName not found. Create a profile using New-SgwProfile or connect to a StorageGRID Server using Connect-SgwServer"
8229+
}
8230+
$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
8231+
}
8232+
81258233
if (!$Server) {
81268234
$Server = $Global:CurrentSgwServer
81278235
}
@@ -8134,7 +8242,7 @@ function Global:Update-SgwExpansionSite {
81348242
}
81358243

81368244
Process {
8137-
$Uri = $Server.BaseURI + "/grid/expansion/site/$id"
8245+
$Uri = $Server.BaseURI + "/grid/expansion/sites/$id"
81388246
$Method = "PUT"
81398247

81408248
$Body = @{ }
@@ -8144,11 +8252,14 @@ function Global:Update-SgwExpansionSite {
81448252
if ($NewID) {
81458253
$Body.id = $NewID
81468254
}
8255+
else {
8256+
$Body.id = $Id
8257+
}
81478258

81488259
$Body = ConvertTo-Json -InputObject $Body
81498260

81508261
try {
8151-
$Response = Invoke-SgwRequest -WebSession $Server.Session -Method $Method -Uri $Uri -Headers $Server.Headers -SkipCertificateCheck:$Server.SkipCertificateCheck
8262+
$Response = Invoke-SgwRequest -WebSession $Server.Session -Method $Method -Uri $Uri -Headers $Server.Headers -Body $Body -SkipCertificateCheck:$Server.SkipCertificateCheck
81528263
}
81538264
catch {
81548265
$ResponseBody = ParseErrorForResponseBody $_

0 commit comments

Comments
 (0)