PureStorage.CBS.AVS.psm1

 . $PSScriptRoot/PureStorage.Logger.ps1
 . $PSScriptRoot/PureStorage.CommonUtil.ps1
 . $PSScriptRoot/PureStorage.RunCommandLauncher.ps1
 . $PSScriptRoot/PureStorage.CBS.AVS.VMFS.ps1
 . $PSScriptRoot/PureStorage.CBS.AVS.VVOLS.ps1
 . $PSScriptRoot/PureStorage.CBS.AVS.VVOLS.Replication.ps1
 . $PSScriptRoot/PureStorage.CBS.AVS.Configuration.ps1
 . $PSScriptRoot/PureStorage.CBS.AVS.Monitor.ps1

$VVOL_WARNIING = "vVols Cmdlets are experimental and not supported in this release. Please use with caution."
$DEFAULT_UTILIZATION_THRESHOLD = 80

function Build-PCBSCluster {
    <#
    .SYNOPSIS
     Build or update settings for a cluster of ESXi servers
    .DESCRIPTION
     Build or update settings for a cluster of ESXi servers. Creates a hostgroup in Pure Cloud Block Store if it does not exists and
     updates iSCSI settings. Can be used when creating a new cluster or when adding hosts to a cluster.
    .PARAMETER ClusterName
     Cluster name
    .PARAMETER PureCloudBlockStoreConnection
     Optional. Pure Cloud Block Store Connection. The connection can be created using Connect-Pf2Array cmdlet
    .PARAMETER AVSCloudName
     AVS cloud name
    .PARAMETER AVSResourceGroup
     AVS Resource group name
    .PARAMETER TimeoutInMinutes
     Optional. Timeout in minutes for RunCommand operations.
    .EXAMPLE
    Build-PCBSCluster -ClusterName "mycluster" -PureCloudBlockStoreConnection $CBSConnection `
      -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
    #>

    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$true, ValueFromPipeline=$true)]
        [String]$ClusterName,

        [Parameter(Mandatory=$false)]
        $PureCloudBlockStoreConnection,

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

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

        [Parameter(Mandatory=$false)]
        [ValidateRange(5, 60)]
        [int] $TimeoutInMinutes
    )

    Write-Progress -Activity "Building cluster" -Status "0% Complete:" -PercentComplete 1

    $fa = Connect-PureCloudBlockStore -PureCloudBlockStoreConnection $PureCloudBlockStoreConnection
    $WorkflowID = New-WorkflowID
    New-PhoneHomeWorkflowLogEntry -RestClient $fa -Event $global:BeginWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    try {
        $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName
        $cluster = Get-Cluster -Server $vCenterServer -Name $ClusterName
        if (-not $cluster) {
            throw "Could not find cluster '$ClusterName'..."
        }

        $TimeoutInMinutes = Get-Timeout -Cluster $cluster -InputParams $PSBoundParameters

        $ClusterStatus = Get-AVSClusterProvisionStatus -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName -AvsClusterName $ClusterName
        if ($ClusterStatus -ne "Succeeded") {
            throw "The current provisioning status of cluster $ClusterName is $ClusterStatus. The operation can only proceed when provisioning status is 'Succeeded'"
        }

        Test-MPIOProvisionStatus -Cluster $cluster

        Write-Progress -Activity "Configuring iSCSI" -Status "25% Complete:" -PercentComplete 25
        $updated_hosts = New-PfaHostGroupfromVcCluster -FlashArray $fa -Cluster $cluster `
        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes
        Write-Progress -Activity "Removing unused hosts" -Status "50% Complete:" -PercentComplete 50
        Remove-PfaUnusedHosts -FlashArray $fa -Cluster $cluster | Out-Null

        Write-Progress -Activity "Refreshing iSCSI targets" -Status "75% Complete:" -PercentComplete 75
        if ($updated_hosts) {
            $ethList = (Get-Pfa2NetworkInterface -Array $FlashArray | Where-Object {$_.services -eq "iscsi"} | Where-Object {$_.enabled -eq $true} | Where-Object {$null -ne $_.Eth.address}).Eth
            $ISCSIAddressList = @()
            foreach ($eth in $ethList) {
            $ISCSIAddressList += $eth.address
            }

            $params = @{
                ClusterName = $ClusterName
                # Need to join the list as string as RunCommand does not support array type
                ISCSIAddress = $ISCSIAddressList -join ","
            }

            Invoke-RunScript -RunCommandName  "Remove-VMHostStaticiSCSITargets" -RunCommandModule "Microsoft.AVS.VMFS" -Parameters $params `
                -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes
        }
        Write-Host "Cluster '$ClusterName' is successfully built"
        Write-Progress -Activity "Operation is done" -Status "100% Complete:" -PercentComplete 100
    }
    catch {
        New-PhoneHomeWorkflowLogEntry -RestClient $fa -Event $global:ErrorWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand -ErrorMessage $_
        throw
    }
    New-PhoneHomeWorkflowLogEntry -RestClient $fa -Event $global:CompleteWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}

function New-PCBSVmfsDatastore {
    <#
    .SYNOPSIS
      Creates a new VMFS datastore and mounts to a VMware cluster
    .DESCRIPTION
      Creates a new VMFS datastore and mounts to a VMware cluster
    .PARAMETER ClusterName
      Cluster name
    .PARAMETER DatastoreName
      Datastore name
    .PARAMETER Size
      Datastore capacity size in bytes
    .PARAMETER PodName
     Optional. Pod name. If the parameter is specified, the backing volume for the datastore will be created in the specified Pod.
    .PARAMETER NoDefaultProtection
     Optional. Bypass default protection group. If the parameter is specified, the datastore will not be protected by default protection group
    .PARAMETER PureCloudBlockStoreConnection
     Optional. Pure Cloud Block Store Connection. The connection can be created using Connect-Pf2Array cmdlet
    .PARAMETER AVSCloudName
     AVS cloud name
    .PARAMETER AVSResourceGroup
     AVS Resource group name
    .PARAMETER TimeoutInMinutes
      Optional. Timeout in minutes for RunCommand operations.

    .EXAMPLE
      New-PCBSVmfsDatastore -ClusterName myClusterName -PureCloudBlockStoreConnection $CBSConnection -DatastoreName MyVMFSStore -Size 4GB `
        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

      Create a datastore "MyVMFS"
    #>

    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$true)]
        [String]$ClusterName,

        [Parameter(Mandatory=$true, ValueFromPipeline=$true)]
        [String]$DatastoreName,

        [ValidateRange(1GB,64TB)] # 1 GB to 64 TB
        [Parameter(Mandatory=$true)]
        [UInt64]$Size,

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

        [Parameter(Mandatory=$false)]
        [switch] $NoDefaultProtection,

        [Parameter(Mandatory=$false)]
        $PureCloudBlockStoreConnection,

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

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

        [Parameter(Mandatory=$false)]
        [ValidateRange(5, 60)]
        [int] $TimeoutInMinutes
    )
    Write-Progress -Activity "Creating datastore" -Status "0% Complete:" -PercentComplete 1

    $fa = Connect-PureCloudBlockStore -PureCloudBlockStoreConnection $PureCloudBlockStoreConnection
    $WorkflowID = New-WorkflowID
    New-PhoneHomeWorkflowLogEntry -RestClient $fa -Event $global:BeginWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    try {
        $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName
        $Cluster = Get-Cluster -Server $vCenterServer -Name $ClusterName -ErrorAction Ignore
        if (-not $Cluster) {
            throw "Cluster $ClusterName does not exist."
        }

        $ClusterStatus = Get-AVSClusterProvisionStatus -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName -AvsClusterName $ClusterName
        if ($ClusterStatus -ne "Succeeded") {
            throw "The current provisioning status of cluster $ClusterName is $ClusterStatus. The operation can only proceed when provisioning status is 'Succeeded'"
        }
        $TimeoutInMinutes = Get-Timeout -Cluster $Cluster -InputParams $PSBoundParameters
        New-PfaVmfs -Cluster $Cluster -Flasharray $fa -Name $DatastoreName -vCenterServer $vCenterServer -Size $Size -NoDefaultProtection:$NoDefaultProtection.IsPresent `
            -PodName $PodName -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes

        Write-Host "Datastore '$DatastoreName' is successfully created"
        Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    } catch {
        New-PhoneHomeWorkflowLogEntry -RestClient $fa -Event $global:ErrorWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand -ErrorMessage $_
        throw
    }
    New-PhoneHomeWorkflowLogEntry -RestClient $fa -Event $global:CompleteWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}

function Restore-PCBSVmfsDatastore {
    <#
    .SYNOPSIS
      Mounts a copy of a VMFS datastore to a VMware cluster from a Pure Cloud Block Store snapshot, volume, or pod.
    .DESCRIPTION
      Takes in a snapshot/volume/pod name, the corresponding Pure Cloud Block Store, and a cluster. The VMFS copy will be resignatured and mounted.
    .PARAMETER ClusterName
      Cluster name
    .PARAMETER VolumeSnapshotName
      Volume snapshot name. A volume will be created from the volume snapshot. A datastore will be created from the volume
    .PARAMETER VolumeName
      Volume name. A datastore will be created from the volume. No volume copy will be created, the volume specified will be directly used for the datastore
    .PARAMETER ProtectionGroupSnapshotName
      Protection group snapshot name. All of volume snapshots of the protection group snapshot will be used for restoring. The snapshot will be skipped if not supported.
    .PARAMETER PodName
      Pod name. All of volumes of the pod will be used for restoring. The volume will be skipped if not supported
    .PARAMETER PureCloudBlockStoreConnection
      Optional. Pure Cloud Block Store Connection. The connection can be created using Connect-Pf2Array cmdlet
    .PARAMETER DatastoreName
      Optional. Datastore name. If the parameter is not specified, a generated name will be used.
    .PARAMETER AVSCloudName
      AVS cloud name
    .PARAMETER AVSResourceGroup
      AVS Resource group name
    .EXAMPLE
      Restore-PCBSVmfsDatastore -ClusterName myClusterName -VolumeSnapshotName mySnapshotName -PureCloudBlockStoreConnection $CBSConnection `
        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

      Takes in a snapshot name, the corresponding Pure Cloud Block Store, and a cluster. The VMFS copy will be resignatured and mounted.
    .EXAMPLE
      Restore-PCBSVmfsDatastore -ClusterName myClusterName -VolumeName myVolumeName -PureCloudBlockStoreConnection $CBSConnection `
        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

      Takes in a volume name, the corresponding Pure Cloud Block Store, and a cluster. The VMFS copy will be resignatured and mounted.
    #>

    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$true)]
        [String]$ClusterName,

        [Parameter(Mandatory = $true, ParameterSetName = 'VolumeSnapshot')]
        [String]$VolumeSnapshotName,

        [Parameter(Mandatory = $true, ParameterSetName = 'Volume')]
        [String]$VolumeName,

        [Parameter(Mandatory = $true, ParameterSetName = 'ProtectionGroupSnapshot')]
        [String]$ProtectionGroupSnapshotName,

        [Parameter(Mandatory = $true, ParameterSetName = 'Pod')]
        [String]$PodName,

        [Parameter(Mandatory = $false, ParameterSetName = 'Volume')]
        [Parameter(Mandatory = $false, ParameterSetName = 'VolumeSnapshot')]
        [String]$DatastoreName,

        [Parameter(Mandatory=$false)]
        $PureCloudBlockStoreConnection,

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


        [Parameter(Mandatory=$true)]
        [String]$AVSResourceGroup
    )
    Write-Progress -Activity "Restoring datastore" -Status "0% Complete:" -PercentComplete 1

    $fa = Connect-PureCloudBlockStore -PureCloudBlockStoreConnection $PureCloudBlockStoreConnection
    $WorkflowID = New-WorkflowID
    New-PhoneHomeWorkflowLogEntry -RestClient $fa -Event $global:BeginWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    try {
        $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName
        $Cluster = Get-Cluster -Server $vCenterServer -Name $ClusterName -ErrorAction Ignore
        if (-not $Cluster) {
            throw "Cluster '$ClusterName' does not exist."
        }

        $ClusterStatus = Get-AVSClusterProvisionStatus -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName -AvsClusterName $ClusterName
        if ($ClusterStatus -ne "Succeeded") {
            throw "The current provisioning status of cluster $ClusterName is $ClusterStatus. The operation can only proceed when provisioning status is 'Succeeded'"
        }

        if (-not [string]::IsNullOrEmpty($DatastoreName)) {
        $Datastore = Get-Datastore -Server $vCenterServer -Name $DatastoreName -ErrorAction Ignore
            if ($Datastore) {
                throw "Datastore '$Datastore' already exists."
            }
        }

        switch ($PSCmdlet.ParameterSetName) {
            'Volume' {
                Write-Host "Creating datastore from volume..."
            $NewDatastore = Restore-PfaVmfsFromVolume -FlashArray $fa -Cluster $Cluster -VolumeName $VolumeName -DatastoreName $DatastoreName `
                                    -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

                break
            }
            'VolumeSnapshot' {
                Write-Host "Creating datastore from volume snapshot..."
            $NewDatastore = Restore-PfaVmfsFromVolumeSnapshot -FlashArray $fa -Cluster $Cluster -VolumeSnapshotName $VolumeSnapshotName -DatastoreName $DatastoreName `
                                    -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

                break
            }
            'ProtectionGroupSnapshot' {
                Write-Host "Creating datastore from protection group snapshot..."
            $NewDatastore = Restore-PfaVmfsFromProtectionGroupSnapshot -FlashArray $fa -Cluster $Cluster -ProtectionGroupSnapshotName $ProtectionGroupSnapshotName `
                                    -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
                break
            }
            'Pod' {
                Write-Host "Creating datastore from pod..."
            $NewDatastore = Restore-PfaVmfsFromPod -FlashArray $fa -Cluster $Cluster -PodName $PodName `
                                    -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
                break
            }
        }
        Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed

        Write-Host "Datastore '$($NewDatastore.Name)' is successfully restored"
    } catch {
        New-PhoneHomeWorkflowLogEntry -RestClient $fa -Event $global:ErrorWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand -ErrorMessage $_
        throw
    }
    New-PhoneHomeWorkflowLogEntry -RestClient $fa -Event $global:CompleteWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
    return $NewDatastore
}


function Remove-PCBSVmfsDatastore {
  <#
    .SYNOPSIS
     Detaches and unmount a VMFS datastore from a cluster. Remove the datastore from the host group
    .DESCRIPTION
     Detaches and unmount a VMFS datastore from a cluster. Remove the datastore from the host group. The connection configured for the volume and cluster host/host group will be removed from Pure Cloud Block Store. The volume will be destroyed if there is no other connection left.
    .PARAMETER ClusterName
     Cluster name
    .PARAMETER DatastoreName
     Datastore name
    .PARAMETER PureCloudBlockStoreConnection
     Optional. Pure Cloud Block Store Connection. The connection can be created using Connect-Pf2Array cmdlet
    .PARAMETER AVSCloudName
     AVS cloud name
    .PARAMETER AVSResourceGroup
     AVS Resource group name
    .PARAMETER TimeoutInMinutes
    Optional. Timeout in minutes for RunCommand operations.
    .EXAMPLE
     Remove-PCBSVmfsDatastore -ClusterName "mycluster" -DatastoreName "myDatastore" PureCloudBlockStoreConnection $CBSConnection `
        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

     Takes in a datastore name, datastore would be removed.
    #>

    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$true)]
        [String]$ClusterName,

        [Parameter(Mandatory=$true, ValueFromPipeline=$true)]
        [String]$DatastoreName,

        [Parameter(Mandatory=$false)]
        $PureCloudBlockStoreConnection,

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

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

        [Parameter(Mandatory=$false)]
        [ValidateRange(5, 60)]
        [int] $TimeoutInMinutes
    )
    Write-Progress -Activity "Removing datastore" -Status "0% Complete:" -PercentComplete 1
    $FlashArray = Connect-PureCloudBlockStore -PureCloudBlockStoreConnection $PureCloudBlockStoreConnection
    $WorkflowID = New-WorkflowID
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:BeginWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    try {
        $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName
        $Cluster = Get-Cluster -Server $vCenterServer -Name $ClusterName -ErrorAction Ignore
        if (-not $Cluster) {
            throw "Cluster '$ClusterName' does not exist."
        }

        $TimeoutInMinutes = Get-Timeout -Cluster $cluster -InputParams $PSBoundParameters

        $ClusterStatus = Get-AVSClusterProvisionStatus -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName -AvsClusterName $ClusterName
        if ($ClusterStatus -ne "Succeeded") {
            throw "The current provisioning status of cluster $ClusterName is $ClusterStatus. The operation can only proceed when provisioning status is 'Succeeded'"
        }

        $Datastore = Get-Datastore -Server $vCenterServer -Name $DatastoreName -ErrorAction Ignore
        if (-not $Datastore) {
            throw "Datastore '$DatastoreName' does not exist."
        }
        Remove-PfaVmfsDatastore -Cluster $Cluster -Datastore $DataStore -FlashArray $FlashArray `
            -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes

        Write-Host "Datastore '$DatastoreName' is successfully removed"
        Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    } catch {
        New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:ErrorWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand -ErrorMessage $_
        throw
    }
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:CompleteWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}


function Set-PCBSVmfsCapacity {
  <#
    .SYNOPSIS
     Increase the size of a Pure Cloud Block Store-based VMFS datastore.
    .DESCRIPTION
     Takes in a datastore, the corresponding Pure Cloud Block Store, and a new size. Both the volume and the VMFS will be grown.
    .PARAMETER ClusterName
     Cluster name
    .PARAMETER DatastoreName
     Datastore name
    .PARAMETER Size
     New datastore capacity size in bytes
    .PARAMETER PureCloudBlockStoreConnection
     Optional. Pure Cloud Block Store Connection. The connection can be created using Connect-Pf2Array cmdlet
    .PARAMETER AVSCloudName
     AVS cloud name
    .PARAMETER AVSResourceGroup
     AVS Resource group name
    .PARAMETER TimeoutInMinutes
      Optional. Timeout in minutes for RunCommand operations.
    .EXAMPLE
     Set-PCBSVmfsCapacity -ClusterName "mycluster" -DatastoreName myDatastore -Size 3GB -PureCloudBlockStoreConnection $CBSConnection `
        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

     Expand size of the datastore myDatastore to 3GB.
    #>

    [CmdletBinding()]
    Param (
          [Parameter(Mandatory=$true)]
          [String]$ClusterName,

          [Parameter(Mandatory=$true, ValueFromPipeline=$true)]
          [string]$DatastoreName,

          [ValidateRange(1GB,64TB)] # 1 GB to 64 TB
          [Parameter(Mandatory=$true)]
          [UInt64]$Size,

          [Parameter(Mandatory=$false)]
          $PureCloudBlockStoreConnection,

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

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

          [Parameter(Mandatory=$false)]
          [ValidateRange(5, 60)]
          [int]$TimeoutInMinutes
    )
    Write-Progress -Activity "Resizing datastore" -Status "0% Complete:" -PercentComplete 1

    $FlashArray = Connect-PureCloudBlockStore -PureCloudBlockStoreConnection $PureCloudBlockStoreConnection
    $WorkflowID = New-WorkflowID
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:BeginWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    try {
        $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName
        $Cluster = Get-Cluster -Server $vCenterServer -Name $ClusterName -ErrorAction Ignore
        if (-not $Cluster) {
            throw "Cluster '$ClusterName' does not exist."
        }

        $TimeoutInMinutes = Get-Timeout -Cluster $cluster -InputParams $PSBoundParameters

        $ClusterStatus = Get-AVSClusterProvisionStatus -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName -AvsClusterName $ClusterName
        if ($ClusterStatus -ne "Succeeded") {
            throw "The current provisioning status of cluster $ClusterName is $ClusterStatus. The operation can only proceed when provisioning status is 'Succeeded'"
        }

        $Datastore = Get-Datastore -Server $vCenterServer -Name $DatastoreName -ErrorAction SilentlyContinue
        if (-not $Datastore) {
            throw "Could not find datastore '$DatastoreName'! Please make sure to select an existing datastore."
        }
        Set-PfaVmfsCapacity -Cluster $Cluster -FlashArray $FlashArray -Datastore $Datastore -SizeInByte $Size `
            -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes

        Write-Host "Datastore '$DatastoreName' is successfully resized"
        Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    } catch {
        New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:ErrorWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand -ErrorMessage $_
        throw
    }
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:CompleteWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}


function New-PCBSVASAProvider {
    <#
    .SYNOPSIS
    Register Pure Cloud Block Store VASA providers with vCenter

    .DESCRIPTION
    Register Pure Cloud Block Store VASA providers for all array controllers with vCenter. If a VASA provider has a certificate problem, it will be created

    .PARAMETER PureCloudBlockStoreConnection
    Optional. Pure Cloud Block Store Connection. The connection can be created using Connect-Pf2Array cmdlet

    .PARAMETER PureCloudBlockStoreCredential
    Pure Cloud BlockStore Credential

    .PARAMETER AVSCloudName
    AVS cloud name

    .PARAMETER AVSResourceGroup
    AVS Resource group name

    .PARAMETER TimeoutInMinutes
    Optional. Timeout in minutes for RunCommand operations.

    .EXAMPLE
    New-PCBSVASAProvider -PureCloudBlockStoreConnection $CBSConnection -PureCloudBlockStoreCredential $CBSConnectionCredential `
        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

    #>

    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$false)]
        $PureCloudBlockStoreConnection,

        [Parameter(Mandatory=$true)]
        [PSCredential]$PureCloudBlockStoreCredential,

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

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

        [Parameter(Mandatory=$false)]
        [ValidateRange(5, 60)]
        [int]$TimeoutInMinutes = 10
    )

    Write-Warning $VVOL_WARNIING
    Write-Progress -Activity "Register VASA provider" -Status "0% Complete:" -PercentComplete 1
    $FlashArray = Connect-PureCloudBlockStore -PureCloudBlockStoreConnection $PureCloudBlockStoreConnection
    $WorkflowID = New-WorkflowID
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:BeginWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    try {
        $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName
        Update-VASAProvider -vCenterServer $vCenterServer -FlashArray $FlashArray -FlashArrayCredential $PureCloudBlockStoreCredential `
                            -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes
    }catch {
        New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:ErrorWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand -ErrorMessage $_
        throw
    }
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:CompleteWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    Write-Host "VASA provider is successfully registered."
    Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}

function Update-PCBSVASAProvider {
    <#
    .SYNOPSIS
    Refresh Pure Cloud Block Store VASA provider vCenter certificates

    .DESCRIPTION
    Refresh Pure Cloud Block Store VASA provider vCenter certificates

    .PARAMETER PureCloudBlockStoreConnection
    Optional. Pure Cloud Block Store Connection. The connection can be created using Connect-Pf2Array cmdlet

    .PARAMETER PureCloudBlockStoreCredential
    Pure Cloud BlockStore Credential

    .PARAMETER AVSCloudName
    AVS cloud name

    .PARAMETER AVSResourceGroup
    AVS Resource group name

    .PARAMETER TimeoutInMinutes
    Optional. Timeout in minutes for RunCommand operations.

    .EXAMPLE
    Update-PCBSVASAProvider -PureCloudBlockStoreConnection $CBSConnection -PureCloudBlockStoreCredential $CBSConnectionCredential `
        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

    #>

    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$false)]
        $PureCloudBlockStoreConnection,

        [Parameter(Mandatory=$true)]
        [PSCredential]$PureCloudBlockStoreCredential,

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


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

        [Parameter(Mandatory=$false)]
        [ValidateRange(5, 60)]
        [int]$TimeoutInMinutes = 10
    )

    Write-Warning $VVOL_WARNIING
    Write-Progress -Activity "Update VASA provider" -Status "0% Complete:" -PercentComplete 1
    $FlashArray = Connect-PureCloudBlockStore -PureCloudBlockStoreConnection $PureCloudBlockStoreConnection
    $WorkflowID = New-WorkflowID
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:BeginWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    try {
        $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName
        Update-VASAProvider -vCenterServer $vCenterServer -FlashArray $FlashArray -FlashArrayCredential $PureCloudBlockStoreCredential -RefreshOnly `
          -AVSResourceGroup $AVSResourceGroup -AVSCloudName $AVSCloudName -TimeoutInMinutes $TimeoutInMinutes
    }catch {
        New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:ErrorWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand -ErrorMessage $_
        throw
    }
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:CompleteWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    Write-Host "VASA provider is successfully updated."
    Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}

function New-PCBSVvolDataStore {
    <#
    .SYNOPSIS
    Mount a vVol datastore on all of the hosts in the cluster.

    .DESCRIPTION
    Mount a vVol datastore on all of the hosts in the cluster.

    .PARAMETER ClusterName
    Cluster name

    .PARAMETER DatastoreName
    Optional. Datastore name. If not provided, a datastore name driven from the Pure Cloud Clock Store Name will be used

    .PARAMETER UseDefaultStore
    Optional. Indicates whether to use default root container. If not provided, the default store will not be used and multi-storage Pod container will be used.
    Note that Non-default store can only be used with Pure Cloud Block Store version 6.4.1 or later.

    .PARAMETER PureCloudBlockStoreConnection
    Optional. Pure Cloud Block Store Connection. The connection can be created using Connect-Pf2Array cmdlet

    .PARAMETER AVSCloudName
    AVS cloud name

    .PARAMETER AVSResourceGroup
    AVS resource group name

    .PARAMETER TimeoutInMinutes
    Optional. Timeout in minutes for RunCommand operations.

    .EXAMPLE
    New-PCBSVVolDataStore -ClusterName "mycluster" -DatastoreName "myDatastore" -PureCloudBlockStoreConnection $CBSConnection `
        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

    #>

    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true)]
        [String]$ClusterName,

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

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

        [Parameter(Mandatory=$false)]
        $PureCloudBlockStoreConnection,

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


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

        [Parameter(Mandatory=$false)]
        [ValidateRange(5, 60)]
        [int]$TimeoutInMinutes
    )

    Write-Warning $VVOL_WARNIING
    Write-Progress -Activity "Add datastore" -Status "0% Complete:" -PercentComplete 1

    $FlashArray = Connect-PureCloudBlockStore -PureCloudBlockStoreConnection $PureCloudBlockStoreConnection
    $WorkflowID = New-WorkflowID
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:BeginWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    try {
        $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName
        $Cluster = Get-Cluster -Server $vCenterServer -Name $ClusterName -ErrorAction Ignore
        if (-not $Cluster) {
            throw "Cluster $ClusterName does not exist."
        }
        $ClusterStatus = Get-AVSClusterProvisionStatus -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName -AvsClusterName $ClusterName
        if ($ClusterStatus -ne "Succeeded") {
            throw "The current provisioning status of cluster $ClusterName is $ClusterStatus. The operation can only proceed when provisioning status is 'Succeeded'"
        }
        $TimeoutInMinutes = Get-Timeout -Cluster $cluster -InputParams $PSBoundParameters
        $datastore = Mount-VvolDatastore -vCenterServer $vCenterServer -DatastoreName $DatastoreName -Cluster $Cluster -FlashArray $FlashArray -UseDefaultStore $UseDefaultStore `
                                        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes
        Wait-VvolDatastoreCreation -DataStoreName $datastore.Name
    } catch {
        New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:ErrorWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand -ErrorMessage $_
        throw
    }
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:CompleteWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    Write-Host "Datastore '$($datastore.Name)' is successfully created"
    Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}

function Remove-PCBSVVolDataStore {
    <#
    .SYNOPSIS
    Remove a vVol datastore from all of the hosts in the cluster.

    .DESCRIPTION
    Remove a vVol datastore from all of the hosts in the cluster.

    .PARAMETER ClusterName
    Cluster name

    .PARAMETER DatastoreName
    Datastore name

    .PARAMETER PureCloudBlockStoreConnection
    Optional. Pure Cloud Block Store Connection. The connection can be created using Connect-Pf2Array cmdlet

    .PARAMETER AVSCloudName
    AVS Cloud Name

    .PARAMETER AVSResourceGroup
    AVS Resource Group

    .PARAMETER TimeoutInMinutes
    Optional. Timeout in minutes for RunCommand operations.

    .EXAMPLE
    Remove-PCBSVVolDataStore -ClusterName "mycluster" -DatastoreName "myDatastore" -PureCloudBlockStoreConnection $CBSConnection `
        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
    #>

    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true)]
        [String]$ClusterName,

        [Parameter(Mandatory=$true)]
        [String]$DatastoreName,

        [Parameter(Mandatory=$false)]
        $PureCloudBlockStoreConnection,

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


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

        [Parameter(Mandatory=$false)]
        [ValidateRange(5, 60)]
        [int]$TimeoutInMinutes
    )

    Write-Warning $VVOL_WARNIING
    Write-Progress -Activity "Remove datastore" -Status "0% Complete:" -PercentComplete 1

    $FlashArray = Connect-PureCloudBlockStore -PureCloudBlockStoreConnection $PureCloudBlockStoreConnection
    $WorkflowID = New-WorkflowID
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:BeginWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand

    try {
        $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName
        $Cluster = Get-Cluster -Server $vCenterServer -Name $ClusterName -ErrorAction Ignore
        if (-not $Cluster) {
            throw "Cluster $ClusterName does not exist."
        }
        $ClusterStatus = Get-AVSClusterProvisionStatus -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName -AvsClusterName $ClusterName
        if ($ClusterStatus -ne "Succeeded") {
            throw "The current provisioning status of cluster $ClusterName is $ClusterStatus. The operation can only proceed when provisioning status is 'Succeeded'"
        }
        $TimeoutInMinutes = Get-Timeout -Cluster $cluster -InputParams $PSBoundParameters
        $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName
        Dismount-VvolDatastore -vCenterServer $vCenterServer -DatastoreName $DatastoreName -Cluster $Cluster -FlashArray $FlashArray `
                                -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes

        Write-Host "Datastore '$DatastoreName' is successfully removed"

    }
    catch {
        New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:ErrorWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand -ErrorMessage $_
        throw
    }
    Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
    New-PhoneHomeWorkflowLogEntry -RestClient $FlashArray -Event $global:CompleteWorkflow -ID $WorkflowID -Name $MyInvocation.MyCommand
}

function New-PCBSStoragePolicy {
    <#
    .SYNOPSIS
      Creates a new Pure Cloud Block Store vVol Storage Policy
    .DESCRIPTION
      Creates a new Pure Cloud Block Store vVol Storage Policy with specified capabilities
    .INPUTS
      Capabilities
    .OUTPUTS
      New storage policy
    .PARAMETER PolicyName
      Pure Cloud Block Store vVol Storage Policy name.
    .PARAMETER PolicyDescription
      Optional. Pure Cloud Block Store vVol Storage Policy description.
    .PARAMETER SourcePureCloudBlockStores
      Optional. Name of one or more Pure Cloud Block Store to use. Use comma as seperater if there are multiple names
    .PARAMETER ReplicationEnabled
      Optional. Replication capability rule. The input value could be yes, no or empty, If not provided replication will not be enabled.
    .PARAMETER ReplicationInterval
      Optional. Replication capability rule. Protection group remote snapshot creation interval in seconds.
    .PARAMETER ReplicationRetentionInterval
      Optional. Replication capability rule. Protection group remote snapshot retention interval in seconds.
    .PARAMETER ReplicationRuleLocalSnapshotEnabled
      Optional. Replication capability rule. The input value could be yes, no or empty.
    .PARAMETER ReplicationRuleLocalSnapshotInterval
      Optional. Replication capability rule. Protection group local snapshot creation interval in seconds.
    .PARAMETER ReplicationRuleLocalSnapshotRetentionInterval
      Optional. Replication capability rule. Protection group local snapshot retention interval in seconds.
    .PARAMETER ReplicationConcurrency
      Optional. Replication capability rule. The number of target Pure Cloud Block Store to replicate to at once.
    .PARAMETER ReplicationRansomwareProtection
      Optional. Replication capability rule. Protection group ransomware protection
    .PARAMETER TargetPureCloudBlockStores
      Optional. Replication capability rule. Names of specific Pure Cloud Block Store desired as replication targets. Use comma as seperater if there are multiple names
    .PARAMETER ConsistencyGroupName
      Optional. Replication capability rule. A Pure Cloud Block Store protection group name
    .PARAMETER PerVirtualDiskIOPSLimit
      Optional. QoS placement capability rule. IOPS limit get applied to per virtual disk
    .PARAMETER PerVirtualDiskIOPSLimitUnit
      Optional. QoS placement capability rule. IOPS limit unit (K, M, or -)
    .PARAMETER PerVirtualDiskBandwidthLimit
      Optional. QoS placement capability rule. Bandwidth limit get applied to per virtual disk
    .PARAMETER PerVirtualDiskBandwidthLimitUnit
      Optional. QoS placement capability rule. Bandwidth limit unit (KB/s, MB/s or GB/s)
    .PARAMETER VolumeTaggingKey
      Optional. Volume tagging placement capability. Volumes with this policy will be tagged with the key
    .PARAMETER VolumeTaggingValue
      Optional. Volume tagging placement capability. Volumes with this policy will be tagged with the value
    .PARAMETER VolumeTaggingCopyable
      Optional. Volume tagging placement capability. When set to yes, any volume copies of this volume will receive the tag
    .PARAMETER PlacementRuleLocalSnapshotInterval
      Optional. Local snapshot protection placement capability. Snapshots will be taken in the specified interval in seconds.
    .PARAMETER PlacementRuleLocalSnapshotRetentionInterval
      Optional. Local snapshot protection placement capability. Snapshots will be retained for the timespan in seconds.
    .PARAMETER PlacementRuleLocalSnapshotRetainAdditionalSnapshots
      Optional. Local snapshot protection placement capability. Optional additional retention: After the retention timespan specified above is up, a number of snapshots will be selected, evenly spaced out, from the last retention timespan. This parameter specifies the number of snapshots to select from the last retention timespan. These snapshots will be retained for a number of additional days (see parameter below). Leave this parameter as "0" if additional retention is not required.
    .PARAMETER PlacementRuleLocalSnapshotRetainAdditionalDays
      Optional. Local snapshot protection placement capability. Optional additional retention: This parameter specifies the number of days that additional snapshots should be retained. If a selection for "Retain additional snapshots" (see above) was made, this parameter must also be specified. Leave this parameter as "0" if additional retention is not required.
    .PARAMETER OffloadType
      Optional. Snapshot offload protection placement capability. Purity//FA Snap to Cloud is a policy-based solution to manage portable snapshots through the offload of volume snapshots to a target, such as an Azure Blob container, or an S3 bucket, for long-term retention. With different types of offload targets this rule allows policies to specify a specific offload target type or to have no requirement for a specific type of target.
    .PARAMETER OffloadTargetNames
      Optional. Snapshot offload protection placement capability. Upon the first assignment of this policy to a VM on a given datastore a consistency group will be created with the settings supplied. This rule specifies which targets are added to the consistency groups target list. If no requirement is selected then the storage provider will selected one of the available offload targets on the compatible datastore's array.
    .PARAMETER OffloadReplicationInterval
      Optional. Snapshot offload protection placement capability. Snapshots will be taken and replicated to the offload target in the specified interval.
    .PARAMETER OffloadOffloadReplicationTime
      Optional. Snapshot offload protection placement capability. If the replication interval is set to one or more days, optionally set the 'Daily/weekly replication time' to specify the preferred hour of each day when Purity//FA replicates the snapshot. For example, if the replication schedule is set to "Replicate every 4 days at 6pm," Purity//FA replicates the snapshots every four days at or around 6:00 p.m.
    .PARAMETER OffloadRetentionInterval
      Optional. Snapshot offload protection placement capability. Replicated snapshots will be retained for the specified timespan on the offload target.
    .PARAMETER OffloadRetainAdditionalSnapshots
      Optional. Snapshot offload protection placement capability. After the retention timespan specified is up, a number of snapshots will be selected, evenly spaced out, from the last retention timespan. This parameter specifies the number of snapshots to select from the last retention timespan. These snapshots will be retained for a number of additional days (see parameter below). Leave this parameter as "0" if additional retention is not required.
    .PARAMETER OffloadRetainAdditionalDays
      Optional. Snapshot offload protection placement capability. This parameter specifies the number of days that additional snapshots should be retained. If a selection for "Retain additional snapshots" (see above) was made, this parameter must also be specified. Leave this parameter as "0" if additional retention is not required.
    .PARAMETER OffloadReplicationBlackoutFrom
      Optional. Snapshot offload protection placement capability. Define a timespan for which replication is suspended or "blacked out". The asynchronous replication process stops during the blackout period. When the blackout period starts, replication processes that are still in progress will not be interrupted. Instead, Purity//FA will wait until the in-progress snapshot replication is complete before it observes the blackout period. This value dictates when the blackout period begins.
    .PARAMETER OffloadReplicationBlackoutTo
      Optional. Snapshot offload protection placement capability. Define a timespan for which replication is suspended or "blacked out". The asynchronous replication process stops during the blackout period. When the blackout period starts, replication processes that are still in progress will not be interrupted. Instead, Purity//FA will wait until the in-progress snapshot replication is complete before it observes the blackout period. This value dictates when the blackout period ends and replication jobs can be initiated again.
    .PARAMETER DefaultProtectionOptout
      Optional. Default protection opt-out placement capability. Whether should new volumes be placed in default protection groups. If not provided, new volumes will be placed in default protection groups.
    .PARAMETER AVSCloudName
      AVS Cloud Name
    .PARAMETER AVSResourceGroup
      AVS Resource Group
    .PARAMETER TimeoutInMinutes
      Optional. Timeout in minutes for RunCommand operations.
    .EXAMPLE
      New-PCBSStoragePolicy

      Creates the default SPBM policy that indicates a VM should be on a Pure Cloud Block Store using vVols. Default generated name and description.
    .EXAMPLE
      New-PCBSStoragePolicy -PolicyName myGreatPolicy `
      -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

      Creates a SPBM policy with the specified name that indicates a VM should be on a Pure Cloud Block Store using vVols. Default generated description.
    .EXAMPLE
      New-PCBSStoragePolicy -PolicyName myGreatReplicationPolicy -ReplicationInterval 7200 -ReplicationEnabled "yes" -ReplicationConcurrency 2 `
      -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

      Creates a replication-type SPBM policy with the specified name that indicates a VM should be on a Pure Cloud Block Store using vVols, replicated every 2 hours to at least two other Pure Cloud Block Stores. Default generated description.

    .EXAMPLE
      New-PCBSStoragePolicy -PolicyName myGreatReplicationPolicy -SourcePureCloudBlockStores "MyArrayOne,MyArrayTwo" `
      -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

      Creates a SPBM policy with the specified name that indicates a VM should be on the specific Pure Cloud Block Store using vVols.
      #>


    [CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true)]
        [String]$PolicyName,

        [Parameter(Mandatory=$false)]
        [String]$PolicyDescription = "Pure Storage Cloud Block Store vVol storage policy default description",

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

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

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

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

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

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

        [Parameter(Mandatory=$false)]
        [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)]
        [Timespan]$PlacementRuleLocalSnapshotInterval,

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

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

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

        [Parameter(Mandatory=$false)]
        [ValidateSet("s3", "nfs", "azure")]
        [string]$OffloadType,

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

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

        [Parameter(Mandatory=$false)]
        [ValidateSet("-", "12am", "1am", "2am", "3am", "4am", "5am", "6am", "7am", "8am", "9am", "10am", "11am", "12pm", "1pm", "2pm", "3pm", "4pm", "5pm", "6pm", "7pm", "8pm", "9pm", "10pm", "11pm")]
        [string]$OffloadOffloadReplicationTime,

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

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

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

        [Parameter(Mandatory=$false)]
        [ValidateSet("-", "12am", "1am", "2am", "3am", "4am", "5am", "6am", "7am", "8am", "9am", "10am", "11am", "12pm", "1pm", "2pm", "3pm", "4pm", "5pm", "6pm", "7pm", "8pm", "9pm", "10pm", "11pm")]
        [string]$OffloadReplicationBlackoutFrom,

        [Parameter(Mandatory=$false)]
        [ValidateSet("-", "12am", "1am", "2am", "3am", "4am", "5am", "6am", "7am", "8am", "9am", "10am", "11am", "12pm", "1pm", "2pm", "3pm", "4pm", "5pm", "6pm", "7pm", "8pm", "9pm", "10pm", "11pm")]
        [string]$OffloadReplicationBlackoutTo,

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

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


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

        [Parameter(Mandatory=$false)]
        [ValidateRange(5, 60)]
        [int]$TimeoutInMinutes = 10
    )
    Write-Warning $VVOL_WARNIING
    Write-Progress -Activity "Create storage policy" -Status "0% Complete:" -PercentComplete 1

    $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName

    New-VvolStoragePolicy -PolicyName $PolicyName -PolicyDescription $PolicyDescription -SourcePureCloudBlockStores $SourcePureCloudBlockStores -ReplicationEnabled $ReplicationEnabled -ReplicationInterval $ReplicationInterval -ReplicationRetentionInterval $ReplicationRetentionInterval `
    -ReplicationRuleLocalSnapshotEnabled $ReplicationRuleLocalSnapshotEnabled -ReplicationRuleLocalSnapshotInterval $ReplicationRuleLocalSnapshotInterval -ReplicationRuleLocalSnapshotRetentionInterval $ReplicationRuleLocalSnapshotRetentionInterval -ReplicationConcurrency $ReplicationConcurrency -ReplicationRansomwareProtection $ReplicationRansomwareProtection `
    -TargetPureCloudBlockStores $TargetPureCloudBlockStores -ConsistencyGroupName $ConsistencyGroupName -PerVirtualDiskIOPSLimit $PerVirtualDiskIOPSLimit -PerVirtualDiskIOPSLimitUnit $PerVirtualDiskIOPSLimitUnit `
    -PerVirtualDiskBandwidthLimit $PerVirtualDiskBandwidthLimit -PerVirtualDiskBandwidthLimitUnit $PerVirtualDiskBandwidthLimitUnit -VolumeTaggingKey $VolumeTaggingKey -VolumeTaggingValue $VolumeTaggingValue -VolumeTaggingCopyable $VolumeTaggingCopyable `
    -PlacementRuleLocalSnapshotInterval $PlacementRuleLocalSnapshotInterval -PlacementRuleLocalSnapshotRetentionInterval $PlacementRuleLocalSnapshotRetentionInterval -PlacementRuleLocalSnapshotRetainAdditionalSnapshots $PlacementRuleLocalSnapshotRetainAdditionalSnapshots -PlacementRuleLocalSnapshotRetainAdditionalDays $PlacementRuleLocalSnapshotRetainAdditionalDays `
    -OffloadType $OffloadType -OffloadTargetNames $OffloadTargetNames -OffloadReplicationInterval $OffloadReplicationInterval -OffloadOffloadReplicationTime $OffloadOffloadReplicationTime -OffloadRetentionInterval $OffloadRetentionInterval -OffloadRetainAdditionalSnapshots $OffloadRetainAdditionalSnapshots -OffloadRetainAdditionalDays $OffloadRetainAdditionalDays -OffloadReplicationBlackoutFrom $OffloadReplicationBlackoutFrom -OffloadReplicationBlackoutTo $OffloadReplicationBlackoutTo -DefaultProtectionOptout $DefaultProtectionOptout `
    -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -vCenterServer $vCenterServer -TimeoutInMinutes $TimeoutInMinutes

    Write-Host "Storage policy '$PolicyName' is successfully created"
    Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}

