Initial commit

This commit is contained in:
Laurence Horrocks-Barlow 2026-05-19 00:35:27 +01:00
commit 6bf433c9a9
20 changed files with 1162 additions and 0 deletions

View file

@ -0,0 +1,80 @@
function Connect-GpfsServer {
[CmdletBinding(DefaultParameterSetName = 'Credential')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$Server,
[Parameter()]
[int]$Port = 443,
[Parameter()]
[ValidateSet('v2')]
[string]$ApiVersion = 'v2',
[Parameter(Mandatory, ParameterSetName = 'Credential')]
[PSCredential]$Credential,
[Parameter(Mandatory, ParameterSetName = 'UserPass')]
[string]$Username,
[Parameter(Mandatory, ParameterSetName = 'UserPass')]
[SecureString]$Password,
[Parameter()]
[switch]$UseSsl,
[Parameter()]
[switch]$SkipCertificateCheck,
[Parameter()]
[int]$TimeoutSeconds = 30,
[Parameter()]
[switch]$PassThru
)
if ($PSCmdlet.ParameterSetName -eq 'UserPass') {
$Credential = [PSCredential]::new($Username, $Password)
}
$protocol = if ($UseSsl) { 'https' } else { 'https' }
$baseUrl = '{0}://{1}:{2}' -f $protocol, $Server, $Port
$plainPass = $Credential.GetNetworkCredential().Password
$credBytes = [System.Text.Encoding]::UTF8.GetBytes('{0}:{1}' -f $Credential.UserName, $plainPass)
$encodedCred = [Convert]::ToBase64String($credBytes)
$script:GpfsSession = @{
Server = $Server
Port = $Port
BaseUrl = $baseUrl
ApiVersion = $ApiVersion
SkipCertificateCheck = $SkipCertificateCheck.IsPresent
TimeoutSeconds = $TimeoutSeconds
Headers = @{
Authorization = "Basic $encodedCred"
Accept = 'application/json'
}
}
try {
$cluster = Invoke-GpfsApiRequest -Method GET -Endpoint 'cluster'
Write-Verbose "Connected to GPFS cluster: $($cluster.cluster.clusterName)"
}
catch {
$script:GpfsSession = $null
throw "Failed to connect to GPFS server '$Server': $_"
}
if ($PassThru) {
[PSCustomObject]@{
Server = $Server
Port = $Port
ApiVersion = $ApiVersion
Connected = $true
}
}
else {
Write-Host "Connected to GPFS server: $Server ($ApiVersion)" -ForegroundColor Green
}
}

View file

@ -0,0 +1,13 @@
function Disconnect-GpfsServer {
[CmdletBinding()]
param()
if (-not $script:GpfsSession) {
Write-Warning 'No active GPFS session.'
return
}
$server = $script:GpfsSession.Server
$script:GpfsSession = $null
Write-Host "Disconnected from GPFS server: $server" -ForegroundColor Yellow
}

25
Public/GpfsCluster.ps1 Normal file
View file

@ -0,0 +1,25 @@
function Get-GpfsCluster {
[CmdletBinding()]
param()
Invoke-GpfsApiRequest -Method GET -Endpoint 'cluster'
}
function Get-GpfsClusterAuditLog {
[CmdletBinding()]
param()
Invoke-GpfsApiRequest -Method GET -Endpoint 'cluster/auditlog'
}
function Set-GpfsClusterAuditLog {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess('cluster audit log', 'Update')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint 'cluster/auditlog' -Body $Settings
}
}

18
Public/GpfsConfig.ps1 Normal file
View file

@ -0,0 +1,18 @@
function Get-GpfsClusterConfig {
[CmdletBinding()]
param()
Invoke-GpfsApiRequest -Method GET -Endpoint 'config'
}
function Set-GpfsClusterConfig {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess('cluster configuration', 'Update')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint 'config' -Body $Settings
}
}

View file

