snapshots.psm1
$SnapshotsDefaultProperties = ('name', 'index', 'sys-name', 'creation-time', 'created-from-volume') $SnapshotSetsDefaultProperties = ('name', 'index', 'sys-name', 'cg-name', 'num-of-vols') .(commonLib) Function Get-XtremSnapshots { <# .DESCRIPTION Displays the list of all Snapshots and their defined parameters. .PARAMETER Properties Array of properties requested from this call. .PARAMETER Filters Array of filters for this call. .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Get-XtremSnapshots #> [cmdletbinding()] [Alias('xmsSnapshotList')] Param ( [parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [parameter()] [Alias("Properties")] [string[]]$Property = $SnapshotsDefaultProperties, [parameter()] [Alias("Filters")] [array]$Filter, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest, [Parameter()] [switch]$Full = $false ) initCommand $Route = '/types/snapshots' if ($Full) { $Property = '' } $result = NewXtremRequest -Method GET -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -Properties $Property -ObjectSelection $ObjectSelection -Filters $Filter -ShowRest:$ShowRest.IsPresent -Multi -Full:$Full.IsPresent $result = formatOutPut $Property $result finalizeCommand return $result } # [Argumentcompleter( { doComplete $args 'snapshots' prop })] # [Argumentcompleter( { doComplete $args 'snapshots' filter })] # addCompleter Get-XtremSnapshots Property 'snapshots' prop # addCompleter Get-XtremSnapshots Filter 'snapshots' filter Function Get-XtremSnapshot { <# .DESCRIPTION Displays details of the selected Snapshot. .PARAMETER SnapshotName Snapshot's name or index number .PARAMETER Properties Array of properties requested from this call. .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Get-XtremSnapshot -SnapshotName testvol #> [cmdletbinding()] [Alias('xmsSnapshotGet')] Param ( [parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [Alias("Name", "Index")] [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [Argumentcompleter( { doComplete $args 'snapshots' name })] $SnapshotName, [Alias("Properties")] [array]$Property, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) initCommand $Route = '/types/snapshots' $Route, $GetProperty = SetParametersForRequest $Route $SnapshotName $result = NewXtremRequest -Method GET -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -ObjectSelection $ObjectSelection -GetProperty $GetProperty -Properties $Property -ShowRest:$ShowRest.IsPresent $result = formatOutPut $Property $result finalizeCommand return $result } # [Argumentcompleter( { doComplete $args 'snapshots' prop })] # addCompleter Get-XtremSnapshot Property 'snapshots' prop Function Remove-XtremSnapshot { <# .DESCRIPTION Enables you to delete a Snapshot. .PARAMETER SnapshotName Snapshot's name or index number. .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Remove-XtremSnapshot testSnap #> [CmdletBinding()] [Alias('xmsSnapshotRemove')] Param ( [Parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [Alias("Name", "Index")] [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [Argumentcompleter( { doComplete $args 'snapshots' name })] $SnapshotName, [Parameter()] [bool]$Confirm = (Get-XtremDefaultSession)._XtremCLIMode, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) $confirmed = IsConfirmed $Confirm if (!$confirmed) { return } initCommand $Route = '/types/snapshots' $Route, $GetProperty = SetParametersForRequest $Route $SnapshotName $result = NewXtremRequest -Endpoint $Route -Method DELETE -Session $Session -XtremClusterName $XtremClusterName -GetProperty $GetProperty -ShowRest:$ShowRest.IsPresent finalizeCommand return $result } Function Get-XtremSnapshotSets { <# .DESCRIPTION Displays the list of all Snapshot sets. .PARAMETER Properties Array of properties requested from this call. .PARAMETER Filters Array of filters for this call. .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Get-XtremSnapshotSets #> [cmdletbinding()] [Alias('xmsSnapshotSetList')] Param ( [parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [parameter()] [Alias("Properties")] [Argumentcompleter( { doComplete $args 'snapshot-sets' prop })] [string[]]$Property = $SnapshotSetsDefaultProperties, [parameter()] [Alias("Filters")] [Argumentcompleter( { doComplete $args 'snapshot-sets' filter })] [string[]]$Filter, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest, [Parameter()] [switch]$Full = $false ) initCommand $Route = '/types/snapshot-sets' if ($Full) { $Property = '' } $result = NewXtremRequest -Method GET -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -Properties $Property -ObjectSelection $ObjectSelection -ShowRest:$ShowRest.IsPresent -Multi -Full:$Full.IsPresent $result = formatOutPut $Property $result finalizeCommand return $result } Function Get-XtremSnapshotSet { <# .DESCRIPTION Return a specific snapshot-set .PARAMETER SnapshotSetName Snapshot set's name or index number .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Get-XtremSnapshotSet -SnapshotSetName setName #> [cmdletbinding()] [Alias('xmsSnapshotSetGet')] Param ( [parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [Alias("Name", "Index")] [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [Argumentcompleter( { doComplete $args 'snapshot-sets' name })] $SnapshotSetName, [parameter()] [Alias("Properties")] [Argumentcompleter( { doComplete $args 'snapshot-sets' prop })] [string[]]$Property, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) initCommand $Route = '/types/snapshot-sets' $Route, $GetProperty = SetParametersForRequest $Route $SnapshotSetName $result = NewXtremRequest -Method GET -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -Properties $Property -ObjectSelection $ObjectSelection -GetProperty $GetProperty -ShowRest:$ShowRest.IsPresent $result = formatOutPut $Property $result finalizeCommand return $result } Function New-XtremSnapshot { <# .DESCRIPTION Create a Snapshot on a Volume, list of Volumes, Consistency Group, Snapshot Set or Tag List. .PARAMETER snapshotType The Snapshot is read/write (default) or readonly. .PARAMETER SnapSuffix A string added after a Snapshot stem name, limited to 64 characters .PARAMETER SnapshotSetName Snapshot Set name fromwhich to create a new Snapshot .PARAMETER NewSnapshotSetName The name of the Snapshot Set. .PARAMETER ConsistencyGroupName Consistency Group name from which to create a new Snapshot .PARAMETER VolumeList List of Volume names or indexes from which to create a new Snapshot. .PARAMETER TagList List of Tag names or indexes from which to create a new Snapshot. Please Note: This parameter only supports Snapshots and Volumes. .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE New-XtremSnapshot -NewSnapshotSetName Set1 -SnapSuffix suffix -VolumeList testvol,testvol2 #> [CmdletBinding()] [Alias('xmsSnapshotCreate')] Param ( [Parameter()] [ValidateSet( 'regular', 'readonly')] [string]$snapshotType, [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [Alias("Name", "Index")] [Argumentcompleter( { doComplete $args 'snapshot-sets' name })] [ValidatePattern("^[^\[\]&\(\)`";,<>'/]+$")] [String]$NewSnapshotSetName, [Parameter()] [Argumentcompleter( { doComplete $args 'consistency-groups' name })] [string]$ConsistencyGroupName, [Parameter()] [Argumentcompleter( { doComplete $args 'snapshot-sets' name })] [string]$SnapshotSetName, [Parameter()] [Argumentcompleter( { doComplete $args 'volumes' name })] [array]$VolumeList, [Parameter()] [Argumentcompleter( { doComplete $args 'tags' name })] [array]$TagList, [Parameter()] [string]$SnapSuffix, [Parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) initCommand $Route = '/types/snapshots' $BodyList = @{ } AddIfExists -name "cluster-id" -value $XtremClusterName -list $BodyList AddIfExists -name "snapshot-set-name" -value $NewSnapshotSetName -list $BodyList AddIfExists -name "consistency-group-id" -value $ConsistencyGroupName -list $BodyList AddIfExists -name "snapshot-type" -value $snapshotType -list $BodyList AddIfExists -name "snap-suffix" -value $SnapSuffix -list $BodyList AddIfExists -name "snapshot-set-id" -value $SnapshotSetName -list $BodyList AddIfExists -name "volume-list" -value $VolumeList -list $BodyList AddIfExists -name "tag-list" -value $TagList -list $BodyList $Body = BuildXtremJson -list $BodyList $result = NewXtremRequest -Method POST -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -Body $Body -ObjectSelection $ObjectSelection -ShowRest:$ShowRest.IsPresent finalizeCommand return $result } Function New-XtremSnapshotAndReassign { <# .DESCRIPTION Create a Snapshot and reassign on a Volume, Consistency Group or Snapshot Set. .PARAMETER FromConsistencyGroupId Consistency Group's name or index number from which to create a new Snapshot. .PARAMETER FromSnapshotSetId Snapshot Set's name or index number from which to create a new Snapshot. .PARAMETER FromSnapshotSetTagId Snapshot Set's tag name or index number from which to create a new Snapshot. .PARAMETER FromVolumeId Volume name or index number from which to create a new Snapshot .PARAMETER ToConsistencyGroupId Consistency Group's name or index number to which to assign a new Snapshot. .PARAMETER ToSnapshotSetId Snapshot Set's name or index number to which to assign a new Snapshot. .PARAMETER ToSnapshotSetTagId Snapshot Set's Tag name or index number to which to assign a new Snapshot. .PARAMETER ToVolumeId Volume name or index number to which to assign a new Snapshot .PARAMETER BackupSnapshotType The back-up Snapshot type is regular (default) or readonly .PARAMETER BackupSnapSuffix Snapshot name suffix .PARAMETER NoBackup This parameter serves as a flag. If no-backup is included in the request, the source object is removed (regardless of the value entered for this property). .PARAMETER SnapshotSetName The name of the backup Snapshot Set .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE New-XtremSnapshotAndReassign -FromConsistencyGroupId:1 -ToSnapshotSetId:"snapshotset" -BackupSnapSuffix:"suffix" -BackupSnapshotType:"regular" #> [CmdletBinding()] [Alias('xmsSnapshotCreateAndReassign')] Param ( [Parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [Parameter()] $FromConsistencyGroupId, [Parameter()] $FromSnapshotSetId, [Parameter()] $FromSnapshotSetTagId, [Parameter()] $FromVolumeId, [Parameter()] $ToConsistencyGroupId, [Parameter()] $ToSnapshotSetId, [Parameter()] $ToSnapshotSetTagId, [Parameter()] $ToVolumeId, [Parameter()] [string]$BackupSnapshotType, [Parameter()] [string]$BackupSnapSuffix, [Parameter()] [switch]$NoBackup, [Parameter()] [Argumentcompleter( { doComplete $args 'snapshot-sets' name })] [ValidatePattern("^[^\[\]&\(\)`";,<>'/]+$")] [string]$SnapshotSetName, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) initCommand $Route = '/types/snapshot-sets' $BodyList = @{ } AddIfExists -name "cluster-id" -value $XtremClusterName -list $BodyList AddIfExists -name "from-consistency-group-id" -value $FromConsistencyGroupId -list $BodyList AddIfExists -name "from-snapshot-set-id" -value $FromSnapshotSetId -list $BodyList AddIfExists -name "from-snapshot-set-tag-id" -value $FromSnapshotSetTagId -list $BodyList AddIfExists -name "from-volume-id" -value $FromVolumeId -list $BodyList AddIfExists -name "to-consistency-group-id" -value $ToConsistencyGroupId -list $BodyList AddIfExists -name "to-snapshot-set-id" -value $ToSnapshotSetId -list $BodyList AddIfExists -name "to-snapshot-set-tag-id" -value $ToSnapshotSetTagId -list $BodyList AddIfExists -name "to-volume-id" -value $ToVolumeId -list $BodyList AddIfExists -name "backup-snapshot-type" -value $BackupSnapshotType -list $BodyList AddIfExists -name "backup-snap-suffix" -value $BackupSnapSuffix -list $BodyList AddIfExists -name "no-backup" -value $NoBackup.IsPresent -list $BodyList AddIfExists -name "snapshot-set-name" -value $SnapshotSetName -list $BodyList $Body = BuildXtremJson -list $BodyList $result = NewXtremRequest -Method POST -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -Body $Body -Username $Username -Password $Password -ObjectSelection $ObjectSelection -ShowRest:$ShowRest.IsPresent finalizeCommand return $result } Function Remove-XtremSnapshotSet { <# .DESCRIPTION Enables you to delete a Snapshot Set. .PARAMETER SnapshotSetName Snapshot Set's name or index number. .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Remove-XtremSnapshotSet -SnapshotSetName test #> [CmdletBinding()] [Alias('xmsSnapshotSetRemove')] Param ( [Parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [Alias("Name", "Index")] [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [Argumentcompleter( { doComplete $args 'snapshot-sets' name })] $SnapshotSetName, [Parameter()] [bool]$Confirm = (Get-XtremDefaultSession)._XtremCLIMode, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) $confirmed = IsConfirmed $Confirm if (!$confirmed) { return } initCommand $Route = '/types/snapshot-sets' $Route, $GetProperty = SetParametersForRequest $Route $SnapshotSetName $result = NewXtremRequest -Method DELETE -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -GetProperty $GetProperty -ShowRest:$ShowRest.IsPresent finalizeCommand return $result } Function Set-XtremSnapshotSet { <# .DESCRIPTION Enables you to rename a Snapshot Set. .PARAMETER SnapshotSetName Snapshot Set's name or index number .PARAMETER NewName Snapshot Set's new name .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Set-XtremSnapshotSet -SnapshotSetName Set -NewName NewSet #> [CmdletBinding()] [Alias('xmsSnapshotSetModify')] Param ( [Parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [Alias("Name", "Index")] [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0)] [Argumentcompleter( { doComplete $args 'snapshot-sets' name })] $SnapshotSetName, [Parameter()] [ValidatePattern("^[^\[\]&\(\)`";,<>'/]+$")] [String]$NewName, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) initCommand $Route = '/types/snapshot-sets' $Route, $GetProperty = SetParametersForRequest $Route $SnapshotSetName $BodyList = @{ } AddIfExists -name "cluster-id" -value $XtremClusterName -list $BodyList AddIfExists -name "new-name" -value $NewName -list $BodyList $Body = BuildXtremJson -list $BodyList $result = NewXtremRequest -Method PUT -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -GetProperty $GetProperty -Body $Body -ObjectSelection $ObjectSelection -ShowRest:$ShowRest.IsPresent finalizeCommand return $result } Function Refresh-XtremData { <# .DESCRIPTION Refresh Data .PARAMETER FromConsistencyGroupId Consistency Group's name or index number. .PARAMETER FromSnapshotSetId Snapshot Set's name or index number. .PARAMETER FromVolumeId Volume name or index number. .PARAMETER ToConsistencyGroupId Consistency Group's name or index number. .PARAMETER ToVolumeId Volume name or index number .PARAMETER BackupSnapSuffix Suffix .PARAMETER NoBackup Disable backup. .PARAMETER BackupSnapshotSetName The name of the backup Snapshot Set .PARAMETER IgnoreEmptyPair .PARAMETER DryRun .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Refresh-XtremData -FromConsistencyGroupId:1 -ToConsistencyGroupId:2 #> [CmdletBinding()] Param ( [Parameter(ParameterSetName = 'fromCG')] [Argumentcompleter( { doComplete $args 'consistency-groups' name })] $FromConsistencyGroupId, [Parameter(ParameterSetName = 'fromSnap')] $FromSnapshotSetId, [Parameter(ParameterSetName = 'fromSnapTag')] $FromSnapshotSetTagId, [Parameter(ParameterSetName = 'fromVolume')] [Argumentcompleter( { doComplete $args 'volumes' name })] $FromVolumeId, [Parameter(ParameterSetName = 'fromCG')] [Argumentcompleter( { doComplete $args 'consistency-groups' name })] $ToConsistencyGroupId, [Parameter(ParameterSetName = 'fromVolume')] [Argumentcompleter( { doComplete $args 'volumes' name })] $ToVolumeId, [string]$BackupSnapshotType, [Parameter()] [string]$BackupSnapSuffix, [Parameter()] [switch]$NoBackup, [Parameter()] [string]$BackupSnapshotSetName, [Parameter()] [switch]$DryRun, [Parameter()] [switch]$IgnoreEmptyPair, [Parameter()] [switch]$refreshData, [Parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) initCommand $Route = '/commands/volumes/refresh-data/' $BodyList = @{ } AddIfExists -name "cluster-id" -value $XtremClusterName -list $BodyList AddIfExists -name "from-consistency-group-id" -value $FromConsistencyGroupId -list $BodyList AddIfExists -name "from-snapshot-set-id" -value $FromSnapshotSetId -list $BodyList AddIfExists -name "from-volume-id" -value $FromVolumeId -list $BodyList AddIfExists -name "to-consistency-group-id" -value $ToConsistencyGroupId -list $BodyList AddIfExists -name "to-volume-id" -value $ToVolumeId -list $BodyList AddIfExists -name "backup-snap-suffix" -value $BackupSnapSuffix -list $BodyList AddIfExists -name "no-backup" -value $NoBackup.IsPresent -list $BodyList AddIfExists -name "snapshot-set-name" -value $BackupSnapshotSetName -list $BodyList AddIfExists -name "dry-run" -value $DryRun.IsPresent -list $BodyList AddIfExists -name "ignore-empty-pair" -value $IgnoreEmptyPair.IsPresent -list $BodyList AddIfExists -name "refresh-data" -value $DryRun.IsPresent -list $BodyList $Body = BuildXtremJson -list $BodyList $result = NewXtremRequest -Method PUT -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -Body $Body -ObjectSelection $ObjectSelection -ShowRest:$ShowRest.IsPresent finalizeCommand return $result } Function Restore-XtremData { <# .DESCRIPTION Restore Data .PARAMETER FromSnapshotSetId Snapshot Set's name or index number. .PARAMETER FromVolumeId Volume name or index number. .PARAMETER ToConsistencyGroupId Consistency Group's name or index number. .PARAMETER ToVolumeId Volume name or index number .PARAMETER BackupSnapSuffix suffix .PARAMETER NoBackup .PARAMETER SnapshotSetName The name of the backup Snapshot Set .PARAMETER DryRun .PARAMETER ShowRest Return an object represents the REST operation including URI , Method and JSON .EXAMPLE Restore-XtremData -FromSnapshotSetId:1 -ToConsistencyGroupId:2 #> [CmdletBinding()] Param ( [Parameter()] $XtremClusterName = (Get-XtremDefaultSession)._XtremClusterName, [Parameter()] $FromSnapshotSetId, [Parameter()] $FromSnapshotSetTagId, [Parameter()] $FromVolumeId, [Parameter()] $ToConsistencyGroupId, [Parameter()] $ToVolumeId, [Parameter()] [string]$BackupSnapshotType, [Parameter()] [string]$BackupSnapSuffix, [Parameter()] [switch]$NoBackup, [Parameter()] [Argumentcompleter( { doComplete $args 'snapshot-sets' name })] [string]$SnapshotSetName, [Parameter()] [switch]$DryRun = $false, [Parameter()] [string]$createdByExternalClient, [Parameter()] [object]$Session = (Get-XtremDefaultSession), [Parameter()] [switch]$ShowRest ) initCommand $Route = '/commands/volumes/restore-data/' $BodyList = @{ } AddIfExists -name "cluster-id" -value $XtremClusterName -list $BodyList AddIfExists -name "from-snapshot-set-id" -value $FromSnapshotSetId -list $BodyList AddIfExists -name "from-volume-id" -value $FromVolumeId -list $BodyList AddIfExists -name "to-consistency-group-id" -value $ToConsistencyGroupId -list $BodyList AddIfExists -name "to-volume-id" -value $ToVolumeId -list $BodyList AddIfExists -name "backup-snap-suffix" -value $BackupSnapSuffix -list $BodyList AddIfExists -name "no-backup" -value $NoBackup.IsPresent -list $BodyList AddIfExists -name "snapshot-set-name" -value $SnapshotSetName -list $BodyList AddIfExists -name "dry-run" -value $DryRun.IsPresent -list $BodyList AddIfExists -name "created-by-external-client" -value $IgnoreEmptyPair.IsPresent -list $BodyList $Body = BuildXtremJson -list $BodyList $result = NewXtremRequest -Method PUT -Endpoint $Route -Session $Session -XtremClusterName $XtremClusterName -Body $Body -ObjectSelection $ObjectSelection -ShowRest:$ShowRest.IsPresent finalizeCommand return $result } Export-ModuleMember *-* -Alias * |