function Remove-PCBSStoragePolicy {
<#
    .SYNOPSIS
     Remove a Pure Cloud Block Store vVol Storage Policy
    .DESCRIPTION
     Remove a Pure Cloud Block Store vVol Storage Policy using policy name. The policy must be unused and belong to Pure
    .INPUTS
     SPBM policy name
    .PARAMETER PolicyName
     Pure Cloud Block Store vVol Storage Policy name
    .PARAMETER AVSCloudName
     AVS cloud name
    .PARAMETER AVSResourceGroup
     AVS Resource group name
    .PARAMETER TimeoutInMinutes
      Optional. Timeout in minutes for RunCommand operations.
    .EXAMPLE
     Remove-PCBSStoragePolicy -PolicyName myPolicyName -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
 #>


    [CmdletBinding()]
    Param(
        [Parameter(mandatory = $true)]
        [string]$PolicyName,

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

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

        [Parameter(Mandatory=$false)]
        [ValidateRange(5, 60)]
        [int]$TimeoutInMinutes = 10
    )

    Write-Warning $VVOL_WARNIING
    Write-Progress -Activity "Remove storage policy" -Status "0% Complete:" -PercentComplete 1

    $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName

    Remove-VvolStoragePolicy -PolicyName $PolicyName -vCenterServer $vCenterServer `
                            -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes

    Write-Host "Storage policy '$PolicyName' is successfully removed"
    Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}


function Start-PCBSFailover {
  <#
  .SYNOPSIS
    Issue test failover or failover operation against "Target" replication group.
  .DESCRIPTION
    Issue test failover or failover operation against replication group. Must be run on a "Target" Replication Group.
  .PARAMETER TargetReplicationGroupID
    Target VMWare Replication Group Id to be used on failover. Must be a "Target" Replication Group.
  .PARAMETER PointInTimeReplicaName
    Optional. Point in time replica name to failover to. If not provided, the latest replica will be used.
  .PARAMETER ClusterName
    Cluster name where failover VMs will be created.
  .PARAMETER PowerOn
    Optional. Indicates whether to or not to power on created VMs. If not provided the VM(s) will be powered on.
  .PARAMETER TestFailover
    Optional. Indicates whether to actually perform a failover(false) or to only perform a test failover(true). If not provided will only perform failover test.
  .PARAMETER AVSCloudName
    AVS cloud name. The target AVS instance where the failover will be performed.
  .PARAMETER AVSResourceGroup
    AVS resource group name.
  .PARAMETER TimeoutInMinutes
    Optional. Timeout in minutes for RunCommand operations.
  .EXAMPLE
    Start-PCBSFailover -TargetReplicationGroupID myGroupId -ClusterName myclustername -TestFailover $true -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
    Issues test failover on replication group specified by id "myGroupId", test VMs will be created under cluster "myclustername", and group replication state will be set to "InTest"
  .EXAMPLE
    Start-PCBSFailover -TargetReplicationGroupID myGroupId -ClusterName myclustername -PowerOn $true -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
    Issues failover on replication group specified by id "myGroupId", test VMs will be created under cluster "myclustername", VMs created will be powered on, and group replication state will be set to "FailedOver"
  .EXAMPLE
    Start-PCBSFailover -TargetReplicationGroupID myGroupId -ClusterName myclustername -PowerOn $true -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
    Issues Failover on replication group specified by id "myGroupId", new VMs will be created under cluster "myclustername", VMs created will be powered on, and group replication state will be set to "FailedOver"
    #>


    [CmdletBinding()]
    Param(
        [Parameter(mandatory = $true)]
        [String]$ClusterName,

        [Parameter(mandatory = $true)]
        [String]$TargetReplicationGroupID,

        [Parameter(mandatory = $false)]
        [String]$PointInTimeReplicaName,

        [Parameter(mandatory = $false)]
        [switch]$PowerOn,

        [Parameter(mandatory = $false)]
        [switch]$TestFailover,

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

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

        [Parameter(Mandatory=$false)]
        [ValidateRange(5, 60)]
        [int]$TimeoutInMinutes = 10
    )
    Write-Warning $VVOL_WARNIING
    Write-Progress -Activity "Start failover" -Status "0% Complete:" -PercentComplete 1
    $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName

    Start-VvolReplicationGroupFailover -ReplicationGroupID $TargetReplicationGroupID -PointInTimeReplicaName $PointInTimeReplicaName -ClusterName $ClusterName -PowerOn $PowerOn -TestFailover $TestFailover -vCenterServer $vCenterServer `
                                        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes

    Write-Host "Replication group '$TargetReplicationGroupID' successfully failovered to cluster '$ClusterName'"
    Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}

