Skip to content

Commit a02a44a

Browse files
committed
Added profile handling to config Cmdlets
1 parent fc6e533 commit a02a44a

1 file changed

Lines changed: 101 additions & 9 deletions

File tree

src/StorageGRID-Webscale.psm1

Lines changed: 101 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2637,24 +2637,39 @@ function Global:Enable-SgwCompliance {
26372637

26382638
## config ##
26392639

2640-
# complete as of API 2.1
2640+
# complete as of API 2.2
26412641

26422642
<#
26432643
.SYNOPSIS
26442644
Retrieves global configuration and token information
26452645
.DESCRIPTION
26462646
Retrieves global configuration and token information
2647+
.PARAMETER Server
2648+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
2649+
.PARAMETER ProfileName
2650+
StorageGRID Profile to use for connection.
26472651
#>
26482652
function Global:Get-SgwConfig {
26492653
[CmdletBinding()]
26502654

26512655
PARAM (
26522656
[parameter(Mandatory = $False,
26532657
Position = 0,
2654-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
2658+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
2659+
[parameter(Mandatory = $False,
2660+
Position = 1,
2661+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName
26552662
)
26562663

26572664
Begin {
2665+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
2666+
$ProfileName = "default"
2667+
}
2668+
if ($ProfileName) {
2669+
$Profile = Get-SgwProfile -ProfileName $ProfileName
2670+
$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
2671+
}
2672+
26582673
if (!$Server) {
26592674
$Server = $Global:CurrentSgwServer
26602675
}
@@ -2690,17 +2705,32 @@ function Global:Get-SgwConfig {
26902705
Retrieves the global management API and UI configuration
26912706
.DESCRIPTION
26922707
Retrieves the global management API and UI configuration
2708+
.PARAMETER Server
2709+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
2710+
.PARAMETER ProfileName
2711+
StorageGRID Profile to use for connection.
26932712
#>
26942713
function Global:Get-SgwConfigManagement {
26952714
[CmdletBinding()]
26962715

26972716
PARAM (
26982717
[parameter(Mandatory = $False,
26992718
Position = 0,
2700-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
2719+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
2720+
[parameter(Mandatory = $False,
2721+
Position = 1,
2722+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName
27012723
)
27022724

27032725
Begin {
2726+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
2727+
$ProfileName = "default"
2728+
}
2729+
if ($ProfileName) {
2730+
$Profile = Get-SgwProfile -ProfileName $ProfileName
2731+
$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
2732+
}
2733+
27042734
if (!$Server) {
27052735
$Server = $Global:CurrentSgwServer
27062736
}
@@ -2736,21 +2766,38 @@ function Global:Get-SgwConfigManagement {
27362766
Changes the global management API and UI configuration
27372767
.DESCRIPTION
27382768
Changes the global management API and UI configuration
2769+
.PARAMETER Server
2770+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
2771+
.PARAMETER ProfileName
2772+
StorageGRID Profile to use for connection.
2773+
.PARAMETER MinApiVersion
2774+
Minimum API Version.
27392775
#>
27402776
function Global:Update-SgwConfigManagement {
27412777
[CmdletBinding()]
27422778

27432779
PARAM (
2744-
[parameter(Mandatory = $True,
2780+
[parameter(Mandatory = $False,
27452781
Position = 0,
2746-
HelpMessage = "Minimum API Version.")][Int][ValidateSet(1, 2)]$MinApiVersion,
2782+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
27472783
[parameter(Mandatory = $False,
27482784
Position = 1,
2749-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
2785+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName,
2786+
[parameter(Mandatory = $True,
2787+
Position = 2,
2788+
HelpMessage = "Minimum API Version.")][Int][ValidateSet(1, 2)]$MinApiVersion
27502789
)
27512790

27522791

27532792
Begin {
2793+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
2794+
$ProfileName = "default"
2795+
}
2796+
if ($ProfileName) {
2797+
$Profile = Get-SgwProfile -ProfileName $ProfileName
2798+
$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
2799+
}
2800+
27542801
if (!$Server) {
27552802
$Server = $Global:CurrentSgwServer
27562803
}
@@ -2790,17 +2837,32 @@ function Global:Update-SgwConfigManagement {
27902837
Retrieve StorageGRID Product Version
27912838
.DESCRIPTION
27922839
Retrieve StorageGRID Product Version
2840+
.PARAMETER Server
2841+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
2842+
.PARAMETER ProfileName
2843+
StorageGRID Profile to use for connection.
27932844
#>
27942845
function Global:Get-SgwProductVersion {
27952846
[CmdletBinding()]
27962847

27972848
PARAM (
27982849
[parameter(Mandatory = $False,
27992850
Position = 0,
2800-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
2851+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
2852+
[parameter(Mandatory = $False,
2853+
Position = 1,
2854+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName
28012855
)
28022856

28032857
Begin {
2858+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
2859+
$ProfileName = "default"
2860+
}
2861+
if ($ProfileName) {
2862+
$Profile = Get-SgwProfile -ProfileName $ProfileName
2863+
$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
2864+
}
2865+
28042866
if (!$Server) {
28052867
$Server = $Global:CurrentSgwServer
28062868
}
@@ -2836,17 +2898,32 @@ function Global:Get-SgwProductVersion {
28362898
Retrieves the current API version of the management API
28372899
.DESCRIPTION
28382900
Retrieves the current API version of the management API
2901+
.PARAMETER Server
2902+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
2903+
.PARAMETER ProfileName
2904+
StorageGRID Profile to use for connection.
28392905
#>
28402906
function Global:Get-SgwVersion {
28412907
[CmdletBinding()]
28422908

28432909
PARAM (
28442910
[parameter(Mandatory = $False,
28452911
Position = 0,
2846-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
2912+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
2913+
[parameter(Mandatory = $False,
2914+
Position = 1,
2915+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName
28472916
)
28482917

28492918
Begin {
2919+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
2920+
$ProfileName = "default"
2921+
}
2922+
if ($ProfileName) {
2923+
$Profile = Get-SgwProfile -ProfileName $ProfileName
2924+
$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
2925+
}
2926+
28502927
if (!$Server) {
28512928
$Server = $Global:CurrentSgwServer
28522929
}
@@ -2884,17 +2961,32 @@ function Global:Get-SgwVersion {
28842961
Retrieves the major versions of the management API supported by the product release
28852962
.DESCRIPTION
28862963
Retrieves the major versions of the management API supported by the product release
2964+
.PARAMETER Server
2965+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
2966+
.PARAMETER ProfileName
2967+
StorageGRID Profile to use for connection.
28872968
#>
28882969
function Global:Get-SgwVersions {
28892970
[CmdletBinding()]
28902971

28912972
PARAM (
28922973
[parameter(Mandatory = $False,
28932974
Position = 0,
2894-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
2975+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
2976+
[parameter(Mandatory = $False,
2977+
Position = 1,
2978+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName
28952979
)
28962980

28972981
Begin {
2982+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
2983+
$ProfileName = "default"
2984+
}
2985+
if ($ProfileName) {
2986+
$Profile = Get-SgwProfile -ProfileName $ProfileName
2987+
$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
2988+
}
2989+
28982990
if (!$Server) {
28992991
$Server = $Global:CurrentSgwServer
29002992
}

0 commit comments

Comments
 (0)