PureStorage.CBS.AVS.VVOLS.ps1

function Mount-VvolDatastore {
    <#
    .SYNOPSIS
      Mounts a FlashArray VVol Datastore to a host or cluster
    .DESCRIPTION
      Mounts a FlashArray VVol Datastore to a cluster, connects a PE to the cluster if not present.
      The datastore will be created if it does not already exist. The function will return the exting (or newly created) datastore
    #>


    Param(
            [Parameter(Mandatory=$True)]
            $Flasharray,

            [Parameter(Mandatory=$True)]
            $vCenterServer,

            [Parameter(Mandatory=$false)]
            [string]$DatastoreName,

            [Parameter(Mandatory=$false)]
            [bool]$UseDefaultStore,

            [Parameter(Mandatory=$true,ValueFromPipeline=$True)]
            [VMware.VimAutomation.ViCore.Types.V1.Inventory.Cluster]$Cluster,

            [Parameter(Mandatory=$false)]
            [String]$AVSCloudName,

            [Parameter(Mandatory=$false)]
            [String]$AVSResourceGroup
    )
    if ($DatastoreName) {
        $datastore = Get-Datastore -Server $vCenterServer -Name $DatastoreName -ErrorAction Ignore
        if ($datastore) {
            throw "Cannot create the datastore. Datastore '$DatastoreName' already exists!"
        }
    }
    $arrayID = Get-ArrayID -FlashArray $Flasharray
    $arrayOui = Get-ArrayOUI -ArrayID $arrayID
    $ArrayName = Get-ArrayName -FlashArray $FlashArray

    if ($UseDefaultStore) {
        $scId = Get-RootStorageContainerID -ArrayID $arrayID
        $datastoreExists = Get-Datastore -Server $vCenterServer |Where-Object {$_.Type -eq "VVol"} |Where-Object {$_.ExtensionData.Info.VVolds.Scid -eq $scId}
        if (-not $datastoreExists)
        {
            if (-not $DatastoreName) {
                $DatastoreName = $ArrayName + "-vvol-DS"
            }
        }
        else {
            if (-not $DatastoreName) {
                $DatastoreName = $datastoreExists.Name
            }
        }
    }
    else {
        if (-not $DatastoreName) {
            throw "Datastore name must be provided when using non default containers."
        }
        # See if a pod was already created
        $pod = Get-Pfa2Pod -Array $Flasharray -Name $DatastoreName -ErrorAction Ignore
        if (-not $pod) {
            Write-Host "Creating a pod $DatastoreName ..."
            $pod = New-Pfa2Pod -Array $Flasharray -Name $DatastoreName -ErrorAction Stop
        }
        $pod_id = $pod.id.Replace("-","")
        $scid = "vvol:"+$pod_id.substring(0,16)+"-"+$pod_id.substring(16)
    }

    Write-Verbose "Using storage container ID '$scid'..."
    $datastoreExists = Get-Datastore |Where-Object {$_.Type -eq "VVol"} |Where-Object {$_.ExtensionData.Info.VVolds.Scid -eq $scId}
    if ($datastoreExists) {
        if ($DatastoreName -ne $datastoreExists.Name) {
            throw "A datastore '$($datastoreExists.Name)' already exists using container ID '$scid'. Will not be able to create a datastore with the name '$DatastoreName."
        }
        Write-Host "A datastore already exists. Using datastore $($datastoreExists.Name)..."
        $datastore = $datastoreExists
    }

    $esxiHosts = $cluster |Get-VMHost
    foreach ($esxi in $esxiHosts) {
        $hostPE = Find-ProtocolEndpoint -Esxi $esxi -DatastoreName $DatastoreName -UseDefaultStore $UseDefaultStore -arrayOui $arrayOui
        if (-not $hostPE)
        {
            if ($datastore)
            {
                $fa = Get-PfaConnectionOfDatastore -FlashArray $Flasharray -datastore $datastore -ErrorAction Ignore
                if ($null -eq $fa) {
                    throw "No protocol endpoints found on the host $($esxi.name) for this array. Attempt to provision a PE failed as no valid PowerShell connections found for the array. Please either provision the protocol endpoint or connect the array to an existing PE."
                }
            }

            $hGroup = Get-PfaHostGroupfromVcCluster -cluster $cluster -flasharray $Flasharray -ErrorAction Stop
            $allPEs = Get-Pfa2Volume -Array $Flasharray | Where-Object {$_.Subtype -eq "protocol_endpoint"}  -ErrorAction Stop
            if (($null -eq $protocolEndpoint) -or ($protocolEndpoint -eq ""))
            {
                $protocolEndpoint = "pure-protocol-endpoint"
                if (-not $UseDefaultStore) {
                    $ProtocolEndpoint = "$DatastoreName::$ProtocolEndpoint"
                }
            }
            $pe = $allPEs | Where-Object {$_.name -eq $protocolEndpoint}
            if ($null -eq $pe)
            {
                $pe = New-Pfa2Volume -Array $Flasharray -Name $protocolEndpoint -Subtype "protocol_endpoint"
            }
            try
            {
                New-Pfa2Connection -Array $FlashArray -HostGroupNames $hGroup.name -VolumeNames $pe.name -ErrorAction Stop
            }
            catch
            {
                if ($_.Exception -notlike "*Connection already exists.*")
                {
                    throw $_.Exception
                }
            }
            # Refresh VASA Providers
            $provider_id = (Get-VasaStorageArray -Server $vCenterServer -Id ("com.purestorage:" + (Get-Pfa2Array -Array $Flasharray).id)).provider.id
            Write-Host "Refreshing VASA Provider..."
            $out = Get-VasaProvider -Server $vCenterServer -id  $provider_id -Refresh
            Write-Host "Refreshed VASA provider $($out.Name) ($($out.Id)"
        }
    }

    $params = @{
            ClusterName = $Cluster.Name;
            DatastoreName = $DatastoreName;
            ScId = $SciD
    }
    Invoke-RunScript -RunCommandName  "New-VvolDatastore" -RunCommandModule "Microsoft.AVS.VVOLS" -Parameters $params `
            -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

    $datastore = Get-Datastore -Server $vCenterServer -Name $DatastoreName -ErrorAction stop
    return $datastore
}

function Dismount-VvolDatastore {
    Param(
        [Parameter(Mandatory=$True)]
        $Flasharray,

        [Parameter(Mandatory=$True)]
        $vCenterServer,

        [Parameter(Mandatory=$True)]
        [string]$DatastoreName,

        [Parameter(Mandatory=$true,ValueFromPipeline=$True)]
        [VMware.VimAutomation.ViCore.Types.V1.Inventory.Cluster]$Cluster,

        [Parameter(Mandatory=$false)]
        [String]$AVSCloudName,

        [Parameter(Mandatory=$false)]
        [String]$AVSResourceGroup
    )

    $Datastore = Get-Datastore -Server $vCenterServer -Name $DatastoreName -ErrorAction Ignore
    if (-not $Datastore) {
        throw "Datastore ($DatastoreName) does not exist."
    }

    if ("VVOL" -ne $Datastore.Type) {
        throw "Datastore $DatastoreName is of type $($Datastore.Type). This cmdlet can only process VVol datastores"
    }

    $params = @{
            ClusterName = $Cluster.Name;
            DatastoreName = $DatastoreName;
    }

    Write-Progress -Activity "Removing datastore" -Status "50% Complete:" -PercentComplete 50
    Invoke-RunScript -RunCommandName  "Remove-VvolDatastore" -RunCommandModule "Microsoft.AVS.VVOLS" -Parameters $params `
            -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
}

