@@ -64,7 +64,7 @@ function Get-PfaVMFSVol {
6464 else {
6565 $fa = get-pfaConnectionOfDatastore - datastore $datastore - flasharrays $flasharray
6666 }
67- $pureVolumes = Get-PfaVolumes - Array $fa
67+ $pureVolumes = New-PfaRestOperation - resourceType volume - restOperationType GET - flasharray $fa - SkipCertificateCheck
6868 $lun = $datastore.ExtensionData.Info.Vmfs.Extent.DiskName | select-object - unique
6969 $volserial = ($lun.ToUpper ()).substring(12 )
7070 $purevol = $purevolumes | where-object { $_.serial -eq $volserial }
@@ -123,6 +123,7 @@ function New-PfaVmfs {
123123
124124 [Parameter (ParameterSetName = ' GB' , Position = 2 , mandatory = $true )]
125125 [Parameter (ParameterSetName = ' TB' , Position = 2 , mandatory = $true )]
126+ [Parameter (ParameterSetName = ' Snapshot' , Position = 5 )]
126127 [ValidateScript ({
127128 if (($_ -match " ^[A-Za-z][a-zA-Z0-9\-_]+[a-zA-Z0-9]$" ) -and ($_.length -lt 64 ))
128129 {
@@ -169,13 +170,20 @@ function New-PfaVmfs {
169170 {
170171 foreach ($fa in $flasharray )
171172 {
172- $snapshot = Get-PfaVolumeSnapshot - Array $fa - SnapshotName $snapName
173+ $snapshot = $null
174+ $snapshot = New-PfaRestOperation - resourceType volume/ $ ($snapName ) - restOperationType GET - flasharray $fa - SkipCertificateCheck - queryFilter " ?snap=true"
173175 if ($null -ne $snapshot )
174176 {
175177 break
176178 }
177- }
178- $newDatastores = New-PfaVmfsFromSnapshot - cluster $cluster - flasharray $fa - snapName $snapshot.name
179+ }
180+ if ([string ]::IsNullOrEmpty($volName ))
181+ {
182+ $newDatastores = New-PfaVmfsFromSnapshot - cluster $cluster - flasharray $fa - snapName $snapshot.name
183+ }
184+ else {
185+ $newDatastores = New-PfaVmfsFromSnapshot - cluster $cluster - flasharray $fa - snapName $snapshot.name - volumeName $volName
186+ }
179187 $Global :CurrentFlashArray = $fa
180188 }
181189 else
@@ -189,18 +197,17 @@ function New-PfaVmfs {
189197 {
190198 for ($h = 0 ; $h -lt $volNames.Count ; $h ++ )
191199 {
192- Remove-PfaHostGroupVolumeConnection - Array $allFAs [$h ] - VolumeName $ volNames [$h ] - HostGroupName $hostGroupNames [$h ] | Out-Null
193- Remove-PfaVolumeOrSnapshot - Array $allFAs [$h ] - Name $volNames [$h ] | Out-Null
194- Remove-PfaVolumeOrSnapshot - Array $allFAs [$h ] - Name $volNames [$h ] - Eradicate | Out-Null
200+ New-PfaRestOperation - resourceType " hgroup/ $ ( $hostGroupNames [$h ]) /volume/ $ ( $ volNames [$h ]) " - restOperationType DELETE - flasharray $allFAs [$h ] - SkipCertificateCheck | Out-Null
201+ New-PfaRestOperation - resourceType " volume/ $ ( $volNames [$h ]) " - restOperationType DELETE - flasharray $allFAs [$h ] - SkipCertificateCheck | Out-Null
202+ New-PfaRestOperation - resourceType " volume/ $ ( $volNames [$h ]) " - restOperationType DELETE - flasharray $allFAs [$h ] - SkipCertificateCheck - queryFilter " ?eradicate=true " | Out-Null
195203 }
196- $cluster | get-pfaHostGroupfromVcCluster - flasharray $fa - ErrorAction Stop
197204 }
198205 if ($oneVolume -gt 0 )
199206 {
200207 if ($oneVolume -eq 1 )
201208 {
202209 $nameSuffix = (" -" + (get-random - Maximum 9999 - Minimum 1000 ))
203- Rename-PfaVolumeOrSnapshot - Array $lastFA - Name $volName - NewName ($volName + $ nameSuffix ) | Out-Null
210+ New-PfaRestOperation - resourceType " volume/ $ ( $volName ) " - restOperationType PUT - flasharray $lastFA - jsonBody " { `" name `" : `" $ ( $volName ) $ ( $ nameSuffix) `" } " - SkipCertificateCheck | Out-Null
204211 $volNames [0 ] = ($volName + " -" + $nameSuffix )
205212 $newName = ($volName + " -" + (get-random - Maximum 9999 - Minimum 1000 ))
206213 }
@@ -211,10 +218,10 @@ function New-PfaVmfs {
211218 else {
212219 $newName = $volName
213220 }
214- $newVol = New-PfaVolume - Array $fa - Size $volSize - VolumeName $newName - ErrorAction Stop
221+ $newVol = New-PfaRestOperation - resourceType " volume/ $ ( $newName ) " - restOperationType POST - flasharray $fa - jsonBody " { `" size `" : `" $ ( $volSize ) `" } " - SkipCertificateCheck - ErrorAction Stop
215222 $Global :CurrentFlashArray = $fa
216223 $lastFA = $fa
217- New-PfaHostGroupVolumeConnection - Array $fa - VolumeName $ newVol.name - HostGroupName $hostGroup .name | Out-Null
224+ New-PfaRestOperation - resourceType " hgroup/ $ ( $hostGroup .name ) /volume/ $ ( $ newVol.name ) " - restOperationType POST - flasharray $fa - SkipCertificateCheck - ErrorAction Stop | Out-Null
218225 $newNAAs += " naa.624a9370" + $newVol.serial.toLower ()
219226 $allFAs += $fa
220227 $volNames += $newVol.name
@@ -227,7 +234,7 @@ function New-PfaVmfs {
227234 {
228235 if ($newDatastores.count -lt 1 )
229236 {
230- $esxi = $cluster | get-vmhost | where-object {($_.version -like ' 5.5.*' ) -or ($_.version -like ' 6.*' )}| where-object {($_.ConnectionState -eq ' Connected' )} | Select-Object - last 1
237+ $esxi = $cluster | get-vmhost | where-object {($_.version -like ' 5.5.*' ) -or ($_.version -like ' 6.*' ) -or ( $_ .version -like ' 7.* ' ) }| where-object {($_.ConnectionState -eq ' Connected' )} | Select-Object - last 1
231238 $cluster | Get-VMHost | Get-VMHostStorage - RescanAllHba | Out-Null
232239 $ESXiApiVersion = $esxi.ExtensionData.Summary.Config.Product.ApiVersion
233240 $varCount = 0
@@ -248,9 +255,9 @@ function New-PfaVmfs {
248255 }
249256 catch {
250257 Write-Error $Global :Error [0 ]
251- Remove-PfaHostGroupVolumeConnection - Array $allFAs [$varCount ] - VolumeName $ volNames [$varCount ] - HostGroupName $hostGroupNames [$varCount ] | Out-Null
252- Remove-PfaVolumeOrSnapshot - Array $allFAs [$varCount ] - Name $volNames [$varCount ] | Out-Null
253- Remove-PfaVolumeOrSnapshot - Array $allFAs [$varCount ] - Name $volNames [$varCount ] - Eradicate | Out-Null
258+ New-PfaRestOperation - resourceType " hgroup/ $ ( $hostGroupNames [$varCount ]) /volume/ $ ( $ volNames [$varCount ]) " - restOperationType DELETE - flasharray $allFAs [$varCount ] - SkipCertificateCheck | Out-Null
259+ New-PfaRestOperation - resourceType " volume/ $ ( $volNames [$varCount ]) " - restOperationType DELETE - flasharray $allFAs [$varCount ] - SkipCertificateCheck | Out-Null
260+ New-PfaRestOperation - resourceType " volume/ $ ( $volNames [$varCount ]) " - restOperationType DELETE - flasharray $allFAs [$varCount ] - SkipCertificateCheck - queryFilter " ?eradicate=true " | Out-Null
254261 }
255262 $varCount ++
256263 }
@@ -340,7 +347,7 @@ function Add-PfaVmfsToCluster {
340347 else
341348 {
342349 try {
343- $faConnection = New-PfaHostGroupVolumeConnection - Array $fa - VolumeName $ pureVol.name - HostGroupName $hostGroup .name - ErrorAction Stop
350+ $faConnection = New-PfaRestOperation - resourceType " hgroup/ $ ( $hostGroup .name ) /volume/ $ ( $ pureVol.name ) " - restOperationType POST - flasharray $fa - SkipCertificateCheck - ErrorAction Stop
344351 }
345352 catch {
346353 Write-Error $Global :Error [0 ]
@@ -439,7 +446,7 @@ function Set-PfaVmfsCapacity {
439446 {
440447 throw " The new size cannot be smaller than the existing size. VMFS volumes cannot be shrunk."
441448 }
442- Resize-PfaVolume - Array $fa - VolumeName $pureVol.name - NewSize $volSize - ErrorAction Stop | Out-Null
449+ New-PfaRestOperation - resourceType " volume/ $ ( $pureVol.name ) " - restOperationType PUT - flasharray $fa - jsonBody " { `" size `" : $ ( $volSize ) } " - SkipCertificateCheck | Out-Null
443450 $Global :CurrentFlashArray = $fa
444451 foreach ($dsHost in $datastore.ExtensionData.Host.Key )
445452 {
@@ -525,7 +532,7 @@ function Get-PfaVmfsSnapshot {
525532 $fa = get-pfaConnectionOfDatastore - datastore $datastore - flasharrays $flasharray - ErrorAction Stop
526533 }
527534 $pureVol = $datastore | get-pfaVolfromVMFS - flasharray $fa - ErrorAction Stop
528- $volSnapshots = Get-PfaVolumeSnapshots - Array $fa - VolumeName $pureVol.name
535+ $volSnapshots = New-PfaRestOperation - resourceType " volume/ $ ( $pureVol.name ) " - restOperationType GET - flasharray $fa - SkipCertificateCheck - queryFilter " ?snap=true "
529536 $Global :CurrentFlashArray = $fa
530537 return $volSnapshots
531538}
@@ -643,10 +650,10 @@ function New-PfaVmfsSnapshot {
643650 $Global :CurrentFlashArray = $fa
644651 if ($suffix -ne " " )
645652 {
646- $newSnapshots += New-PfaVolumeSnapshots - Array $fa - Sources $ pureVol.name - Suffix $suffix
653+ $newSnapshots += New-PfaRestOperation - resourceType " volume " - restOperationType POST - flasharray $fa - jsonBody " { `" snap `" :true, `" source `" :[ `" $ ( $ pureVol.name ) `" ], `" suffix `" : `" $ ( $suffix ) `" } " - SkipCertificateCheck - ErrorAction Stop
647654 }
648655 else {
649- $newSnapshots += New-PfaVolumeSnapshots - Array $fa - Sources $ pureVol.name
656+ $newSnapshots += New-PfaRestOperation - resourceType " volume " - restOperationType POST - flasharray $fa - jsonBody " { `" snap `" :true, `" source `" :[ `" $ ( $ pureVol.name ) `" ]} " - SkipCertificateCheck - ErrorAction Stop
650657 }
651658
652659 }
@@ -711,24 +718,18 @@ function New-PfaVmfsFromSnapshot {
711718 [PurePowerShell.PureArray ]$flasharray ,
712719
713720 [Parameter (Position = 2 , mandatory = $true )]
714- [string ]$snapName
721+ [string ]$snapName ,
722+
723+ [Parameter (Position = 3 )]
724+ [string ]$volumeName
715725 )
716- $volumeName = $snapName.split (" ." )
717- if ($volumeName.count -eq 3 )
718- {
719- $volumeName = $volumeName [2 ]
720- } elseif ($volumeName.count -eq 2 )
726+ if ([string ]::IsNullOrWhiteSpace($volumeName ))
721727 {
722- $volumeName = $volumeName [0 ]
723- }
724- $volumeName = $volumeName.Split (" /" )
725- if ($volumeName.count -eq 2 ) {
726- $volumeName = $volumeName [1 ]
728+ $volumeName = " newVMFSfromsnapshot-" + (Get-Random - Minimum 10000 - Maximum 99999 )
727729 }
728- $volumeName = " $ ( $volumeName ) -snap-" + (Get-Random - Minimum 1000 - Maximum 9999 )
729- $newVol = New-PfaVolume - Array $flasharray - Source $snapName - VolumeName $volumeName - ErrorAction Stop
730+ $newVol = New-PfaRestOperation - resourceType " volume/$ ( $volumeName ) " - restOperationType POST - flasharray $flasharray - jsonBody " {`" source`" :`" $ ( $snapName ) `" }" - SkipCertificateCheck - ErrorAction Stop
730731 $hostGroup = $flasharray | get-pfaHostGroupfromVcCluster - cluster $cluster
731- New-PfaHostGroupVolumeConnection - Array $flasharray - VolumeName $ newVol.name - HostGroupName $hostGroup .name | Out-Null
732+ New-PfaRestOperation - resourceType " hgroup/ $ ( $hostGroup .name ) /volume/ $ ( $ newVol.name ) " - restOperationType POST - flasharray $flasharray - SkipCertificateCheck - ErrorAction Stop | Out-Null
732733 $esxi = $cluster | Get-VMHost | where-object {($_.ConnectionState -eq ' Connected' )} | Select-Object - last 1
733734 $esxi | Get-VMHostStorage - RescanAllHba - RescanVMFS - ErrorAction stop | Out-Null
734735 $hostStorage = get-view - ID $esxi.ExtensionData.ConfigManager.StorageSystem
@@ -770,9 +771,9 @@ function New-PfaVmfsFromSnapshot {
770771 }
771772 if ($deleteVol -eq $true )
772773 {
773- Remove-PfaHostGroupVolumeConnection - Array $flasharray - VolumeName $ newVol.name - HostGroupName $hostGroup .name | Out-Null
774- Remove-PfaVolumeOrSnapshot - Array $flasharray - Name $newVol.name | Out-Null
775- Remove-PfaVolumeOrSnapshot - Array $flasharray - Name $newVol.name - Eradicate | Out-Null
774+ New-PfaRestOperation - resourceType " hgroup/ $ ( $hostGroup .name ) /volume/ $ ( $ newVol.name ) " - restOperationType DELETE - flasharray $flasharray - SkipCertificateCheck | Out-Null
775+ New-PfaRestOperation - resourceType " volume/ $ ( $newVol.name ) " - restOperationType DELETE - flasharray $flasharray - SkipCertificateCheck | Out-Null
776+ New-PfaRestOperation - resourceType " volume/ $ ( $newVol.name ) " - restOperationType DELETE - flasharray $flasharray - SkipCertificateCheck - queryFilter " ?eradicate=true " | Out-Null
776777 return $null
777778 }
778779 $esxcli = get-esxcli - VMHost $esxi - v2 - ErrorAction stop
0 commit comments