@ -0,0 +1,228 @@
function Get-GpfsConfiguration {
[CmdletBinding()]
param(
[Parameter()]
[string]$Path = (Join-Path $env:USERPROFILE '.PSGpfsApi\config.json'),
[Parameter()]
[string]$Profile
)
if (-not (Test-Path $Path)) {
throw "Configuration file not found: $Path"
}
$config = Get-Content $Path -Raw | ConvertFrom-Json
if ($Profile) {
$profileObj = $config.Profiles.$Profile
if (-not $profileObj) {
throw "Profile '$Profile' not found in configuration."
}
return $profileObj
}
return $config
}
function Set-GpfsConfiguration {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)]
[string]$ProfileName,
[Parameter(Mandatory)]
[string]$Server,
[Parameter()]
[int]$Port = 443,
[Parameter()]
[ValidateSet('v2')]
[string]$ApiVersion = 'v2',
[Parameter()]
[bool]$UseSsl = $true,
[Parameter()]
[bool]$SkipCertificateCheck = $false,
[Parameter()]
[int]$TimeoutSeconds = 30,
[Parameter()]
[string]$Username,
[Parameter()]
[string]$Path = (Join-Path $env:USERPROFILE '.PSGpfsApi\config.json'),
[Parameter()]
[switch]$SetActive
)
$dir = Split-Path $Path -Parent
if (-not (Test-Path $dir)) {
New-Item -ItemType Directory -Path $dir -Force | Out-Null
}
if (Test-Path $Path) {
$config = Get-Content $Path -Raw | ConvertFrom-Json
}
else {
$config = [PSCustomObject]@{
Profiles = [PSCustomObject]@{}
ActiveProfile = 'default'
}
}
$profileData = [PSCustomObject]@{
Server = $Server
Port = $Port
ApiVersion = $ApiVersion
UseSsl = $UseSsl
SkipCertificateCheck = $SkipCertificateCheck
TimeoutSeconds = $TimeoutSeconds
Username = $Username
}
$config.Profiles | Add-Member -NotePropertyName $ProfileName -NotePropertyValue $profileData -Force
if ($SetActive) {
$config.ActiveProfile = $ProfileName
}
if ($PSCmdlet.ShouldProcess($Path, 'Write configuration')) {
$config | ConvertTo-Json -Depth 10 | Set-Content $Path -Encoding UTF8
Write-Verbose "Configuration saved: $Path (profile: $ProfileName)"
}
}
function Import-GpfsConfiguration {
[CmdletBinding()]
param(
[Parameter()]
[string]$Path = (Join-Path $env:USERPROFILE '.PSGpfsApi\config.json'),
[Parameter()]
[string]$Profile,
[Parameter(Mandatory)]
[PSCredential]$Credential,
[Parameter()]
[switch]$SkipCertificateCheck
)
if (-not (Test-Path $Path)) {
throw "Configuration file not found: $Path"
}
$config = Get-Content $Path -Raw | ConvertFrom-Json
$profileName = if ($Profile) { $Profile } else { $config.ActiveProfile }
$profileObj = $config.Profiles.$profileName
if (-not $profileObj) {
throw "Profile '$profileName' not found in configuration."
}
$connectParams = @{
Server = $profileObj.Server
Port = $profileObj.Port
ApiVersion = $profileObj.ApiVersion
TimeoutSeconds = $profileObj.TimeoutSeconds
Credential = $Credential
}
if ($profileObj.UseSsl) {
$connectParams['UseSsl'] = $true
}
if ($profileObj.SkipCertificateCheck -or $SkipCertificateCheck) {
$connectParams['SkipCertificateCheck'] = $true
}
Connect-GpfsServer @connectParams
}
function Export-GpfsConfiguration {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)]
[string]$Path
)
$defaultPath = Join-Path $env:USERPROFILE '.PSGpfsApi\config.json'
if (-not (Test-Path $defaultPath)) {
throw "No configuration found at default path: $defaultPath"
}
if ($PSCmdlet.ShouldProcess($Path, 'Export configuration')) {
Copy-Item -Path $defaultPath -Destination $Path -Force
Write-Verbose "Configuration exported to: $Path"
}
}
function New-GpfsConfigurationProfile {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$Name,
[Parameter(Mandatory)]
[string]$Server,
[Parameter()]
[int]$Port = 443,
[Parameter()]
[string]$Username,
[Parameter()]
[bool]$SkipCertificateCheck = $false,
[Parameter()]
[switch]$SetActive
)
$setParams = @{
ProfileName = $Name
Server = $Server
Port = $Port
SkipCertificateCheck = $SkipCertificateCheck
SetActive = $SetActive
}
if ($Username) {
$setParams['Username'] = $Username
}
Set-GpfsConfiguration @setParams
}
function Select-GpfsConfigurationProfile {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$Profile,
[Parameter()]
[string]$Path = (Join-Path $env:USERPROFILE '.PSGpfsApi\config.json')
)
if (-not (Test-Path $Path)) {
throw "Configuration file not found: $Path"
}
$config = Get-Content $Path -Raw | ConvertFrom-Json
if (-not $config.Profiles.$Profile) {
throw "Profile '$Profile' not found in configuration."
}
if ($PSCmdlet.ShouldProcess($Profile, 'Set active profile')) {
$config.ActiveProfile = $Profile
$config | ConvertTo-Json -Depth 10 | Set-Content $Path -Encoding UTF8
Write-Verbose "Active profile set to: $Profile"
}
}

