Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Public/Array/Get-PfbArrayPerformanceReplication.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function Get-PfbArrayPerformanceReplication {
End of the time range for historical data (epoch milliseconds or datetime string).
.PARAMETER Resolution
Time resolution for data points in milliseconds (e.g. 30000, 86400000).
.PARAMETER Type
Restricts results to replication performance for a specific object type. Valid values
are "all", "file-system", and "object-store".
.PARAMETER Array
The FlashBlade connection object. If not specified, the default connection is used.
.EXAMPLE
Expand All @@ -37,6 +40,9 @@ function Get-PfbArrayPerformanceReplication {
[Parameter()] [long]$StartTime,
[Parameter()] [long]$EndTime,
[Parameter()] [long]$Resolution,
[Parameter()]
[ValidateSet('all', 'file-system', 'object-store')]
[string]$Type,
[Parameter()] [PSCustomObject]$Array
)

Expand All @@ -52,6 +58,7 @@ function Get-PfbArrayPerformanceReplication {
if ($StartTime) { $queryParams['start_time'] = $StartTime }
if ($EndTime) { $queryParams['end_time'] = $EndTime }
if ($Resolution) { $queryParams['resolution'] = $Resolution }
if ($Type) { $queryParams['type'] = $Type }

Invoke-PfbApiRequest -Array $Array -Method GET -Endpoint 'arrays/performance/replication' -QueryParams $queryParams -AutoPaginate
}
Expand Down
27 changes: 14 additions & 13 deletions Public/FileSystem/Get-PfbFileSystemSession.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ function Get-PfbFileSystemSession {
Retrieves file system sessions from the FlashBlade.
.DESCRIPTION
Returns active client sessions connected to file systems on the FlashBlade.
Supports filtering by file system name, ID, or advanced filter expressions.
Supports filtering by session name, protocol, or advanced filter expressions.
Auto-paginates by default.
.PARAMETER Name
One or more file system names to retrieve sessions for. Accepts pipeline input.
.PARAMETER Id
One or more session IDs to retrieve.
One or more session names to filter by -- the session's own generated identifier
(e.g. as returned in a prior Get-PfbFileSystemSession call's Name property), NOT the
name of a file system. Accepts pipeline input.
.PARAMETER Filter
A server-side filter expression to narrow results.
.PARAMETER Sort
Expand All @@ -18,14 +18,17 @@ function Get-PfbFileSystemSession {
Maximum number of items to return.
.PARAMETER TotalOnly
Return only the total count, not the items.
.PARAMETER Protocol
Restricts results to sessions using one or more specific protocols. Valid values are
"nfs" and "smb".
.PARAMETER Array
The FlashBlade connection object. If not specified, uses the default connection.
.EXAMPLE
Get-PfbFileSystemSession
Returns all file system sessions on the FlashBlade.
.EXAMPLE
Get-PfbFileSystemSession -Name "fs01"
Returns all sessions connected to file system 'fs01'.
Get-PfbFileSystemSession -Name "22517998136858346-smb"
Returns the single session with that session name.
.EXAMPLE
Get-PfbFileSystemSession -Filter "protocol='NFS'" -Limit 50
Returns up to 50 NFS sessions.
Expand All @@ -36,10 +39,6 @@ function Get-PfbFileSystemSession {
[ValidateNotNullOrEmpty()]
[string[]]$Name,

[Parameter(ParameterSetName = 'ById')]
[ValidateNotNullOrEmpty()]
[string[]]$Id,

[Parameter()]
[string]$Filter,

Expand All @@ -53,29 +52,31 @@ function Get-PfbFileSystemSession {
[Parameter()]
[switch]$TotalOnly,

[Parameter()]
[ValidateSet('nfs', 'smb')]
[string[]]$Protocol,

[Parameter()]
[PSCustomObject]$Array
)

begin {
Assert-PfbConnection -Array ([ref]$Array)
$allNames = [System.Collections.Generic.List[string]]::new()
$allIds = [System.Collections.Generic.List[string]]::new()
}

process {
if ($Name) { foreach ($n in $Name) { $allNames.Add($n) } }
if ($Id) { foreach ($i in $Id) { $allIds.Add($i) } }
}

end {
$queryParams = @{}
if ($allNames.Count -gt 0) { $queryParams['names'] = $allNames -join ',' }
if ($allIds.Count -gt 0) { $queryParams['ids'] = $allIds -join ',' }
if ($Filter) { $queryParams['filter'] = $Filter }
if ($Sort) { $queryParams['sort'] = $Sort }
if ($Limit -gt 0) { $queryParams['limit'] = $Limit }
if ($TotalOnly) { $queryParams['total_only'] = 'true' }
if ($Protocol) { $queryParams['protocols'] = $Protocol -join ',' }

Invoke-PfbApiRequest -Array $Array -Method GET -Endpoint 'file-systems/sessions' -QueryParams $queryParams -AutoPaginate
}
Expand Down
76 changes: 58 additions & 18 deletions Public/FileSystem/Remove-PfbFileSystemSession.ps1
Original file line number Diff line number Diff line change
@@ -1,34 +1,63 @@
function Remove-PfbFileSystemSession {
<#
.SYNOPSIS
Terminates a file system session on the FlashBlade.
Terminates one or more file system sessions on the FlashBlade.
.DESCRIPTION
Forces the termination of an active client session connected to a file system.
This is a disruptive operation that disconnects the client and may cause
in-progress operations to fail.
Forces the termination of active client session(s). This is a disruptive operation
that disconnects the client(s) and may cause in-progress operations to fail.

Two mutually exclusive modes are supported, matching the real REST endpoint's own
rules (live-confirmed: the server rejects combining `names` with any other query
parameter, including `protocols`):
- -Name: terminates one specific session, identified by the session's own generated
name (as returned in the Name property of Get-PfbFileSystemSession's output) --
NOT a file system name.
- -Protocol: bulk-terminates every active session using the given protocol(s),
across the entire array, regardless of file system or client. Cannot be combined
with -Name. The server requires an internal "disruptive" flag for this
single-filter bulk mode, which this cmdlet sets automatically -- there is no
narrower per-client/per-user filter exposed here, so any use of -Protocol affects
every matching session array-wide. Because of that blast radius, -Protocol also
requires -Force -- independent of $ConfirmPreference/-Confirm, so a caller who has
globally lowered their confirm preference still cannot trigger a bulk purge without
explicitly opting in.
.PARAMETER Name
The name of the file system whose session should be terminated.
.PARAMETER Id
The ID of the session to terminate.
The session's own generated name to terminate (as returned by
Get-PfbFileSystemSession's Name property) -- NOT the name of a file system.
Mandatory in the ByName parameter set; cannot be combined with -Protocol.
.PARAMETER Protocol
Bulk-terminates every active session using one or more specific protocols, across
the entire array. Valid values are "nfs" and "smb". Cannot be combined with -Name --
the server rejects that combination. This is an array-wide, cross-client operation;
there is no narrower filter exposed by this cmdlet. Requires -Force.
.PARAMETER Force
Required alongside -Protocol to acknowledge the array-wide, cross-client blast radius
of that bulk-terminate mode. This check is independent of $ConfirmPreference/-Confirm
-- it cannot be bypassed by lowering the session's confirm preference, unlike the
standard SupportsShouldProcess prompt this cmdlet also honors.
.PARAMETER Array
The FlashBlade connection object. If not specified, uses the default connection.
.EXAMPLE
Remove-PfbFileSystemSession -Name "fs01"
Terminates sessions on file system 'fs01'.
Remove-PfbFileSystemSession -Name "22517998136858346-smb"
Terminates the single session with that session name.
.EXAMPLE
Remove-PfbFileSystemSession -Id "abc-123"
Terminates the session with the specified ID.
Remove-PfbFileSystemSession -Protocol 'smb' -Force -Confirm:$false
Bulk-terminates every active SMB session on the array.
.EXAMPLE
Remove-PfbFileSystemSession -Name "fs01" -Confirm:$false
Remove-PfbFileSystemSession -Name "22517998136858346-smb" -Confirm:$false
Terminates the session without prompting for confirmation.
#>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(ParameterSetName = 'ByName', Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[string]$Name,

[Parameter(ParameterSetName = 'ById', Mandatory)]
[string]$Id,
[Parameter(ParameterSetName = 'ByProtocol', Mandatory)]
[ValidateSet('nfs', 'smb')]
[string[]]$Protocol,

[Parameter()]
[switch]$Force,

[Parameter()]
[PSCustomObject]$Array
Expand All @@ -40,12 +69,23 @@ function Remove-PfbFileSystemSession {

process {
$queryParams = @{}
if ($Name) { $queryParams['names'] = $Name }
if ($Id) { $queryParams['ids'] = $Id }
$action = 'Terminate file system session'

$target = if ($Name) { $Name } else { $Id }
if ($PSCmdlet.ParameterSetName -eq 'ByProtocol') {
if (-not $Force) {
throw "Remove-PfbFileSystemSession -Protocol bulk-terminates EVERY active session using that protocol, across the entire array, for every client -- pass -Force to acknowledge this before it will run (independent of `$ConfirmPreference/-Confirm)."
}
$queryParams['protocols'] = $Protocol -join ','
$queryParams['disruptive'] = 'true'
$target = $Protocol -join ', '
$action = 'Bulk-terminate ALL file system sessions using protocol(s)'
}
else {
$queryParams['names'] = $Name
$target = $Name
}

if ($PSCmdlet.ShouldProcess($target, 'Terminate file system session')) {
if ($PSCmdlet.ShouldProcess($target, $action)) {
Invoke-PfbApiRequest -Array $Array -Method DELETE -Endpoint 'file-systems/sessions' -QueryParams $queryParams
}
}
Expand Down
6 changes: 6 additions & 0 deletions Public/Network/Invoke-PfbNetworkTrace.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function Invoke-PfbNetworkTrace {
The hostname or IP address to trace the route to. This parameter is mandatory.
.PARAMETER SourceName
The name of the network interface to use as the source of the trace.
.PARAMETER Method
The trace protocol to use. Valid values are "icmp", "tcp", and "udp".
.PARAMETER Array
The FlashBlade connection object. If not specified, the default connection is used.
.EXAMPLE
Expand All @@ -29,12 +31,16 @@ function Invoke-PfbNetworkTrace {
param(
[Parameter(Mandatory, Position = 0)] [string]$Destination,
[Parameter()] [string]$SourceName,
[Parameter()]
[ValidateSet('icmp', 'tcp', 'udp')]
[string]$Method,
[Parameter()] [PSCustomObject]$Array
)
begin { Assert-PfbConnection -Array ([ref]$Array) }
process {
$queryParams = @{ 'destination' = $Destination }
if ($SourceName) { $queryParams['source.name'] = $SourceName }
if ($Method) { $queryParams['method'] = $Method }
Invoke-PfbApiRequest -Array $Array -Method GET -Endpoint 'network-interfaces/trace' -QueryParams $queryParams
}
}
18 changes: 18 additions & 0 deletions Public/Policy/Get-PfbPolicyAllMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ function Get-PfbPolicyAllMember {
One or more member names to filter by.
.PARAMETER MemberId
One or more member IDs to filter by.
.PARAMETER MemberType
One or more member types to filter by (e.g. "file-systems", "object-store-users").
Tab-completes the values documented as of this module's release, but the server's
accepted set has grown across REST versions and may include newer values not offered
here — any value is passed through as-is, not validated client-side.
.PARAMETER Filter
A server-side filter expression to narrow results.
.PARAMETER Limit
Expand All @@ -38,6 +43,18 @@ function Get-PfbPolicyAllMember {
[Parameter()] [string[]]$PolicyId,
[Parameter()] [string[]]$MemberName,
[Parameter()] [string[]]$MemberId,
[Parameter()]
[ArgumentCompleter({
param($CommandName, $ParameterName, $WordToComplete, $CommandAst, $FakeBoundParameters)
@(
'file-systems',
'file-system-snapshots',
'file-system-replica-links',
'object-store-users',
'object-store-accounts'
) | Where-Object { $_ -like "$WordToComplete*" }
})]
[string[]]$MemberType,
[Parameter()] [string]$Filter, [Parameter()] [int]$Limit,
[Parameter()] [PSCustomObject]$Array
)
Expand All @@ -49,6 +66,7 @@ function Get-PfbPolicyAllMember {
if ($PolicyId) { $queryParams['policy_ids'] = $PolicyId -join ',' }
if ($MemberName) { $queryParams['member_names'] = $MemberName -join ',' }
if ($MemberId) { $queryParams['member_ids'] = $MemberId -join ',' }
if ($MemberType) { $queryParams['member_types'] = $MemberType -join ',' }
if ($Filter) { $queryParams['filter'] = $Filter }
if ($Limit -gt 0) { $queryParams['limit'] = $Limit }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ function Get-PfbArrayConnectionPerformanceReplication {
End of the time range for historical data (epoch milliseconds).
.PARAMETER Resolution
Time resolution for data points in milliseconds (e.g., 30000, 86400000).
.PARAMETER Type
Restricts results to replication performance for a specific object type. Valid values
are "all", "file-system", and "object-store".
.PARAMETER Array
The FlashBlade connection object. If not specified, the default connection is used.
.EXAMPLE
Expand All @@ -41,6 +44,9 @@ function Get-PfbArrayConnectionPerformanceReplication {
[Parameter()] [long]$StartTime,
[Parameter()] [long]$EndTime,
[Parameter()] [long]$Resolution,
[Parameter()]
[ValidateSet('all', 'file-system', 'object-store')]
[string]$Type,
[Parameter()] [PSCustomObject]$Array
)
begin {
Expand All @@ -61,6 +67,7 @@ function Get-PfbArrayConnectionPerformanceReplication {
if ($StartTime) { $queryParams['start_time'] = $StartTime }
if ($EndTime) { $queryParams['end_time'] = $EndTime }
if ($Resolution) { $queryParams['resolution'] = $Resolution }
if ($Type) { $queryParams['type'] = $Type }
Invoke-PfbApiRequest -Array $Array -Method GET -Endpoint 'array-connections/performance/replication' -QueryParams $queryParams -AutoPaginate
}
}
20 changes: 18 additions & 2 deletions Public/Support/Test-PfbSupport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ function Test-PfbSupport {
The Test-PfbSupport cmdlet tests the support connectivity of the connected Pure Storage
FlashBlade. This returns test results indicating whether Phone Home and remote assist
connections are functioning properly.
.PARAMETER TestType
Restricts which support connectivity test is run. Valid values are "all", "phonehome",
and "remote-assist".
.PARAMETER Array
The FlashBlade connection object. If not specified, the default connection is used.
.EXAMPLE
Test-PfbSupport

Runs the support connectivity test on the connected FlashBlade.
.EXAMPLE
Test-PfbSupport -TestType 'phonehome'

Runs only the phone-home connectivity test.
.EXAMPLE
Test-PfbSupport -Array $FlashBlade

Expand All @@ -22,7 +29,16 @@ function Test-PfbSupport {
Runs the support test and displays the test type from the results.
#>
[CmdletBinding()]
param([Parameter()] [PSCustomObject]$Array)
param(
[Parameter()]
[ValidateSet('all', 'phonehome', 'remote-assist')]
[string]$TestType,

[Parameter()]
[PSCustomObject]$Array
)
Assert-PfbConnection -Array ([ref]$Array)
Invoke-PfbApiRequest -Array $Array -Method GET -Endpoint 'support/test'
$queryParams = @{}
if ($TestType) { $queryParams['test_type'] = $TestType }
Invoke-PfbApiRequest -Array $Array -Method GET -Endpoint 'support/test' -QueryParams $queryParams
}
39 changes: 39 additions & 0 deletions Tests/Get-PfbArrayConnectionPerformanceReplication.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '5.0' }

BeforeAll {
Import-Module "$PSScriptRoot/../PureStorageFlashBladePowerShell.psd1" -Force
$script:fakeArray = [PSCustomObject]@{ Endpoint = 'fb.example.test'; ApiVersion = '2.0'; AuthToken = 'x' }
}

Describe 'Get-PfbArrayConnectionPerformanceReplication' {
BeforeEach {
Mock -ModuleName PureStorageFlashBladePowerShell Assert-PfbConnection { }
Mock -ModuleName PureStorageFlashBladePowerShell Invoke-PfbApiRequest { }
}

It 'restricts -Type to the three real spec-documented values' {
$attr = (Get-Command Get-PfbArrayConnectionPerformanceReplication).Parameters['Type'].Attributes |
Where-Object { $_ -is [System.Management.Automation.ValidateSetAttribute] }
$attr | Should -Not -BeNullOrEmpty
$attr.ValidValues | Should -Be @('all', 'file-system', 'object-store')
}

It 'rejects an invalid -Type value before making any API call' {
{ Get-PfbArrayConnectionPerformanceReplication -Type 'bogus' -Array $fakeArray } | Should -Throw
Should -Invoke Invoke-PfbApiRequest -ModuleName PureStorageFlashBladePowerShell -Times 0 -Exactly
}

It 'passes a valid -Type through to the query string' {
Get-PfbArrayConnectionPerformanceReplication -Type 'file-system' -Array $fakeArray
Should -Invoke Invoke-PfbApiRequest -ModuleName PureStorageFlashBladePowerShell -Times 1 -Exactly -ParameterFilter {
$Method -eq 'GET' -and $Endpoint -eq 'array-connections/performance/replication' -and $QueryParams['type'] -eq 'file-system'
}
}

It 'omits -Type from the query string when not specified' {
Get-PfbArrayConnectionPerformanceReplication -Array $fakeArray
Should -Invoke Invoke-PfbApiRequest -ModuleName PureStorageFlashBladePowerShell -Times 1 -Exactly -ParameterFilter {
-not $QueryParams.ContainsKey('type')
}
}
}
Loading