function Sync-PCBSReplicationGroup {
  <#
  .SYNOPSIS
    Synchronize a replication group. Must be run on a "Target" Replication Group.
  .DESCRIPTION
    Synchronize a replication group. Triggers an on demand snapshot replication job. Must be run on a "Target" Replication Group.
  .PARAMETER TargetReplicationGroupID
    Replication Group Id that was used on the test failover
  .PARAMETER PointInTimeReplicaName
    Optional. Point in time replica name to sync to. If not provided, a generated name "Sync-*" will be used.
  .PARAMETER AVSCloudName
    AVS cloud name
  .PARAMETER AVSResourceGroup
    AVS resource group name
  .PARAMETER TimeoutInMinutes
    Optional. Timeout in minutes for RunCommand operations.
  .EXAMPLE
    Sync-PCBSReplicationGroup -TargetReplicationGroupID myGroupId -PointInTimeReplicaName myReplicaName -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
    Synchronizes a replication group specified by id "myGroupId". An on demand snapshot replication job will be triggered on array
    #>


    [CmdletBinding()]
    Param(
      [Parameter(mandatory=$true)]
      [String]$TargetReplicationGroupID,

      [Parameter(mandatory = $false)]
      [String]$PointInTimeReplicaName,

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

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

      [Parameter(Mandatory=$false)]
      [ValidateRange(5, 60) ]
      [int]$TimeoutInMinutes = 10
    )
    Write-Warning $VVOL_WARNIING
    Write-Progress -Activity "Start Replication Group sync" -Status "0% Complete:" -PercentComplete 1
    $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName

    if (-not $PointInTimeReplicaName) {
      $PointInTimeReplicaName = "Sync-$([guid]::newguid())"
    }
    Sync-VvolReplicationGroup -ReplicationGroupID $TargetReplicationGroupID -PointInTimeReplicaName $PointInTimeReplicaName -vCenterServer $vCenterServer `
                      -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes

    Write-Host "Replication group '$TargetReplicationGroupID' is successfully synced to point in time replica '$PointInTimeReplicaName'"
    Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}

function Stop-PCBSFailoverTest {
  <#
  .SYNOPSIS
    Stops a test failover that was started on replication group
  .DESCRIPTION
    Stops a test failover that was started on replication group. Must be used on a "InTest" Replication Group
  .PARAMETER InTestTargetReplicationGroupID
    Replication Group Id that was used on the test failover
  .PARAMETER AVSCloudName
    AVS cloud name
  .PARAMETER AVSResourceGroup
    AVS resource group name
  .PARAMETER TimeoutInMinutes

  .EXAMPLE
    Stop-PCBSFailoverTest -InTestReplicationGroupID myGroupId -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
    Stops a test failover that was started on replication group specified by id "myGroupId", test VMs will be stopped and deleted and group replication state will be set to "Target"
    #>


    [CmdletBinding()]
    Param(
      [Parameter(mandatory=$true)]
      [String]$InTestTargetReplicationGroupID,

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

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

      [Parameter(Mandatory=$false)]
      [ValidateRange(5, 60) ]
      [int]$TimeoutInMinutes = 10
    )
    Write-Warning $VVOL_WARNIING
    Write-Progress -Activity "Stop failover test" -Status "0% Complete:" -PercentComplete 1
    $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName

    Stop-VvolReplicationGroupFailoverTest -ReplicationGroupID $InTestTargetReplicationGroupID -vCenterServer $vCenterServer `
                                              -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes

    Write-Host "Failover test associated with Replication group '$InTestTargetReplicationGroupID' is successfully stopped"
    Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}

