Skip to content

Commit 37321b6

Browse files
committed
Updated audit Cmdlets to work with Profiles
1 parent 633f878 commit 37321b6

1 file changed

Lines changed: 49 additions & 7 deletions

File tree

src/StorageGRID-Webscale.psm1

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,6 +1904,8 @@ function Global:Get-SgwAccountUsage {
19041904
Retrieve all StorageGRID Webscale Alarms
19051905
.DESCRIPTION
19061906
Retrieve all StorageGRID Webscale Alarms
1907+
.PARAMETER Server
1908+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
19071909
.PARAMETER ProfileName
19081910
StorageGRID Profile to use for connection.
19091911
.PARAMETER IncludeAcknowledged
@@ -1976,24 +1978,39 @@ function Global:Get-SgwAlarms {
19761978

19771979
## audit ##
19781980

1979-
# complete as of API 2.1
1981+
# complete as of API 2.2
19801982

19811983
<#
19821984
.SYNOPSIS
19831985
Gets the audit configuration
19841986
.DESCRIPTION
19851987
Gets the audit configuration
1988+
.PARAMETER Server
1989+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
1990+
.PARAMETER ProfileName
1991+
StorageGRID Profile to use for connection.
19861992
#>
19871993
function Global:Get-SgwAudit {
19881994
[CmdletBinding()]
19891995

19901996
PARAM (
19911997
[parameter(Mandatory = $False,
19921998
Position = 0,
1993-
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server
1999+
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
2000+
[parameter(Mandatory = $False,
2001+
Position = 1,
2002+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName
19942003
)
19952004

19962005
Begin {
2006+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
2007+
$ProfileName = "default"
2008+
}
2009+
if ($ProfileName) {
2010+
$Profile = Get-SgwProfile -ProfileName $ProfileName
2011+
$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
2012+
}
2013+
19972014
if (!$Server) {
19982015
$Server = $Global:CurrentSgwServer
19992016
}
@@ -2034,6 +2051,20 @@ function Global:Get-SgwAudit {
20342051
Replace the audit configuration
20352052
.DESCRIPTION
20362053
Replace the audit configuration
2054+
.PARAMETER Server
2055+
StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.
2056+
.PARAMETER ProfileName
2057+
StorageGRID Profile to use for connection.
2058+
.PARAMETER LevelSystem
2059+
Audit log level for system.
2060+
.PARAMETER LevelStorage
2061+
Audit log level for storage.
2062+
.PARAMETER LevelProtocol
2063+
Audit log level for protocol.
2064+
.PARAMETER LevelManagement
2065+
Audit log level for management.
2066+
.PARAMETER LoggedHeaders
2067+
Logged headers.
20372068
#>
20382069
function Global:Replace-SgwAudit {
20392070
[CmdletBinding()]
@@ -2042,34 +2073,45 @@ function Global:Replace-SgwAudit {
20422073
[parameter(Mandatory = $False,
20432074
Position = 0,
20442075
HelpMessage = "StorageGRID Webscale Management Server object. If not specified, global CurrentSgwServer object will be used.")][PSCustomObject]$Server,
2045-
[parameter(Mandatory = $True,
2076+
[parameter(Mandatory = $False,
20462077
Position = 1,
2078+
HelpMessage = "StorageGRID Profile to use for connection.")][Alias("Profile")][String]$ProfileName,
2079+
[parameter(Mandatory = $True,
2080+
Position = 2,
20472081
HelpMessage = "Audit log level for system.",
20482082
ValueFromPipeline = $True,
20492083
ValueFromPipelineByPropertyName = $True)][ValidateSet("off","error","normal","debug")][String]$LevelSystem,
20502084
[parameter(Mandatory = $True,
2051-
Position = 1,
2085+
Position = 3,
20522086
HelpMessage = "Audit log level for storage.",
20532087
ValueFromPipeline = $True,
20542088
ValueFromPipelineByPropertyName = $True)][ValidateSet("off","error","normal","debug")][String]$LevelStorage,
20552089
[parameter(Mandatory = $True,
2056-
Position = 1,
2090+
Position = 4,
20572091
HelpMessage = "Audit log level for protocol.",
20582092
ValueFromPipeline = $True,
20592093
ValueFromPipelineByPropertyName = $True)][ValidateSet("off","error","normal","debug")][String]$LevelProtocol,
20602094
[parameter(Mandatory = $True,
2061-
Position = 1,
2095+
Position = 5,
20622096
HelpMessage = "Audit log level for management.",
20632097
ValueFromPipeline = $True,
20642098
ValueFromPipelineByPropertyName = $True)][ValidateSet("off","error","normal","debug")][String]$LevelManagement,
20652099
[parameter(Mandatory = $False,
2066-
Position = 2,
2100+
Position = 6,
20672101
HelpMessage = "Logged headers.",
20682102
ValueFromPipeline = $True,
20692103
ValueFromPipelineByPropertyName = $True)][String[]]$LoggedHeaders
20702104
)
20712105

20722106
Begin {
2107+
if (!$ProfileName -and !$Server -and !$CurrentSgwServer.Name) {
2108+
$ProfileName = "default"
2109+
}
2110+
if ($ProfileName) {
2111+
$Profile = Get-SgwProfile -ProfileName $ProfileName
2112+
$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
2113+
}
2114+
20732115
if (!$Server) {
20742116
$Server = $Global:CurrentSgwServer
20752117
}

0 commit comments

Comments
 (0)