function Get-ArrayID {
    Param(
        [Parameter(Mandatory=$true)]
        $FlashArray
    )
    $ArrayID = "com.purestorage:" + (Get-Pfa2Array -Array $Flasharray).id
    return $arrayID
}

function Get-ArrayName {
    Param(
        [Parameter(Mandatory=$true)]
        $FlashArray
    )
    $ArrayName = (Get-Pfa2Array -Array $Flasharray).Name
    return $ArrayName
}

function Get-ArrayOUI {
    Param (
        [Parameter(Mandatory=$true)]
        [string]$ArrayID
    )
    $ArrayOui = $ArrayID.substring(16,36)
    $ArrayOui = $ArrayOui.replace("-","")
    $ArrayOui = $ArrayOui.Substring(0,16)
    return $ArrayOui
}


function Get-RootStorageContainerID {
    Param(
        [Parameter(Mandatory=$true)]
        [string]$ArrayID
    )
    $md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
    $utf8 = new-object -TypeName System.Text.UTF8Encoding
    $hash = $md5.ComputeHash($utf8.GetBytes($ArrayID.substring(16,36)))
    $hash2 = $md5.ComputeHash(($hash))
    $hash2[6] = $hash2[6] -band 0x0f
    $hash2[6] = $hash2[6] -bor 0x30
    $hash2[8] = $hash2[8] -band 0x3f
    $hash2[8] = $hash2[8] -bor 0x80
    $newGUID = (new-object -TypeName System.Guid -ArgumentList (,$hash2)).Guid
    $fixedGUID = $newGUID.Substring(18)
    $scId = $newGUID.Substring(6,2) + $newGUID.Substring(4,2) + $newGUID.Substring(2,2) + $newGUID.Substring(0,2) + "-" + $newGUID.Substring(11,2) + $newGUID.Substring(9,2) + "-" + $newGUID.Substring(16,2) + $newGUID.Substring(14,2) + $fixedGUID
    $scId = $scId.Replace("-","")
    $scId = "vvol:" + $scId.Insert(16,"-")
    return $scId
}