47
Public/GpfsDisk.ps1 Normal file
View file

@ -0,0 +1,47 @@
function Get-GpfsDisk {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, ParameterSetName = 'ByName', Position = 1)]
[string]$DiskName
)
if ($PSCmdlet.ParameterSetName -eq 'ByName') {
Invoke-GpfsApiRequest -Method GET -Endpoint "filesystems/$FilesystemName/disks/$DiskName"
}
else {
Invoke-GpfsApiRequest -Method GET -Endpoint "filesystems/$FilesystemName/disks"
}
}
function Add-GpfsDisk {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Add disk')) {
Invoke-GpfsApiRequest -Method POST -Endpoint "filesystems/$FilesystemName/disks" -Body $Settings
}
}
function Remove-GpfsDisk {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, Position = 1)]
[string]$DiskName
)
if ($PSCmdlet.ShouldProcess($DiskName, 'Remove disk')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "filesystems/$FilesystemName/disks/$DiskName"
}
}

98
Public/GpfsFileset.ps1 Normal file
View file

@ -0,0 +1,98 @@
function Get-GpfsFileset {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, ParameterSetName = 'ByName', Position = 1)]
[string]$FilesetName
)
if ($PSCmdlet.ParameterSetName -eq 'ByName') {
Invoke-GpfsApiRequest -Method GET -Endpoint "filesystems/$FilesystemName/filesets/$FilesetName"
}
else {
Invoke-GpfsApiRequest -Method GET -Endpoint "filesystems/$FilesystemName/filesets"
}
}
function New-GpfsFileset {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Create fileset')) {
Invoke-GpfsApiRequest -Method POST -Endpoint "filesystems/$FilesystemName/filesets" -Body $Settings
}
}
function Set-GpfsFileset {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, Position = 1)]
[string]$FilesetName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesetName, 'Update fileset')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint "filesystems/$FilesystemName/filesets/$FilesetName" -Body $Settings
}
}
function Remove-GpfsFileset {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, Position = 1)]
[string]$FilesetName
)
if ($PSCmdlet.ShouldProcess($FilesetName, 'Remove fileset')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "filesystems/$FilesystemName/filesets/$FilesetName"
}
}
function Register-GpfsFileset {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, Position = 1)]
[string]$FilesetName,
[Parameter(Mandatory)]
[hashtable]$LinkSettings
)
if ($PSCmdlet.ShouldProcess($FilesetName, 'Link fileset')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint "filesystems/$FilesystemName/filesets/$FilesetName/link" -Body $LinkSettings
}
}
function Unregister-GpfsFileset {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, Position = 1)]
[string]$FilesetName
)
if ($PSCmdlet.ShouldProcess($FilesetName, 'Unlink fileset')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "filesystems/$FilesystemName/filesets/$FilesetName/link"
}
}

53
Public/GpfsFilesystem.ps1 Normal file
View file

@ -0,0 +1,53 @@
function Get-GpfsFilesystem {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, ParameterSetName = 'ByName', Position = 0)]
[string]$FilesystemName
)
if ($PSCmdlet.ParameterSetName -eq 'ByName') {
Invoke-GpfsApiRequest -Method GET -Endpoint "filesystems/$FilesystemName"
}
else {
Invoke-GpfsApiRequest -Method GET -Endpoint 'filesystems'
}
}
function New-GpfsFilesystem {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess('filesystem', 'Create')) {
Invoke-GpfsApiRequest -Method POST -Endpoint 'filesystems' -Body $Settings
}
}
function Set-GpfsFilesystem {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Update filesystem')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint "filesystems/$FilesystemName" -Body $Settings
}
}
function Remove-GpfsFilesystem {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Remove filesystem')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "filesystems/$FilesystemName"
}
}

67
Public/GpfsJob.ps1 Normal file
View file