function Start-PCBSFailoverCleanup {
  <#
  .SYNOPSIS
    Cleans up the original source site after failing over to a new site.
  .DESCRIPTION
    Cleans up the original source site after failing over to a new site. Must be run on source site. Will stop and unregister VMs protected by replication group.
  .PARAMETER SourceReplicationGroupID
    Replication Group Id for source group used on the failover
  .PARAMETER RemoveFromDisk
    Optional. Indicates whether to remove VMs from disk.
  .PARAMETER AVSCloudName
    AVS cloud name
  .PARAMETER AVSResourceGroup
    AVS resource group name
  .EXAMPLE
    Start-PCBSFailoverCleanup -SourceReplicationGroupID myGroupId -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
    Will stop and unregister VMs protected by replication group identified by "myGroupId".
    #>


    [CmdletBinding()]
    Param(
      [Parameter(Mandatory=$true)]
      [String]$SourceReplicationGroupID,

      [Parameter(Mandatory=$false)]
      [switch]$RemoveFromDisk,

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

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

    )
    Write-Warning $VVOL_WARNIING
    Write-Progress -Activity "Clean up original source site after failover" -Status "0% Complete:" -PercentComplete 1
    $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName

    Start-VvolCleanupSourceReplicationGroupForFailover -ReplicationGroupID $SourceReplicationGroupID -RemoveFromDisk $RemoveFromDisk -vCenterServer $vCenterServer `
                                                       -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup

    Write-Host "The original source site '$SourceReplicationGroupID' is successfully cleaned up"
    Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}

function Start-PCBSFailoverReverse {
  <#
  .SYNOPSIS
    Reverse replication on a FailedOver replication group and reprotect by assigning a storage policy to affected objects
  .DESCRIPTION
    Reverse replication on a FailedOver replication group and reprotect by assigning a storage policy to affected objects. Must be used on a FailedOver Replication Group. The Failedover Replication Group will become "Source"
  .PARAMETER FailedoverTargetReplicationGroupID
    Replication Group Id that was used on failover
  .PARAMETER PolicyName
    Optional. Policy Name to be used to reprotect objects.
  .PARAMETER AVSCloudName
    AVS cloud name
  .PARAMETER AVSResourceGroup
    AVS resource group name
  .PARAMETER TimeoutInMinutes
    Optional. Timeout in minutes for RunCommand operations.
  .EXAMPLE
    Start-PCBSFailoverReverse -FailedoverTargetReplicationGroupID myGroupId -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
    Reprotect replication group specified by id "myGroupId", and sets objects storage policy to the default "VVol No Requirements Policy"
  .EXAMPLE
    Start-PCBSFailoverReverse -FailedoverTargetReplicationGroupID myGroupId -PolicyName PolicyName -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup
    Reprotect replication group specified by id "myGroupId", and sets objects storage policy to "PolicyName"
    #>


    [CmdletBinding()]
    Param(
      [Parameter(mandatory=$true)]
      [String]$FailedoverTargetReplicationGroupID,

      [Parameter(mandatory=$false)]
      [String]$PolicyName,

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

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

      [Parameter(Mandatory=$false)]
      [ValidateRange(5, 60) ]
      [int]$TimeoutInMinutes = 10
    )
    Write-Warning $VVOL_WARNIING
    Write-Progress -Activity "Reprotect replication group" -Status "0% Complete:" -PercentComplete 1
    $vCenterServer = Connect-AVSvCenter -AVSResourceGroupName $AVSResourceGroup -AVSPrivateCloudName $AVSCloudName

    Start-VvolReprotectReplicationGroup -ReplicationGroupID $FailedoverTargetReplicationGroupID -PolicyName $PolicyName -vCenterServer $vCenterServer `
                                        -AVSCloudName $AVSCloudName -AVSResourceGroup $AVSResourceGroup -TimeoutInMinutes $TimeoutInMinutes

    Write-Host "The FailedOver replication group '$FailedoverTargetReplicationGroupID' is successfully reprotected"
    Write-Progress -Activity "Operation is done" -Status "100% Complete:" -Completed
    Disconnect-VIServer -Server $vCenterServer -Confirm:$false -ErrorAction SilentlyContinue
}