function Find-ProtocolEndpoint {
    Param (
        $Esxi,
        $DatastoreName,
        $UseDefaultStore,
        $arrayOui
    )
    $esxcli = $esxi |Get-EsxCli -v2
    $hostProtocolEndpoint = $esxcli.storage.core.device.list.invoke() |where-object {$_.IsVVOLPE -eq $true}
    foreach ($hostPE in $hostProtocolEndpoint)
    {
        $peID = $hostPE.Device.Substring(12,24)
        $peID = $peID.Substring(0,16)
        if ($UseDefaultStore) {
            if ($peID -eq $arrayOui) {
                return $hostPE

            }
        } else {
            $PEVolumes = Get-Pfa2Volume -Array $Flasharray | Where-Object {($_.Pod.Name -eq $DatastoreName) -and ($_.Subtype -eq "protocol_endpoint")}
            foreach ($peVolume in $PEVolumes) {
                $volumeSerial = $peVolume.Serial.ToLower()
                if ($hostPe.Device -like "*$volumeSerial*"){
                    return $hostPE
                }
            }
        }
    }
    return $null
}

function Get-PfaConnectionOfDatastore {
    <#
    .SYNOPSIS
      Takes in a vVol or VMFS datastore, FlashArray connections and returns the correct connection.
    .DESCRIPTION
      Takes in a vVol or VMFS datastore, FlashArray connections and returns the correct connection or $null if not connected.
    #>


    Param(

      [Parameter(Mandatory=$True,ValueFromPipeline=$True)]
      $Flasharray,

      [Parameter(Mandatory=$true,ValueFromPipeline=$True)]
      [ValidateScript({
        if (($_.Type -ne 'VMFS') -and ($_.Type -ne 'VVOL'))
        {
            throw "The entered datastore is not a VMFS or vVol datastore. It is type $($_.Type). Please only enter a VMFS or vVol datastore"
        }
        else {
          $true
        }
      })]
      [VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.Datastore]$Datastore
    )

    if ($datastore.Type -eq 'VMFS')
      {
          $lun = $datastore.ExtensionData.Info.Vmfs.Extent.DiskName |select-object -unique
          if ($lun -like 'naa.624a9370*')
          {
            $volserial = ($lun.ToUpper()).substring(12)
            $pureVolumes = Get-Pfa2Volume -Array $Flasharray
            $purevol = $purevolumes | where-object { $_.serial -eq $volserial }
            if ($null -ne $purevol.name)
            {
                return $flasharray
            }
          }
          else
          {
              throw "This VMFS is not hosted on FlashArray storage."
          }
      }
      elseif ($datastore.Type -eq 'VVOL')
      {
          $datastoreArraySerial = $datastore.ExtensionData.Info.VvolDS.StorageArray[0].uuid.Substring(16)

        $arraySerial = (Get-Pfa2Array -Array $Flasharray).id
        if ($arraySerial -eq $datastoreArraySerial)
        {
            return $flasharray
        }

      }
      # The datastore was not found on any of the FlashArray connections.
      return $null
}

