Skip to content

Commit 9d417bd

Browse files
committed
Update Tutorial
1 parent 167deb3 commit 9d417bd

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

StorageGRID-Webscale-Tutorial.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,39 +35,39 @@ For data retrieval a connection to the StorageGRID Management Server is required
3535
```powershell
3636
$Server = "nms.mydomain.tld"
3737
$Credential = Get-Credential
38-
Connect-S3MgmtServer -Name $ServerName -Credential $Credential
38+
Connect-SGWServer -Name $Server -Credential $Credential
3939
```
4040

4141
If the login fails, it is often due to an untrusted certificate of the StorageGRID Management Server. You can ignore the certificate check with the `-Insecure` option
4242

4343
```powershell
44-
Connect-S3MgmtServer -Name $ServerName -Credential $Credential -Insecure
44+
Connect-SGWServer -Name $Server -Credential $Credential -Insecure
4545
```
4646

47-
By default the connection to the S3Mgmt server is established through HTTPS. If that doesn't work, HTTP will be tried.
47+
By default the connection to the StorageGRID Webscale Server is established through HTTPS. If that doesn't work, HTTP will be tried.
4848

4949
To force connections via HTTPS use the `-HTTPS` switch
5050

5151
```powershell
52-
Connect-S3MgmtServer -Name $ServerName -Credential $Credential -HTTPS
52+
Connect-SGWServer -Name $Server -Credential $Credential -HTTPS
5353
```
5454

5555
To force connections via HTTP use the `-HTTP` switch
5656

5757
```powershell
58-
Connect-S3MgmtServer -Name $ServerName -Credential $Credential -HTTP
58+
Connect-SGWServer -Name $Server -Credential $Credential -HTTP
5959
```
6060

6161
## Simple workflow for exporting S3 account usage to CSV
6262

6363
In this simple workflow the S3 account usage data will be retrieved and exported as CSV to [C:\tmp\usage.csv](C:\tmp\usage.csv).
6464

6565
```powershell
66-
$Accounting = foreach ($Account in Get-S3Accounts) {
67-
$Usage = Get-S3AccountUsage -id $Account.id
66+
$Accounting = foreach ($Account in (Get-SGWAccounts | Where-Object { $_.capabilities -match "s3" })) {
67+
$Usage = $Account | Get-SGWAccountUsage
6868
$Output = New-Object -TypeName PSCustomObject -Property @{Name=$Account.name;ID=$Account.id;"Calculation Time"=$Usage.calculationTime;"Object Count"=$Usage.objectCount;"Data Bytes used"=$Usage.dataBytes}
6969
Write-Output $Output
70-
}
70+
}
7171
7272
$Accounting | Export-Csv -Path C:\tmp\usage.csv -NoTypeInformation
7373
```

src/StorageGRID-Webscale.psm1

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,19 @@ function global:Connect-SGWServer {
2727
[parameter(Mandatory=$True,
2828
Position=1,
2929
HelpMessage="A System.Management.Automation.PSCredential object containing the credentials needed to log into the StorageGRID Webscale Management Server.")][System.Management.Automation.PSCredential]$Credential,
30-
[parameter(Mandatory=$False,
30+
[parameter(Mandatory=$True,
3131
Position=2,
32+
HelpMessage="Account ID for Tenenant Login")][System.Management.Automation.PSCredential]$AccountID,
33+
[parameter(Mandatory=$False,
34+
Position=3,
3235
HelpMessage="This cmdlet always tries to establish a secure HTTPS connection to the StorageGRID Webscale Management Server, but it will fall back to HTTP if necessary. Specify -HTTP to skip the HTTPS connection attempt and only try HTTP.")][Switch]$HTTP,
3336
[parameter(Mandatory=$False,
34-
Position=2,
37+
Position=4,
3538
HelpMessage="This cmdlet always tries to establish a secure HTTPS connection to the StorageGRID Webscale Management Server, but it will fall back to HTTP if necessary. Specify -HTTPS to fail the connection attempt in that case rather than fall back to HTTP.")][Switch]$HTTPS,
3639
[parameter(Mandatory=$False,
37-
Position=3,
40+
Position=5,
3841
HelpMessage="If the StorageGRID Webscale Management Server certificate cannot be verified, the connection will fail. Specify -Insecure to ignore the validity of the StorageGRID Webscale Management Server certificate.")][Switch]$Insecure,
39-
[parameter(Position=4,
42+
[parameter(Position=6,
4043
Mandatory=$False,
4144
HelpMessage="Specify -Transient to not set the global variable `$CurrentOciServer.")][Switch]$Transient
4245
)
@@ -60,12 +63,23 @@ function global:Connect-SGWServer {
6063
$Server | Add-Member -MemberType NoteProperty -Name Name -Value $Name
6164
$Server | Add-Member -MemberType NoteProperty -Name Credential -Value $Credential
6265

63-
$Body = @"
66+
if ($AccountID) {
67+
$Body = @"
6468
{
69+
"accountId": "$AccountID",
6570
"username": "$($Credential.UserName)",
6671
"password": "$($Credential.GetNetworkCredential().Password)"
6772
}
6873
"@
74+
}
75+
else {
76+
$Body = @"
77+
{
78+
"username": "$($Credential.UserName)",
79+
"password": "$($Credential.GetNetworkCredential().Password)"
80+
}
81+
"@
82+
}
6983

7084
if ($HTTPS -or !$HTTP) {
7185
Try {

0 commit comments

Comments
 (0)