<#
.SYNOPSIS
Fully remove a Pure Storage CBS AVS monitor deployment from Azure infrastructure

.DESCRIPTION
Fully remove a Pure Storage CBS AVS monitor deployment from Azure infrastructure. The resource group and its resources will be destroyed. The vNet subnet used by the monitor will also be remove from the vNet.

.PARAMETER MonitorResourceGroup
ResourceGroup to host monitor infrastructure components

 .PARAMETER RemoveSubnet
Optional. Indicates whether to remove the subnet used by the monitor from the vNet. If not provided, the subnet will not be removed.

.EXAMPLE
Remove-PCBSAVSMonitor -MonitorResourceGroup "myAVSMonitorResourceGroup"

.NOTES
Must be logged in to Azure (using Connect-AzAccount) before running this cmdlet
#>

function Remove-PCBSAVSMonitor {
  [CmdletBinding()]
    Param (
      [Parameter(Mandatory=$true)]
      [String]$MonitorResourceGroup,

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

    $params = @{
      MonitorResourceGroup = $MonitorResourceGroup
      MonitorType = "host"
      RemoveSubnet = $RemoveSubnet
    }

    Remove-Monitor @params
}

<#
.SYNOPSIS
Deploy or update a Pure Storage CBS AVS monitor to Azure infrastructure

.DESCRIPTION
Deploy or update a Pure Storage CBS AVS monitor to Azure infrastructure. The monitor will scan periodically for AVS Cluster/Host changes and will make sure to change iSCSI configuration accordingly.

.PARAMETER MonitorResourceGroup
Resource group to host monitor infrastructure components. The resource group will be created if not exists

.PARAMETER MonitorResourceGroupRegion
Resource group region to host monitor infrastructure components.

.PARAMETER AVSCloudName
AVS cloud name

.PARAMETER AVSResourceGroup
AVS Resource group name

.PARAMETER PureCloudBlockStoreEndpoint
Pure Cloud Block Store endpoint address

.PARAMETER PureCloudBlockStoreCredential
Pure Cloud Block Store credentials

.PARAMETER VNetName
An existing VNet name. The VNey specified should have access to AVS as well as Pure Storage Cloud Block Store (CBS) array.

.PARAMETER VNetResourceGroup
VNet REsourceGroup

.PARAMETER VNetSubnetAddress
The VNet subnet address range in CIDR notation (e.g. 192.168.1.0/24). It must be contained by the address space of the virtual network.

.PARAMETER VNetSubnetName
If VNetSubnetAddress is specified, then VnetSubnetName can be optionaly used to specify a new subnet name otherwise it is existing VNet subnet name.

.PARAMETER MonitorIntervalInMinute
Optional. The default monitor interval is 10 minutes.

.EXAMPLE
Deploy-PCBSAVSMonitor -PureCloudBlockStoreEndpoint "192.168.2.100" -PureCloudBlockStoreCredential (Get-Credential) -AVSCloudName "my-avs" -AVSResourceGroup "avs-resourcegroup" `
              -MonitorResourceGroup "NewResourceGroup" -MonitorResourceGroupRegion "westus2" -VNetName "my-vnet" -VNetResourceGroup "vnet-resourcegroup" -VNetSubnetAddress "192.168.3.0/24"

.NOTES
Must be logged in to Azure (using Connect-AzAccount) before running this cmdlet
#>

function Deploy-PCBSAVSMonitor {
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$true)]
        [String]$MonitorResourceGroup,

        [Parameter(Mandatory=$true)]
        [String]$MonitorResourceGroupRegion,

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

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

        [Parameter(Mandatory=$true)]
        [String]$PureCloudBlockStoreEndpoint,

        [Parameter(Mandatory=$true)]
        [pscredential]$PureCloudBlockStoreCredential,

        [Parameter(Mandatory=$true)]
        [String]$VNetName,

        [Parameter(Mandatory=$true)]
        [String]$VNetResourceGroup,

        [Parameter(ParameterSetName='NewSubnet', Mandatory=$true)]
        [String]$VNetSubnetAddress,

        [Parameter(ParameterSetName='ExistingSubnet', Mandatory=$true)]
        [Parameter(ParameterSetName='NewSubnet', Mandatory=$false)]
        [String]$VNetSubnetName,

        [Parameter(Mandatory=$false)]
        [ValidateScript({ $_ -ge 10 }, ErrorMessage = "The minimum interval for the monitor is 10 minutes.")]
        [ValidateScript({ $_ -le 60 }, ErrorMessage = "The maximum interval for the monitor is 60 minutes.")]
        [int]$MonitorIntervalInMinute = 10
    )

    $params = @{
      MonitorResourceGroup = $MonitorResourceGroup
      MonitorResourceGroupRegion = $MonitorResourceGroupRegion
      AVSCloudName = $AVSCloudName
      AVSResourceGroup = $AVSResourceGroup
      VNetName = $VNetName
      VNetResourceGroup = $VNetResourceGroup
      MonitorIntervalInMinute = $MonitorIntervalInMinute
      MonitorType = "host"
  }
  $paramSetName = $PSCmdlet.ParameterSetName
  if ($paramSetName -eq "NewSubnet") {
      $params.Add("VNetSubnetAddress", $VNetSubnetAddress)
      if ($VNetSubnetName) {
          $params.Add("VNetSubnetName", $VNetSubnetName)
      }
  } else {
      $params.Add("VNetSubnetName", $VNetSubnetName)
  }
  Deploy-MonitoringResource @params
  Write-Host "Adding CBS AVS monitor array to the monitor ..."
  Add-PCBSAVSMonitorArray -MonitorResourceGroup $MonitorResourceGroup `
    -PureCloudBlockStoreEndpoint $PureCloudBlockStoreEndpoint -PureCloudBlockStoreCredential $PureCloudBlockStoreCredential -Force
}

