@@ -79,9 +79,17 @@ function New-PfaRDM {
7979 [Parameter (Position = 6 , ValueFromPipeline = $True )]
8080 [VMware.VimAutomation.ViCore.Types.V1.VirtualDevice.ScsiController ]$scsiController ,
8181
82+ [Parameter (ParameterSetName = ' Snapshot' , Position = 7 )]
83+ [string ]$snapshot ,
84+
8285 [Parameter (ParameterSetName = ' Snapshot' , Position = 7 )]
8386 [string ]$snapshotName
8487 )
88+ if (! [string ]::IsNullOrWhiteSpace($snapshotName ))
89+ {
90+ Write-Warning - Message " The parameter `$ snapshotName is deprecated. Please use `$ snapshot instead"
91+ $snapshot = $snapshotName
92+ }
8593 $warningpreference = " SilentlyContinue"
8694 if ($null -eq $flasharray )
8795 {
@@ -130,9 +138,9 @@ function New-PfaRDM {
130138 throw " This VM is not on a host in a cluster. Non-clustered hosts are not supported by this script."
131139 }
132140 $hostGroup = $cluster | get-pfaHostGroupfromVcCluster - flasharray $flasharray - ErrorAction Stop
133- if ($snapshotName -ne " " )
141+ if (! [ string ]::IsNullOrWhiteSpace( $snapshot ) )
134142 {
135- $newVol = New-PfaRestOperation - resourceType " volume/$ ( $volName ) " - restOperationType POST - flasharray $flasharray - jsonBody " {`" source`" :`" $ ( $snapshotName ) `" }" - SkipCertificateCheck - ErrorAction Stop
143+ $newVol = New-PfaRestOperation - resourceType " volume/$ ( $volName ) " - restOperationType POST - flasharray $flasharray - jsonBody " {`" source`" :`" $ ( $snapshot ) `" }" - SkipCertificateCheck - ErrorAction Stop
136144 }
137145 else {
138146 $newVol = New-PfaRestOperation - resourceType " volume/$ ( $volName ) " - restOperationType POST - flasharray $flasharray - jsonBody " {`" size`" :`" $ ( $volSize ) `" }" - SkipCertificateCheck - ErrorAction Stop
@@ -480,7 +488,7 @@ function Get-PfaRDMSnapshot {
480488 })]
481489 [VMware.VimAutomation.ViCore.Types.V1.VirtualDevice.HardDisk ]$rdm ,
482490
483- [Parameter (Position = 1 , mandatory = $true , ValueFromPipeline = $True )]
491+ [Parameter (Position = 1 , ValueFromPipeline = $True )]
484492 [PurePowerShell.PureArray []]$flasharray
485493 )
486494 if ($null -eq $flasharray )
@@ -571,6 +579,11 @@ function Copy-PfaSnapshotToRDM {
571579 $vm = $rdm.Parent
572580 $controller = $rdm | Get-ScsiController
573581 $datastore = $rdm | Get-Datastore
582+ $foundSnap = New-PfaRestOperation - resourceType " volume/$ ( $snapshot ) ?snap=true" - restOperationType GET - flasharray $fa - SkipCertificateCheck - ErrorAction SilentlyContinue
583+ if ([string ]::IsNullOrWhiteSpace($foundSnap ))
584+ {
585+ throw " Entered snapshot $ ( $snapshot ) is not found on FlashArray $ ( $fa.endpoint ) . Please confirm snapshot name and retry. This requires the full name, not just a snapshot suffix."
586+ }
574587 Remove-HardDisk $rdm - DeletePermanently - Confirm:$false
575588 $refreshedVol = New-PfaRestOperation - resourceType " volume/$ ( $sourceVol.name ) " - restOperationType POST - flasharray $fa - jsonBody " {`" overwrite`" :true,`" source`" :`" $ ( $snapshot ) `" }" - SkipCertificateCheck - ErrorAction Stop
576589 $esxiHosts = $rdm.Parent | Get-VMHost
@@ -678,21 +691,21 @@ function Set-PfaRDMCapacity {
678691 $flasharray = getAllFlashArrays
679692 }
680693 $fa = get-pfaConnectionfromRDM - rdm $rdm - flasharray $flasharray - ErrorAction Stop
681- $pureVol = $rdm | Get-PfaRDMVol - flasharray $flasharray
694+ $pureVol = $rdm | Get-PfaRDMVol - flasharray $fa
682695 if (($truncate -ne $true ) -and ($pureVol.size -gt $volSize ))
683696 {
684697 throw " This operation will shrink the target RDM--please ensure this is expected and if so, please rerun the operation with the -truncate parameter."
685698 }
686699 $vm = $rdm.Parent
687700 $controller = $rdm | Get-ScsiController
688701 $datastore = $rdm | Get-Datastore
689- Remove-HardDisk $rdm - DeletePermanently - Confirm:$false
702+ Remove-HardDisk $rdm - DeletePermanently - Confirm:$false - ErrorAction Stop
690703 if ($truncate -eq $true )
691704 {
692- $expandedVol = New-PfaRestOperation - resourceType " volume/$ ( $pureVol.name ) " - restOperationType PUT - flasharray $flasharray - jsonBody " {`" truncate`" :true,`" size`" :$ ( $volSize ) }" - SkipCertificateCheck
705+ $expandedVol = New-PfaRestOperation - resourceType " volume/$ ( $pureVol.name ) " - restOperationType PUT - flasharray $fa - jsonBody " {`" truncate`" :true,`" size`" :$ ( $volSize ) }" - SkipCertificateCheck
693706 }
694707 else {
695- $expandedVol = New-PfaRestOperation - resourceType " volume/$ ( $pureVol.name ) " - restOperationType PUT - flasharray $flasharray - jsonBody " {`" size`" :$ ( $volSize ) }" - SkipCertificateCheck
708+ $expandedVol = New-PfaRestOperation - resourceType " volume/$ ( $pureVol.name ) " - restOperationType PUT - flasharray $fa - jsonBody " {`" size`" :$ ( $volSize ) }" - SkipCertificateCheck
696709 }
697710 $esxiHosts = $rdm.Parent | Get-VMHost
698711 foreach ($esxiHost in $esxiHosts )
@@ -705,7 +718,7 @@ function Set-PfaRDMCapacity {
705718 }
706719 $storageSystem.RefreshStorageSystem ()
707720 }
708- $expandedVol = New-PfaRestOperation - resourceType " volume/$ ( $expandedVol.name ) " - restOperationType GET - flasharray $flasharray - SkipCertificateCheck
721+ $expandedVol = New-PfaRestOperation - resourceType " volume/$ ( $expandedVol.name ) " - restOperationType GET - flasharray $fa - SkipCertificateCheck
709722 $newNAA = " naa.624a9370" + $expandedVol.serial.toLower ()
710723 $vm | new-harddisk - DeviceName " /vmfs/devices/disks/$ ( $newNAA ) " - DiskType RawPhysical - Controller $controller - Datastore $datastore - ErrorAction stop | Out-Null
711724 $rdmDisk = $vm | Get-harddisk | where-object {$_.DiskType -eq " RawPhysical" }| where-object {$null -ne $_.extensiondata.backing.lunuuid } | Where-Object {(" naa." + $_.ExtensionData.Backing.LunUuid.substring (10 ).substring(0 , 32 )) -eq $newNAA }
@@ -880,7 +893,7 @@ function Convert-PfaRDMToVvol {
880893 }
881894 $fa = get-pfaConnectionfromRDM - flasharray $flasharray - rdm $rdm - ErrorAction Stop
882895 $sourceVol = $rdm | Get-PfaRDMVol - flasharray $fa - ErrorAction Stop
883- $arraySerial = (New-PfaRestOperation - resourceType array - restOperationType GET - flasharray $flasharray - SkipCertificateCheck).id
896+ $arraySerial = (New-PfaRestOperation - resourceType array - restOperationType GET - flasharray $fa - SkipCertificateCheck).id
884897 if ($null -eq $datastore )
885898 {
886899 $datastores = $vm | get-vmhost | Get-Datastore | Where-Object {$_.Type -eq " VVOL" }
@@ -911,8 +924,8 @@ function Convert-PfaRDMToVvol {
911924 $vvolUuid = $vvolVmdk | get-vvolUuidFromHardDisk
912925 $targetVol = get-pfaVolumeNameFromVvolUuid - flasharray $fa - vvolUUID $vvolUuid
913926 New-PfaRestOperation - resourceType " volume/$ ( $sourceVol.name ) " - restOperationType PUT - flasharray $fa - jsonBody " {`" action`" :`" recover`" }" - SkipCertificateCheck | Out-Null
914- New-PfaRestOperation - resourceType " volume/$ ( $targetVol ) " - restOperationType POST - flasharray $fa - jsonBody " {`" source`" :`" $ ( $sourceVol.name ) `" }" - SkipCertificateCheck - ErrorAction Stop
915- New-PfaRestOperation - resourceType " volume/$ ( $sourceVol.nam ) " - restOperationType DELETE - flasharray $fa - SkipCertificateCheck | Out-Null
927+ New-PfaRestOperation - resourceType " volume/$ ( $targetVol ) " - restOperationType POST - flasharray $fa - jsonBody " {`" overwrite `" :true, `" source`" :`" $ ( $sourceVol.name ) `" }" - SkipCertificateCheck - ErrorAction Stop | Out-Null
928+ New-PfaRestOperation - resourceType " volume/$ ( $sourceVol.name ) " - restOperationType DELETE - flasharray $fa - SkipCertificateCheck | Out-Null
916929 return $vvolVmdk
917930}
918931function checkDefaultFlashArray {
0 commit comments