@ -0,0 +1,67 @@
function Get-GpfsJob {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, ParameterSetName = 'ById', Position = 0)]
[string]$JobId,
[Parameter(ParameterSetName = 'All')]
[ValidateSet('RUNNING', 'COMPLETED', 'FAILED', 'CANCELLED')]
[string]$Status
)
if ($PSCmdlet.ParameterSetName -eq 'ById') {
Invoke-GpfsApiRequest -Method GET -Endpoint "jobs/$JobId"
}
else {
$params = @{ Method = 'GET'; Endpoint = 'jobs' }
if ($Status) {
$params['QueryParameters'] = @{ status = $Status }
}
Invoke-GpfsApiRequest @params
}
}
function Remove-GpfsJob {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$JobId
)
if ($PSCmdlet.ShouldProcess($JobId, 'Remove job')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "jobs/$JobId"
}
}
function Wait-GpfsJob {
[CmdletBinding()]
param(
[Parameter(Mandatory, Position = 0)]
[string]$JobId,
[Parameter()]
[int]$PollingIntervalSeconds = 5,
[Parameter()]
[int]$TimeoutSeconds = 300
)
$start = Get-Date
do {
Start-Sleep -Seconds $PollingIntervalSeconds
$job = Invoke-GpfsApiRequest -Method GET -Endpoint "jobs/$JobId"
$currentStatus = $job.jobs[0].status
Write-Verbose "Job $JobId status: $currentStatus"
if ($currentStatus -in @('COMPLETED', 'FAILED', 'CANCELLED')) {
return $job
}
if (((Get-Date) - $start).TotalSeconds -ge $TimeoutSeconds) {
throw "Timed out waiting for job $JobId after $TimeoutSeconds seconds."
}
} while ($true)
}

53
Public/GpfsNfsExport.ps1 Normal file
View file

@ -0,0 +1,53 @@
function Get-GpfsNfsExport {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, ParameterSetName = 'ById', Position = 0)]
[string]$ExportId
)
if ($PSCmdlet.ParameterSetName -eq 'ById') {
Invoke-GpfsApiRequest -Method GET -Endpoint "nfs/exports/$ExportId"
}
else {
Invoke-GpfsApiRequest -Method GET -Endpoint 'nfs/exports'
}
}
function New-GpfsNfsExport {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess('NFS export', 'Create')) {
Invoke-GpfsApiRequest -Method POST -Endpoint 'nfs/exports' -Body $Settings
}
}
function Set-GpfsNfsExport {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$ExportId,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($ExportId, 'Update NFS export')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint "nfs/exports/$ExportId" -Body $Settings
}
}
function Remove-GpfsNfsExport {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$ExportId
)
if ($PSCmdlet.ShouldProcess($ExportId, 'Remove NFS export')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "nfs/exports/$ExportId"
}
}

41
Public/GpfsNode.ps1 Normal file
View file

@ -0,0 +1,41 @@
function Get-GpfsNode {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, ParameterSetName = 'ByName', Position = 0)]
[string]$NodeName
)
if ($PSCmdlet.ParameterSetName -eq 'ByName') {
Invoke-GpfsApiRequest -Method GET -Endpoint "nodes/$NodeName"
}
else {
Invoke-GpfsApiRequest -Method GET -Endpoint 'nodes'
}
}
function Set-GpfsNode {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$NodeName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($NodeName, 'Update node')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint "nodes/$NodeName" -Body $Settings
}
}
function Remove-GpfsNode {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$NodeName
)
if ($PSCmdlet.ShouldProcess($NodeName, 'Remove node')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "nodes/$NodeName"
}
}

24
Public/GpfsPolicy.ps1 Normal file
View file

@ -0,0 +1,24 @@
function Get-GpfsPolicy {
[CmdletBinding()]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName
)
Invoke-GpfsApiRequest -Method GET -Endpoint "filesystems/$FilesystemName/policies"
}
function Set-GpfsPolicy {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Apply policy')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint "filesystems/$FilesystemName/policies" -Body $Settings
}
}

65
Public/GpfsPool.ps1 Normal file
View file

@ -0,0 +1,65 @@
function Get-GpfsPool {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, ParameterSetName = 'ByName', Position = 1)]
[string]$PoolName
)
if ($PSCmdlet.ParameterSetName -eq 'ByName') {
Invoke-GpfsApiRequest -Method GET -Endpoint "filesystems/$FilesystemName/pools/$PoolName"
}
else {
Invoke-GpfsApiRequest -Method GET -Endpoint "filesystems/$FilesystemName/pools"
}
}
function New-GpfsPool {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Create pool')) {
Invoke-GpfsApiRequest -Method POST -Endpoint "filesystems/$FilesystemName/pools" -Body $Settings
}
}
function Set-GpfsPool {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, Position = 1)]
[string]$PoolName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($PoolName, 'Update pool')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint "filesystems/$FilesystemName/pools/$PoolName" -Body $Settings
}
}
function Remove-GpfsPool {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, Position = 1)]
[string]$PoolName
)
if ($PSCmdlet.ShouldProcess($PoolName, 'Remove pool')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "filesystems/$FilesystemName/pools/$PoolName"
}
}