<#
.SYNOPSIS
Deploy or update a Pure Storage CBS Capacity monitor

.DESCRIPTION
Deploy or update a Pure Storage CBS Capacity monitor to Azure infrastructure.
The monitor will scan periodically for CBS space utilization and will automatically request expanding the storage if the utilization reaches pre-defined threshold

.PARAMETER MonitorResourceGroup
Resource group to host monitor infrastructure components. The resource group will be created if not exists

.PARAMETER MonitorResourceGroupRegion
Resource group region to host monitor infrastructure components.

.PARAMETER AVSCloudName
AVS cloud name

.PARAMETER AVSResourceGroup
AVS Resource group name

.PARAMETER VNetName
An existing VNet name. The VNey specified should have access to AVS as well as Pure Storage Cloud Block Store (CBS) array.

.PARAMETER VNetResourceGroup
VNet REsourceGroup

.PARAMETER VNetSubnetAddress
The VNet subnet address range in CIDR notation (e.g. 192.168.1.0/24). It must be contained by the address space of the virtual network.

.PARAMETER VNetSubnetName
If VNetSubnetAddress is specified, then VnetSubnetName can be optionaly used to specify a new subnet name otherwise it is existing VNet subnet name.

.PARAMETER DefaultUtilizationThreshold
Optional. The default utilization threshold is 80%.