function Wait-VvolDatastoreCreation {
    Param(
        [Parameter(Mandatory=$true)]
            [string]$DatastoreName
    )
    $retries = 0
    # Datastore will not be available immediately. The retry logic keeps query the status of the datastore
    while ($retries -le 10) {
      $latestDatastore = (Get-Datastore | Where-Object {$_.Name -eq $DatastoreName})
      if ("Available" -ne $latestDatastore.State) {
        $retries++
        Start-Sleep -s 5
      } else {
        Write-Host "The datastore '$($latestDatastore.Name)' is available"
        break
      }
      Write-Host "Waiting for the datastore '$($latestDatastore.Name)' to be available..."
    }

    if ("Available" -ne $latestDatastore.State) {
      throw "The datastore '$($datastore.Name)' is either not available or not acessible."
    }
}
function Update-VASAProviderCertificates {
    Param (
        [Parameter(Mandatory=$true)]
        $ControllerName,

        [Parameter(Mandatory=$true)]
        $MgmtIP,

        [Parameter(Mandatory=$true)]
        $VASAProvider,


        [Parameter(Mandatory=$true)]
        [PScredential] $FlashArrayCredential,

        [Parameter(Mandatory=$false)]
        [String]$AVSCloudName,

        [Parameter(Mandatory=$false)]
        [String]$AVSResourceGroup
    )

    $ArrayName = Get-ArrayName -FlashArray $FlashArray
    $cert_name = "vasa-$ControllerName"
    Write-Host "Removing certificate $cert_name from FlashArray: $ArrayName ..."
    Remove-Pfa2Certificate -Array $Flasharray -Name $cert_name 
    Write-Host "Creating self-signed certificate $cert_name on FlashArray: $ArrayName ..."
    New-Pfa2Certificate -Array $Flasharray -Name $cert_name -CommonName $MgmtIP.Eth.Address -Organization "Pure Storage" -OrganizationalUnit "Pure Storage" | Out-Null
    Write-Host "Removing VASA provider $provider_name ..."
    $param = @{
        ProviderName = $VASAProvider.Name;
    }
    Invoke-RunScript -RunCommandName  "Remove-VvolVasaProvider" -RunCommandModule "Microsoft.AVS.VVOLS" -Parameters $param `
            -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
}

function Get-VASAProviderFromControllerName {
    Param (
        $FlashArray,
        $ControllerName
    )
    $ArrayId = (Get-Pfa2Array -Array $FlashArray).Id
    $controller_num = $ControllerName.Substring(2)
    $ProviderId = "$ArrayId-$controller_num"
    $vasaProvider = Get-VasaProvider -Server $vCenterServer -ErrorAction Ignore | Where-Object {$_.ProviderId -eq $ProviderId}
    return $vasaProvider
}
function Update-VASAProvider {
    Param (
        [Parameter(ValueFromPipeline=$True)]
        $FlashArray,

        [Parameter(Mandatory=$true)]
        $vCenterServer,

        [Parameter(Mandatory=$true)]
        [PScredential] $FlashArrayCredential,

        [Parameter(Mandatory=$false)]
        [String]$AVSCloudName,

        [Parameter(Mandatory=$false)]
        [String]$AVSResourceGroup,

        [Parameter(Mandatory=$false)]
        [Switch]$RefreshOnly
    )

    $MaxRetryCount = 10
    $mgmtIPs =  Get-Pfa2NetworkInterface -Array $Flasharray | Where-Object {$_.services -eq "management" -and $_.Enabled -and $_.Name -like "ct*"}
    $registeredController = @()
    $ArrayName = Get-ArrayName -FlashArray $FlashArray
    foreach ($mgmtIP in $mgmtIPs)
    {
        $vasaRegistered = $false
        $retry_count = 0
        $controller_name = ($mgmtIp.Name.Split("."))[0]

        if ($registeredController -contains $controller_name) {
            continue
        }
        $provider_name = "$ArrayName-$controller_name"
        do
        {
            $vasaProvider = Get-VASAProviderFromControllerName -FlashArray $FlashArray -ControllerName $controller_name
            if ($vasaProvider) {
                Write-Host "VASA Provider already exists for ‘$ArrayName’ controller ‘$controller_name’..."
                if ($RefreshOnly) {
                    Update-VASAProviderCertificates -VASAProvider $vasaProvider -ControllerName $controller_name -mgmtIP $mgmtIP -FlashArrayCredential $FlashArrayCredential `
                            -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
                    $vasaRegistered = $False
                }
                elseif ($vasaProvider.status -eq "online") {
                    $vasaRegistered = $True
                }
                elseif ($vasaProvider.status -eq "offline") {
                    # VASA provider can be offline if:
                    # - Array is not accessible (in this case, we will get an error when trying to connect)
                    # - Certificate is expired
                    # - Certificate is invalid (for example a new certificate uploaded to the Array)
                    Write-Warning "VASA provider $provider_name status is $($vasaProvider.status)"
                    # No need to check for expiry time as the cert might not be expired but invalid. Remove the certificate and re-register the VASA provider

                    Update-VASAProviderCertificates -VASAProvider $vasaProvider -ControllerName $controller_name -mgmtIP $mgmtIP -FlashArrayCredential $FlashArrayCredential `
                            -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
                    $vasaRegistered = $False
                }
                else {
                    throw  "Could not update VASA provider. VASA provider $provider_name status is $($vasaProvider.status)."
                }
            }
            else {
                Write-Host "Creating VASA Provider for CBS '$ArrayName' controller '$controller_name'..."
                try {
                    $param = @{
                        ProviderName = $provider_name;
                        ProviderCredential = $FlashArrayCredential;
                        ProviderUrl = "https://$($mgmtIP.Eth.Address):8084";
                    }

                    Invoke-RunScript -RunCommandName  "New-VvolVasaProvider" -RunCommandModule "Microsoft.AVS.VVOLS" -Parameters $param `
                        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

                    $vasaRegistered = $True
                    Write-Host "VASA Provider for $provider_name created successfully."
                }
                catch {
                    if ($retry_count -lt $MaxRetryCount) {
                        Write-Warning "Failed to register VASA provider $provider_name with error $_ Retrying ..."
                        $vasaRegistered = $false
                        Start-Sleep -Seconds 10
                    }
                    else {
                        throw "Failed to register VASA provider $provider_name with error $_"
                    }
                }
            }
            $retry_count = $retry_count + 1
        }
        while ($vasaRegistered -ne $true -and $retry_count -lt $MaxRetryCount)
        if (-not $vasaRegistered) {
            throw "Failed to register VASA provider $provider_name after $retry_count tries."
        } else {
            $registeredController += $controller_name
        }
    }

    $param = @{}
    Invoke-RunScript -RunCommandName  "Update-VMHostCertificate" -RunCommandModule "Microsoft.AVS.VVOLS" -Parameters $param `
            -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

}

function New-VvolStoragePolicy {
    Param(
        [Parameter(Mandatory = $true)]
        [String]$PolicyName,

        [Parameter(Mandatory = $false)]
        [String]$PolicyDescription,

        [Parameter(Mandatory = $false)]
        [string[]]$SourcePureCloudBlockStores,

        [Parameter(Mandatory = $false)]
        [Nullable[boolean]]$ReplicationEnabled,

        [Parameter(Mandatory = $false)]
        [Nullable[Timespan]]$ReplicationInterval,

        [Parameter(Mandatory = $false)]
        [Nullable[Timespan]]$ReplicationRetentionInterval,

        [Parameter(Mandatory = $false)]
        [Nullable[boolean]]$ReplicationRuleLocalSnapshotEnabled,

        [Parameter(Mandatory = $false)]
        [Nullable[Timespan]]$ReplicationRuleLocalSnapshotInterval,

        [Parameter(Mandatory = $false)]
        [Nullable[Timespan]]$ReplicationRuleLocalSnapshotRetentionInterval,

        [Parameter(Mandatory = $false)]
        [int]$ReplicationConcurrency,

        [Parameter(Mandatory=$false)]
        [Nullable[boolean]]$ReplicationRansomwareProtection,

        [Parameter(Mandatory = $false)]
        [string[]]$TargetPureCloudBlockStores,

        [Parameter(Mandatory = $false)]
        [String]$ConsistencyGroupName,

        [Parameter(Mandatory = $false)]
        [int]$PerVirtualDiskIOPSLimit,

        [Parameter(Mandatory = $false)]
        [String]$PerVirtualDiskIOPSLimitUnit,

        [Parameter(Mandatory = $false)]
        [int]$PerVirtualDiskBandwidthLimit,

        [Parameter(Mandatory = $false)]
        [String]$PerVirtualDiskBandwidthLimitUnit,

        [Parameter(Mandatory = $false)]
        [String]$VolumeTaggingKey,

        [Parameter(Mandatory = $false)]
        [String]$VolumeTaggingValue,

        [Parameter(Mandatory = $false)]
        [Nullable[boolean]]$VolumeTaggingCopyable,

        [Parameter(Mandatory = $false)]
        [Nullable[Timespan]]$PlacementRuleLocalSnapshotInterval,

        [Parameter(Mandatory = $false)]
        [Nullable[Timespan]]$PlacementRuleLocalSnapshotRetentionInterval,

        [Parameter(Mandatory = $false)]
        [int]$PlacementRuleLocalSnapshotRetainAdditionalSnapshots,

        [Parameter(Mandatory = $false)]
        [int]$PlacementRuleLocalSnapshotRetainAdditionalDays,

        [Parameter(Mandatory=$false)]
        [string]$OffloadType,

        [Parameter(Mandatory=$false)]
        [string[]]$OffloadTargetNames,

        [Parameter(Mandatory=$false)]
        [Nullable[Timespan]]$OffloadReplicationInterval,

        [Parameter(Mandatory=$false)]
        [string]$OffloadOffloadReplicationTime,

        [Parameter(Mandatory=$false)]
        [Nullable[Timespan]]$OffloadRetentionInterval,

        [Parameter(Mandatory=$false)]
        [int]$OffloadRetainAdditionalSnapshots,

        [Parameter(Mandatory=$false)]
        [int]$OffloadRetainAdditionalDays,

        [Parameter(Mandatory=$false)]
        [string]$OffloadReplicationBlackoutFrom,

        [Parameter(Mandatory=$false)]
        [string]$OffloadReplicationBlackoutTo,

        [Parameter(Mandatory=$false)]
        [Nullable[boolean]]$DefaultProtectionOptout,

        [Parameter(Mandatory = $false)]
        [String]$AVSCloudName,

        [Parameter(Mandatory = $false)]
        [String]$AVSResourceGroup,

        [Parameter(Mandatory = $true)]
        [String]$vCenterServer
    )
    $StroagePolicy = Get-SpbmStoragePolicy -Server $vCenterServer -Name $PolicyName -ErrorAction Ignore
    if ($StroagePolicy) {
        throw "A storage policy with the name of $PolicyName already exists`n `n Please choose a unique name."
    }

    $PureCapability = Get-SpbmCapability -Server $vCenterServer | Where-Object { $_.name -like "com.purestorage*" }
    if (-not $PureCapability) {
        throw "This vCenter does not have any Pure VASA providers registered and therefore no policy can be created. ..."
    }

    Write-Host "Creating policy $PolicyName..."
    $policyConfig = [FlashArrayvVolPolicyConfig]::new($policyName,
                                                    $policyDescription,
                                                    $SourcePureCloudBlockStores,
                                                    $ReplicationEnabled,
                                                    $replicationInterval,
                                                    $replicationRetentionInterval,
                                                    $replicationConcurrency,
                                                    $consistencyGroupName,
                                                    $TargetPureCloudBlockStores,
                                                    $ReplicationRuleLocalSnapshotEnabled,
                                                    $ReplicationRuleLocalSnapshotInterval,
                                                    $ReplicationRuleLocalSnapshotRetentionInterval,
                                                    $ReplicationRansomwareProtection,
                                                    $PerVirtualDiskIOPSLimit,
                                                    $PerVirtualDiskIOPSLimitUnit,
                                                    $PerVirtualDiskBandwidthLimit,
                                                    $PerVirtualDiskBandwidthLimitUnit,
                                                    $VolumeTaggingKey,
                                                    $VolumeTaggingValue,
                                                    $VolumeTaggingCopyable,
                                                    $PlacementRuleLocalSnapshotInterval,
                                                    $PlacementRuleLocalSnapshotRetentionInterval,
                                                    $PlacementRuleLocalSnapshotRetainAdditionalSnapshots,
                                                    $PlacementRuleLocalSnapshotRetainAdditionalDays,
                                                    $OffloadType,
                                                    $OffloadTargetNames,
                                                    $OffloadReplicationInterval,
                                                    $OffloadOffloadReplicationTime,
                                                    $OffloadRetentionInterval,
                                                    $OffloadRetainAdditionalSnapshots,
                                                    $OffloadRetainAdditionalDays,
                                                    $OffloadReplicationBlackoutFrom,
                                                    $OffloadReplicationBlackoutTo,
                                                    $DefaultProtectionOptout
                                                    )
    $PolicyConfigJsonString = $policyConfig.ToJsonString()
    Write-Debug "PolicyConfigJsonString: $PolicyConfigJsonString"
    Invoke-RunScript -RunCommandName "New-VvolStoragePolicy" -RunCommandModule "Microsoft.AVS.VVOLS" -Parameters @{PolicyConfigJsonString = $PolicyConfigJsonString } -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
}

function Remove-VvolStoragePolicy {
    Param(
        [Parameter(mandatory = $true)]
        [string]$PolicyName,

        [Parameter(Mandatory = $false)]
        [String]$AVSCloudName,

        [Parameter(Mandatory = $false)]
        [String]$AVSResourceGroup,

        [Parameter(Mandatory = $true)]
        [String]$vCenterServer
    )
    $StroagePolicy = Get-SpbmStoragePolicy -Server $vCenterServer | Where-Object { $_.Name -eq $PolicyName }

    if (-not $StroagePolicy) {
        throw "No existing policy is found with policy name $PolicyName."
    }

    $PureCapability = $StroagePolicy.AnyOfRuleSets.AllOfRules.Capability | where-object { $_.Name -like "com.purestorage*" }
    if ($PureCapability.Count -eq 0) {
        throw "The policy $PolicyName is not managed by Pure Storage."
    }
    Invoke-RunScript -RunCommandName "Remove-VvolStoragePolicy" -RunCommandModule "Microsoft.AVS.VVOLS" -Parameters @{ PolicyName = $PolicyName } -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
}

#Custom Classes
Class FlashArrayvVolPolicyConfig {
    [String] $version = "1.0.0"
    [String] $vendor = "Pure Storage"
    [System.Boolean]$flasharray = $true
    [String]$policyName = ""
    [String]$policyDescription = "Pure Storage Cloud Block Store vVol storage policy default description"
    $SpbmRules = @{
    }


    FlashArrayvVolPolicyConfig ([String]$policyName,
                                [String]$policyDescription,
                                [String[]]$sourceFlashArrays,
                                [Nullable[boolean]]$replicationEnabled,
                                [Nullable[System.TimeSpan]]$replicationInterval,
                                [Nullable[System.TimeSpan]]$ReplicationRetentionInterval,
                                [int]$replicationConcurrency,
                                [String]$consistencyGroupName,
                                [String[]]$targetFlashArrays,
                                [Nullable[boolean]]$ReplicationRuleLocalSnapshotEnabled,
                                [Nullable[System.TimeSpan]]$ReplicationRuleLocalSnapshotInterval,
                                [Nullable[System.TimeSpan]]$ReplicationRuleLocalSnapshotRetentionInterval,
                                [Nullable[boolean]]$ReplicationRansomwareProtection,
                                [int]$PerVirtualDiskIOPSLimit,
                                [String]$PerVirtualDiskIOPSLimitUnit,
                                [int]$PerVirtualDiskBandwidthLimit,
                                [String]$PerVirtualDiskBandwidthLimitUnit,
                                [String]$VolumeTaggingKey,
                                [String]$VolumeTaggingValue,
                                [Nullable[boolean]]$VolumeTaggingCopyable,
                                [Nullable[System.TimeSpan]]$PlacementRuleLocalSnapshotInterval,
                                [Nullable[System.TimeSpan]]$PlacementRuleLocalSnapshotRetentionInterval,
                                [int]$PlacementRuleLocalSnapshotRetainAdditionalSnapshots,
                                [int]$PlacementRuleLocalSnapshotRetainAdditionalDays,
                                [string]$OffloadType,
                                [string[]]$OffloadTargetNames,
                                [Nullable[Timespan]]$OffloadReplicationInterval,
                                [string]$OffloadOffloadReplicationTime,
                                [Nullable[Timespan]]$OffloadRetentionInterval,
                                [int]$OffloadRetainAdditionalSnapshots,
                                [int]$OffloadRetainAdditionalDays,
                                [string]$OffloadReplicationBlackoutFrom,
                                [string]$OffloadReplicationBlackoutTo,
                                [Nullable[boolean]]$DefaultProtectionOptout)
    {
        $this.policyName = $policyName
        $this.policyDescription = $policyDescription

        if ($replicationEnabled -eq $false) {
            if ([System.TimeSpan]0 -ne $replicationInterval -and $null -ne $replicationInterval) {
                throw "Do not specify a replication interval if replicationEnabled is set to false."
            }
            if ([System.TimeSpan]0 -ne $ReplicationRetentionInterval -and $null -ne $ReplicationRetentionInterval) {
                throw "Do not specify a replication retention if replicationEnabled is set to false."
            }
        }
        if ($ReplicationRuleLocalSnapshotEnabled -eq $false) {
            if ([System.TimeSpan]0 -ne $ReplicationRuleLocalSnapshotInterval -and $null -ne $ReplicationRuleLocalSnapshotInterval) {
                throw "Do not specify a snapshot interval if ReplicationRuleLocalSnapshotEnabled is set to false."
            }
            if ([System.TimeSpan]0 -ne $ReplicationRuleLocalSnapshotRetentionInterval -and $null -ne $ReplicationRuleLocalSnapshotRetentionInterval) {
                throw "Do not specify a snapshot retention if ReplicationRuleLocalSnapshotEnabled is set to false."
            }
        }

        if ($null -eq $OffloadRetentionInterval) {
            if ($OffloadRetainAdditionalSnapshots -gt 0 -or $OffloadRetainAdditionalDays -gt 0) {
                throw "Do not specify additional retention options if Offload retention interval is not set."
            }
        }

        if ($sourceFlashArrays.count -ne 0) {
            $this.SpbmRules["com.purestorage.storage.policy.FlashArrayGroup"] = $sourceFlashArrays
        }
        $this.SpbmRules["com.purestorage.storage.policy.PureFlashArray"] = $true

        # Replication
        if ($null -ne $ReplicationRuleLocalSnapshotEnabled) {
            $this.SpbmRules["com.purestorage.storage.replication.LocalSnapshotPolicyCapable"] = $ReplicationRuleLocalSnapshotEnabled
        }
        if ($null -ne $ReplicationRuleLocalSnapshotInterval) {
            $this.SpbmRules["com.purestorage.storage.replication.LocalSnapshotInterval"] = $ReplicationRuleLocalSnapshotInterval.ToString()
        }
        if ($null -ne $ReplicationRuleLocalSnapshotRetentionInterval) {
            $this.SpbmRules["com.purestorage.storage.replication.LocalSnapshotRetention"] = $ReplicationRuleLocalSnapshotRetentionInterval.ToString()
        }
        if ($targetFlashArrays.count -ne 0) {
            $this.SpbmRules["com.purestorage.storage.replication.ReplicationTarget"] = $targetFlashArrays
        }
        if ($null -ne $replicationEnabled) {
            $this.SpbmRules["com.purestorage.storage.replication.RemoteReplicationCapable"] = $replicationEnabled
        }
        if ($null -ne $replicationInterval) {
            $this.SpbmRules["com.purestorage.storage.replication.RemoteReplicationInterval"] = $replicationInterval.ToString()
        }
        if ($null -ne $replicationRetentionInterval) {
            $this.SpbmRules["com.purestorage.storage.replication.RemoteReplicationRetention"] = $replicationRetentionInterval.ToString()
        }
        if (!([string]::IsNullOrWhiteSpace($consistencyGroupName))) {
            $this.SpbmRules["com.purestorage.storage.replication.ReplicationConsistencyGroup"] = $consistencyGroupName
        }
        if (($null -ne $replicationConcurrency) -and ($replicationConcurrency -ne 0)) {
            $this.SpbmRules["com.purestorage.storage.replication.replicationConcurrency"] = $replicationConcurrency
        }
        if ($null -ne $ReplicationRansomwareProtection) {
            $this.SpbmRules["com.purestorage.storage.replication.RansomwareProtection"] = $ReplicationRansomwareProtection
        }

        # IOPS Limit
        if (($null -ne $PerVirtualDiskIOPSLimit) -and ($PerVirtualDiskIOPSLimit -ne 0)) {
            $this.SpbmRules["com.purestorage.storage.policy.IopsLimit.IopsLimit"] = $PerVirtualDiskIOPSLimit
        }
        if (!([string]::IsNullOrWhiteSpace($PerVirtualDiskIOPSLimitUnit))) {
            $this.SpbmRules["com.purestorage.storage.policy.IopsLimit.IopsLimitUnit"] = $PerVirtualDiskIOPSLimitUnit
        }

        # Bandwidth Limit
        if (($null -ne $PerVirtualDiskBandwidthLimit) -and ($PerVirtualDiskBandwidthLimit -ne 0)) {
            $this.SpbmRules["com.purestorage.storage.policy.BandwidthLimit.BandwidthLimit"] = $PerVirtualDiskBandwidthLimit
        }
        if (!([string]::IsNullOrWhiteSpace($PerVirtualDiskBandwidthLimitUnit))) {
            $this.SpbmRules["com.purestorage.storage.policy.BandwidthLimit.BandwidthLimitUnit"] = $PerVirtualDiskBandwidthLimitUnit
        }

        # Volume Tag
        if (!([string]::IsNullOrWhiteSpace($VolumeTaggingKey))) {
            $this.SpbmRules["com.purestorage.storage.policy.VolumeTagging.TagKey"] = $VolumeTaggingKey
        }
        if (!([string]::IsNullOrWhiteSpace($VolumeTaggingValue))) {
            $this.SpbmRules["com.purestorage.storage.policy.VolumeTagging.TagValue"] = $VolumeTaggingValue
        }
        if ($null -ne $VolumeTaggingCopyable) {
            $this.SpbmRules["com.purestorage.storage.policy.VolumeTagging.TagCopyable"] = $VolumeTaggingCopyable
        }

        # Local snapshot
        if ($null -ne $PlacementRuleLocalSnapshotInterval) {
            $this.SpbmRules["com.purestorage.storage.policy.LocalSnapshotProtection.LocalSnapshotInterval"] = $PlacementRuleLocalSnapshotInterval.ToString()
        }
        if ($null -ne $PlacementRuleLocalSnapshotRetentionInterval) {
            $this.SpbmRules["com.purestorage.storage.policy.LocalSnapshotProtection.LocalSnapshotRetention"] = $PlacementRuleLocalSnapshotRetentionInterval.ToString()
        }
        if (($null -ne $PlacementRuleLocalSnapshotRetainAdditionalSnapshots) -and ($PlacementRuleLocalSnapshotRetainAdditionalSnapshots -ne 0)) {
            $this.SpbmRules["com.purestorage.storage.policy.LocalSnapshotProtection.LocalSnapshotThenRetain"] = $PlacementRuleLocalSnapshotRetainAdditionalSnapshots
        }
        if (($null -ne $PlacementRuleLocalSnapshotRetainAdditionalDays) -and ($PlacementRuleLocalSnapshotRetainAdditionalDays -ne 0)) {
            $this.SpbmRules["com.purestorage.storage.policy.LocalSnapshotProtection.LocalSnapshotForAdditionalDays"] = $PlacementRuleLocalSnapshotRetainAdditionalDays
        }

        # Offload
        if (!([string]::IsNullOrWhiteSpace($OffloadType))) {
            $this.SpbmRules["com.purestorage.storage.policy.Offload.OffloadTargetProtocol"] = $OffloadType
        }
        if ($null -ne $OffloadTargetNames) {
            $this.SpbmRules["com.purestorage.storage.policy.Offload.OffloadTargetNames"] = $OffloadTargetNames
        }
        if ($null -ne $OffloadReplicationInterval) {
            $this.SpbmRules["com.purestorage.storage.policy.Offload.OffloadReplicationInterval"] = $OffloadReplicationInterval.ToString()
        }
        if (!([string]::IsNullOrWhiteSpace($OffloadOffloadReplicationTime))) {
            $this.SpbmRules["com.purestorage.storage.policy.Offload.OffloadReplicationTime"] = $OffloadOffloadReplicationTime
        }
        if ($null -ne $OffloadRetentionInterval) {
            $this.SpbmRules["com.purestorage.storage.policy.Offload.OffloadRetentionInterval"] = $OffloadRetentionInterval.ToString()
        }
        if (($null -ne $OffloadRetainAdditionalSnapshots) -and ($OffloadRetainAdditionalSnapshots -ne 0)) {
            $this.SpbmRules["com.purestorage.storage.policy.Offload.OffloadRetentionExtraSnapshotsPerDay"] = $OffloadRetainAdditionalSnapshots
        }
        if (($null -ne $OffloadRetainAdditionalDays) -and ($OffloadRetainAdditionalDays -ne 0)) {
            $this.SpbmRules["com.purestorage.storage.policy.Offload.OffloadRetentionExtraSnapshotsDays"] = $OffloadRetainAdditionalDays
        }
        if (!([string]::IsNullOrWhiteSpace($OffloadReplicationBlackoutFrom))) {
            $this.SpbmRules["com.purestorage.storage.policy.Offload.OffloadReplicationBlackoutFrom"] = $OffloadReplicationBlackoutFrom
        }
        if (!([string]::IsNullOrWhiteSpace($OffloadReplicationBlackoutTo))) {
            $this.SpbmRules["com.purestorage.storage.policy.Offload.OffloadReplicationBlackoutTo"] = $OffloadReplicationBlackoutTo
        }

        # Default Protection
        if ($DefaultProtectionOptout) {
            $this.SpbmRules["com.purestorage.storage.policy.DefaultProtection"] = "Opt out"
        }
    }

    [string] ToJsonString() {
        return $this | ConvertTo-Json
    }
}



# SIG # Begin signature block
# MIIn+AYJKoZIhvcNAQcCoIIn6TCCJ+UCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0s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