72
Public/GpfsQuota.ps1 Normal file
View file

@ -0,0 +1,72 @@
function Get-GpfsQuota {
[CmdletBinding()]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter()]
[ValidateSet('USR', 'GRP', 'FILESET')]
[string]$QuotaType,
[Parameter()]
[string]$ObjectName,
[Parameter()]
[string]$FilesetName
)
$query = @{}
if ($QuotaType) { $query['quotaType'] = $QuotaType }
if ($ObjectName) { $query['objectName'] = $ObjectName }
if ($FilesetName){ $query['filesetName']= $FilesetName }
$params = @{ Method = 'GET'; Endpoint = "filesystems/$FilesystemName/quotas" }
if ($query.Count -gt 0) { $params['QueryParameters'] = $query }
Invoke-GpfsApiRequest @params
}
function New-GpfsQuota {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Create quota')) {
Invoke-GpfsApiRequest -Method POST -Endpoint "filesystems/$FilesystemName/quotas" -Body $Settings
}
}
function Set-GpfsQuota {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Update quota')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint "filesystems/$FilesystemName/quotas" -Body $Settings
}
}
function Remove-GpfsQuota {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Filter
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Remove quota')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "filesystems/$FilesystemName/quotas" -Body $Filter
}
}

53
Public/GpfsSmbShare.ps1 Normal file
View file

@ -0,0 +1,53 @@
function Get-GpfsSmbShare {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, ParameterSetName = 'ByName', Position = 0)]
[string]$ShareName
)
if ($PSCmdlet.ParameterSetName -eq 'ByName') {
Invoke-GpfsApiRequest -Method GET -Endpoint "smb/shares/$ShareName"
}
else {
Invoke-GpfsApiRequest -Method GET -Endpoint 'smb/shares'
}
}
function New-GpfsSmbShare {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess('SMB share', 'Create')) {
Invoke-GpfsApiRequest -Method POST -Endpoint 'smb/shares' -Body $Settings
}
}
function Set-GpfsSmbShare {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$ShareName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($ShareName, 'Update SMB share')) {
Invoke-GpfsApiRequest -Method PUT -Endpoint "smb/shares/$ShareName" -Body $Settings
}
}
function Remove-GpfsSmbShare {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$ShareName
)
if ($PSCmdlet.ShouldProcess($ShareName, 'Remove SMB share')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "smb/shares/$ShareName"
}
}

54
Public/GpfsSnapshot.ps1 Normal file
View file

@ -0,0 +1,54 @@
function Get-GpfsSnapshot {
[CmdletBinding(DefaultParameterSetName = 'All')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, ParameterSetName = 'ByName', Position = 1)]
[string]$SnapshotName,
[Parameter(ParameterSetName = 'All')]
[string]$FilesetName
)
if ($PSCmdlet.ParameterSetName -eq 'ByName') {
Invoke-GpfsApiRequest -Method GET -Endpoint "filesystems/$FilesystemName/snapshots/$SnapshotName"
}
else {
$params = @{ Method = 'GET'; Endpoint = "filesystems/$FilesystemName/snapshots" }
if ($FilesetName) {
$params['QueryParameters'] = @{ filesetName = $FilesetName }
}
Invoke-GpfsApiRequest @params
}
}
function New-GpfsSnapshot {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory)]
[hashtable]$Settings
)
if ($PSCmdlet.ShouldProcess($FilesystemName, 'Create snapshot')) {
Invoke-GpfsApiRequest -Method POST -Endpoint "filesystems/$FilesystemName/snapshots" -Body $Settings
}
}
function Remove-GpfsSnapshot {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
[Parameter(Mandatory, Position = 0)]
[string]$FilesystemName,
[Parameter(Mandatory, Position = 1)]
[string]$SnapshotName
)
if ($PSCmdlet.ShouldProcess($SnapshotName, 'Remove snapshot')) {
Invoke-GpfsApiRequest -Method DELETE -Endpoint "filesystems/$FilesystemName/snapshots/$SnapshotName"
}
}