.PARAMETER MonitorIntervalInMinute
Optional. The default monitor interval is 10 minutes.

.EXAMPLE
Deploy-PCBSCapacityMonitor -AVSCloudName "my-avs" -AVSResourceGroup "avs-resourcegroup" `
              -MonitorResourceGroup "NewResourceGroup" -MonitorResourceGroupRegion "westus2" `
              -VNetName "my-vnet" -VNetResourceGroup "vnet-resourcegroup" -VNetSubnetAddress "192.168.3.0/24"

.NOTES
Must be logged in to Azure (using Connect-AzAccount) before running this cmdlet
#>

function Deploy-PCBSCapacityMonitor {
  [CmdletBinding()]
  Param(
      [Parameter(Mandatory=$true)]
      [String]$MonitorResourceGroup,

      [Parameter(Mandatory=$true)]
      [String]$MonitorResourceGroupRegion,

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

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

      [Parameter(Mandatory=$true)]
      [String]$VNetName,

      [Parameter(Mandatory=$true)]
      [String]$VNetResourceGroup,

      [Parameter(ParameterSetName='NewSubnet', Mandatory=$true)]
      [String]$VNetSubnetAddress,

      [Parameter(ParameterSetName='ExistingSubnet', Mandatory=$true)]
      [Parameter(ParameterSetName='NewSubnet', Mandatory=$false)]
      [String]$VNetSubnetName,

      [Parameter(Mandatory=$false)]
      [ValidateRange(1, 100)]
      [int] $DefaultUtilizationThreshold = $DEFAULT_UTILIZATIOn_THRESHOLD,

      [Parameter(Mandatory=$false)]
      [ValidateScript({ $_ -ge 10 }, ErrorMessage = "The minimum interval for the monitor is 10 minutes.")]
      [ValidateScript({ $_ -le 60 }, ErrorMessage = "The maximum interval for the monitor is 60 minutes.")]
      [int]$MonitorIntervalInMinute = 30
  )

  $params = @{
      MonitorResourceGroup = $MonitorResourceGroup
      MonitorResourceGroupRegion = $MonitorResourceGroupRegion
      AVSCloudName = $AVSCloudName
      AVSResourceGroup = $AVSResourceGroup
      VNetName = $VNetName
      VNetResourceGroup = $VNetResourceGroup
      MonitorIntervalInMinute = $MonitorIntervalInMinute
      DefaultUtilizationThreshold = $DefaultUtilizationThreshold
      MonitorType = "capacity"
  }
  $paramSetName = $PSCmdlet.ParameterSetName
  if ($paramSetName -eq "NewSubnet") {
      $params.Add("VNetSubnetAddress", $VNetSubnetAddress)
      if ($VNetSubnetName) {
          $params.Add("VNetSubnetName", $VNetSubnetName)
      }
  } else {
      $params.Add("VNetSubnetName", $VNetSubnetName)
  }
  Deploy-MonitoringResource @params
}

<#
.SYNOPSIS
List the existing Pure Cloud Block Store in the Pure Storage CBS AVS monitor

.DESCRIPTION
List the existing Pure Cloud Block Store in the Pure Storage CBS AVS monitor

.PARAMETER MonitorResourceGroup
ResourceGroup to host monitor infrastructure components

.EXAMPLE
Get-PCBSAVSMonitorArray -MonitorResourceGroup myMonitor

.NOTES
Must be logged in to Azure (using Connect-AzAccount) before running this cmdlet
#>


function Get-PCBSAVSMonitorArray {
    [CmdletBinding()]
    Param (
      [Parameter(Mandatory=$true)]
      [String]$MonitorResourceGroup
    )
    $ResourceGroup = Get-AzResourceGroup -Name $MonitorResourceGroup

    if (-not $ResourceGroup) {
        throw "Resource group $MonitorResourceGroupdoes not exist"
    }

    if (-not $ResourceGroup.Tags["PureStorage.CBS.AVS"]) {
        throw "Resouce group $MonitorResourceGroup specified does not host Pure Storage CBS AVS monitor"
    }

    $UserPrincipalName = (Get-AzContext).Account.Id
    $KeyVault = Get-AzKeyVault -ResourceGroupName $MonitorResourceGroup
    Set-AzKeyVaultAccessPolicy -VaultName $KeyVault.VaultName  -UserPrincipalName $UserPrincipalName -PermissionsToSecrets set,delete,get,purge,list

    $Arrays = @()
    $Secrets = Get-AzKeyVaultSecret -VaultName $KeyVault.VaultName | where-object {$_.Name -like "*-$($KeyVault.VaultName)-username"}
    foreach ($Secret in $Secrets) {
        $ArrayName = ($Secret.name -Split "-$($KeyVault.VaultName)-username")[0]
        # If the string matches the format like "172-168-1-0", the array ip addressed was processed because secret name does not allow "."
        if ($ArrayName -match "^\d+-\d+-\d+-\d+$") {
            $ArrayName = $ArrayName.Replace("-", ".")
        }
        $Arrays += $ArrayName
    }

    return $Arrays
}

<#
.SYNOPSIS
Add a Pure Cloud Block Store to an existing Pure Storage CBS AVS monitor

.DESCRIPTION
Add a Pure Cloud Block Store to an existing Pure Storage CBS AVS monitor. If the Pure Block store already exists, it will be overwritten

.PARAMETER MonitorResourceGroup
ResourceGroup to host monitor infrastructure components

.PARAMETER PureCloudBlockStoreEndpoint
Pure Cloud Block Store endpoint address

.PARAMETER PureCloudBlockStoreCredential
Pure Cloud Block Store credential

.PARAMETER Force
Optional. If specified, the cmdlet will not throw error if the Pure Cloud Block Store cannot be verified

.EXAMPLE
Add-PCBSAVSMonitorArray -MonitorResourceGroup myMonitorGroup -PureCloudBlockStoreEndpoint myArray -PureCloudBlockStoreCredential (Get-Credential)

.NOTES
Must be logged in to Azure (using Connect-AzAccount) before running this cmdlet
#>

function Add-PCBSAVSMonitorArray {
    [CmdletBinding()]
    Param (
      [Parameter(Mandatory=$true)]
      [String]$MonitorResourceGroup,

      [Parameter(Mandatory=$true)]
      [String]$PureCloudBlockStoreEndpoint,

      [Parameter(Mandatory=$true)]
      [pscredential]$PureCloudBlockStoreCredential,

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

    $params = @{
      MonitorResourceGroup = $MonitorResourceGroup
      PureCloudBlockStoreEndpoint = $PureCloudBlockStoreEndpoint
      PureCloudBlockStoreCredential = $PureCloudBlockStoreCredential
      MonitorType = "host"
    }

    if ($Force) {
        $params.Add("Force", $Force)
    }

    Add-MonitorArray @params
}

<#
.SYNOPSIS
Remove an existing Pure Cloud Block Store from a Pure Storage CBS AVS monitor

.DESCRIPTION
Remove an existing Pure Cloud Block Store from a Pure Storage CBS AVS monitor. If the Pure Block store already exists, it will be overwritten

.PARAMETER MonitorResourceGroup
ResourceGroup to host monitor infrastructure components

.PARAMETER PureCloudBlockStoreEndpoint
Pure Cloud Block Store endpoint address

.EXAMPLE
Remove-PCBSAVSMonitorArray -MonitorResourceGroup myMonitorGroup -PureCloudBlockStoreEndpoint myArray

.NOTES
Must be logged in to Azure (using Connect-AzAccount) before running this cmdlet
#>

function Remove-PCBSAVSMonitorArray {
    [CmdletBinding()]
    Param (
      [Parameter(Mandatory=$true)]
      [String]$MonitorResourceGroup,

      [Parameter(Mandatory=$true)]
      [String]$PureCloudBlockStoreEndpoint
    )

    $params = @{
      MonitorResourceGroup = $MonitorResourceGroup
      MonitorType = "host"
      PureCloudBlockStoreEndpoint = $PureCloudBlockStoreEndpoint
    }
    Remove-MonitorArray @params
}

function Get-DefaultUtilizationThreshold {
    [CmdletBinding()]
    Param (
      [Parameter(Mandatory=$true)]
      $ResourceGroupName
    )

    $AzFunctionApp = Get-AzFunctionApp -ResourceGroupName $ResourceGroupName
    if (-not $AzFunctionApp) {
        throw "Resource group $ResourceGroupName does not exist"
    }
    $AppSettings = Get-AzFunctionAppSetting -ResourceGroupName $ResourceGroupName -Name $AzFunctionApp.Name
    $DefaultUtilizationThreshold = $DEFAULT_UTILIZATION_THRESHOLD
    if ($AppSettings["DEFAULT_UTILIZATION_THRESHOLD"]) {
        $DefaultUtilizationThreshold = [int]$AppSettings["DEFAULT_UTILIZATION_THRESHOLD"]
    }
    return $DefaultUtilizationThreshold
}

<#
.SYNOPSIS
Fully remove a Pure Storage CBS Capacity monitor deployment from Azure infrastructure

.DESCRIPTION
Fully remove a Pure Storage CBS capacity monitor deployment from Azure infrastructure. The resource group and its resources will be destroyed. The vNet subnet used by the monitor will also be remove from the vNet.

.PARAMETER MonitorResourceGroup
ResourceGroup to host monitor infrastructure components

 .PARAMETER RemoveSubnet
Optional. Indicates whether to remove the subnet used by the monitor from the vNet. If not provided, the subnet will not be removed.

.EXAMPLE
Remove-PCBSCapacityMonitor -MonitorResourceGroup "myCapacityMonitorResourceGroup"

.NOTES
Must be logged in to Azure (using Connect-AzAccount) before running this cmdlet
#>

function Remove-PCBSCapacityMonitor {
  [CmdletBinding()]
    Param (
      [Parameter(Mandatory=$true)]
      [String]$MonitorResourceGroup,

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

    $params = @{
      MonitorResourceGroup = $MonitorResourceGroup
      MonitorType = "capacity"
      RemoveSubnet = $RemoveSubnet
    }

    Remove-Monitor @params
}

<#
.SYNOPSIS
Add a Pure Cloud Block Store to an existing Pure Storage CBS capacity monitor

.DESCRIPTION
Add a Pure Cloud Block Store to an existing Pure Storage CBS capacity monitor. If the Pure Block store already exists, it will be overwritten

.PARAMETER MonitorResourceGroup
ResourceGroup to host monitor infrastructure components

.PARAMETER PureCloudBlockStoreEndpoint
Pure Cloud Block Store endpoint address

.PARAMETER PureCloudBlockStoreCredential
Pure Cloud Block Store credential

.PARAMETER UtilizationThreshold
Optional. The utilization threshold for the Pure Cloud Block Store. If not provided, the default threshold will be used.

.PARAMETER Force
Optional. If specified, the cmdlet will not throw error if the Pure Cloud Block Store cannot be verified

.EXAMPLE
Add-PCBSCapacityMonitorArray -MonitorResourceGroup myMonitorGroup -PureCloudBlockStoreEndpoint myArray -PureCloudBlockStoreCredential (Get-Credential) `
                             -UtilizationThreshold 80

.NOTES
Must be logged in to Azure (using Connect-AzAccount) before running this cmdlet
#>

function Add-PCBSCapacityMonitorArray {
  [CmdletBinding()]
  Param (
    [Parameter(Mandatory=$true)]
    [String]$MonitorResourceGroup,

    [Parameter(Mandatory=$true)]
    [String]$PureCloudBlockStoreEndpoint,

    [Parameter(Mandatory=$true)]
    [pscredential]$PureCloudBlockStoreCredential,

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

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

  $params = @{
    MonitorResourceGroup = $MonitorResourceGroup
    PureCloudBlockStoreEndpoint = $PureCloudBlockStoreEndpoint
    PureCloudBlockStoreCredential = $PureCloudBlockStoreCredential
    MonitorType = "capacity"
  }

  if ($UtilizationThreshold) {
    $params.Add("UtilizationThreshold", $UtilizationThreshold)
  }

  if ($Force) {
    $params.Add("Force", $Force)
  }

  Add-MonitorArray @params
}

<#
.SYNOPSIS
Get metadata of a Pure Storage CBS capacity monitor

.DESCRIPTION
Get metadata of a Pure Storage CBS capacity monitor

.PARAMETER MonitorResourceGroup
ResourceGroup that hosts monitor infrastructure components
#>

function Get-PCBSCapacityMonitor {
  param (
    [Parameter(Mandatory=$true)]
    [String]$MonitorResourceGroup
  )

  $result = @{Arrays = @()}
  $ResourceGroup = Get-AzResourceGroup -Name $MonitorResourceGroup

  if (-not $ResourceGroup) {
      throw "Resource group $MonitorResourceGroup does not exist"
  }

  if (-not $ResourceGroup.Tags["PureStorage.CBS.AVS"]) {
      throw "Resouce group $MonitorResourceGroup specified does not host Pure Storage CBS AVS monitor"
  }

  # Get global utilization threshold
  $DefaultUtilizationThreshold = Get-DefaultUtilizationThreshold -ResourceGroupName $MonitorResourceGroup
  $result["DefaultUtilizationThreshold"] = $DefaultUtilizationThreshold

  $KeyVault = Get-AzKeyVault -ResourceGroupName $MonitorResourceGroup

  # List CBS arras and their corresponding utilization threshold
  $UserPrincipalName = (Get-AzContext).Account.Id
  $KeyVault = Get-AzKeyVault -ResourceGroupName $MonitorResourceGroup
  Set-AzKeyVaultAccessPolicy -VaultName $KeyVault.VaultName  -UserPrincipalName $UserPrincipalName -PermissionsToSecrets set,delete,get,purge,list

  $Secrets = Get-AzKeyVaultSecret -VaultName $KeyVault.VaultName | where-object {$_.Name -like "*-$($KeyVault.VaultName)-capacity-username"}
  foreach ($Secret in $Secrets) {
      $ArrayName = ($Secret.name -Split "-$($KeyVault.VaultName)-capacity-username")[0]
      $EncodedThreshold = Get-AzKeyVaultSecret -VaultName $KeyVault.VaultName -Name "$($ArrayName)-$($KeyVault.VaultName)-capacity-threshold"
      if ($EncodedThreshold) {
        $Threshold = [int] (ConvertFrom-SecureString -SecureString $EncodedThreshold.SecretValue -AsPlainText)
      }
      else {
        $Threshold = $null
      }
      # If the string matches the format like "172-168-1-0", the array ip addressed was processed because secret name does not allow "."
      if ($ArrayName -match "^\d+-\d+-\d+-\d+$") {
          $ArrayName = $ArrayName.Replace("-", ".")
      }

      $result["Arrays"] += @{ArrayName = $ArrayName; Threshold=$Threshold}
  }
  return $result
}

<#
.SYNOPSIS
Remove an existing Pure Cloud Block Store from a Pure Storage CBS capacity monitor

.DESCRIPTION
Remove an existing Pure Cloud Block Store from a Pure Storage CBS capacity monitor.

.PARAMETER MonitorResourceGroup
ResourceGroup that hosts the monitor infrastructure components

.PARAMETER PureCloudBlockStoreEndpoint
Pure Cloud Block Store endpoint address
#>


function Remove-PCBSCapacityMonitorArray {
  param (
    [Parameter(Mandatory=$true)]
    [String]$MonitorResourceGroup,

    [Parameter(Mandatory=$true)]
    [String]$PureCloudBlockStoreEndpoint
  )

  $params = @{
    MonitorResourceGroup = $MonitorResourceGroup
    MonitorType = "capacity"
    PureCloudBlockStoreEndpoint = $PureCloudBlockStoreEndpoint
  }

  Remove-MonitorArray @params
}

Export-ModuleMember -Function Build-PCBSCluster
Export-ModuleMember -Function New-PCBSVmfsDatastore
Export-ModuleMember -Function Restore-PCBSVmfsDatastore
Export-ModuleMember -Function Remove-PCBSVmfsDatastore
Export-ModuleMember -Function Set-PCBSVmfsCapacity
Export-ModuleMember -Function Deploy-PCBSAVSMonitor
Export-ModuleMember -Function Remove-PCBSAVSMonitor
Export-ModuleMember -Function Add-PCBSAVSMonitorArray
Export-ModuleMember -Function Remove-PCBSAVSMonitorArray
Export-ModuleMember -Function Get-PCBSAVSMonitorArray
Export-ModuleMember -Function New-PCBSVvolDataStore
Export-ModuleMember -Function Remove-PCBSVvolDataStore
Export-ModuleMember -Function New-PCBSVASAProvider
Export-ModuleMember -Function Update-PCBSVASAProvider
Export-ModuleMember -Function New-PCBSStoragePolicy
Export-ModuleMember -Function Remove-PCBSStoragePolicy
Export-ModuleMember -Function Start-PCBSFailover
Export-ModuleMember -Function Stop-PCBSFailoverTest
Export-ModuleMember -Function Start-PCBSFailoverCleanup
Export-ModuleMember -Function Start-PCBSFailoverReverse
Export-ModuleMember -Function Sync-PCBSReplicationGroup
Export-ModuleMember -Function Deploy-PCBSCapacityMonitor
Export-ModuleMember -Function Remove-PCBSCapacityMonitor
Export-ModuleMember -Function Add-PCBSCapacityMonitorArray
Export-ModuleMember -Function Get-PCBSCapacityMonitor
Export-ModuleMember -Function Remove-PCBSCapacityMonitorArray

# SIG # Begin signature block
# MIIuiQYJKoZIhvcNAQcCoIIuejCCLnYCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCB+BhtuF3Ri7Ogf
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