IBM FlashSystem

IBM FlashSystem

Find answers and share expertise on IBM FlashSystem


#Storage
#Datasecurity
#Storage
#FlashSystem
 View Only

Automating Policy-Based Replication in IBM FlashSystem with PowerShell

By SUMIT GUPTA posted 13 days ago

  

Automating Policy-Based Replication on IBM Storage Virtualize with PowerShell

Policy-Based Replication (PBR) is IBM Storage Virtualize's approach to declarative, topology-aware data replication. Rather than wiring up individual FlashCopy mappings and consistency groups by hand, PBR lets you describe what should be replicated and where, then lets the system continuously enforce that intent — across two sites, with configurable RPO alerting, and with volumes automatically enrolled as soon as they are added to a replication-policy-enabled volume group.

Setting up PBR for the first time involves a chain of interdependent objects: a trusted connection between the two clusters, an FC or IP partnership, linked storage pools, a replication policy, volume groups, and host mappings. Doing this by hand through the GUI or CLI — especially across multiple environments — is repetitive, error-prone, and hard to audit.

With the release of v1.1.0 of the IBM Storage Virtualize PowerShell Toolkit, the entire PBR setup sequence can be expressed as a single idempotent script — safe to run on a fresh cluster, safe to re-run if it fails halfway through. This post walks through the workflow step by step.

Getting Started

The toolkit is available on GitHub. If you are upgrading from v1.0.0, no changes to existing scripts are required — v1.1.0 is fully additive.

# Clone or pull the latest version
git clone https://github.com/IBM/IBM-SV-PowerShell.git

# Install the updated module
.\Install-Module.ps1

# Verify the installed version
Get-Module -Name IBMStorageVirtualize -ListAvailable

# Explore available cmdlets
Get-Command -Module IBMStorageVirtualize
Get-Help New-IBMSVReplicationPolicy -Examples

The PBR Setup Workflow

The end-to-end automation follows eight ordered steps:

  • Step 0 - Connect
  • Step 1 - Create Truststore
  • Step 2 - Create Partnership
  • Step 3 - Enable PBR
  • Step 4 - Link Storage Pools
  • Step 5 - Replication Policy
  • Step 6 - VG creation
  • Step 7 - Apply Replication Policy to VG
  • Step 8 - Perform Host Mapping

Cmdlets Used in This Workflow

The table below lists every cmdlet called in the PBR script. Cmdlets marked new in v1.1 were introduced in this release.

Caption
Cmdlet Role in PBR Setup
Connect-IBMStorageVirtualize Authenticates and opens a REST session to a cluster.
Disconnect-IBMStorageVirtualize Closes the authenticated session after setup completes.
New-IBMSVTruststore new in v1.1 Exchanges TLS certificates and creates truststores on both clusters.
New-IBMSVPartnership new in v1.1 Creates an FC or IP replication partnership on both clusters.
Set-IBMSVPartnership new in v1.1 Enables Policy-Based Replication on the partnership.
Get-IBMSVPool Retrieves the primary pool's replication link UID.
Set-IBMSVPool Stamps the replication link UID onto the secondary pool.
Get-IBMSVSystem Fetches each cluster's system ID for the replication policy.
New-IBMSVReplicationPolicy new in v1.1 Creates a named replication policy with topology and RPO settings.
New-IBMSVVolumeGroup Creates a volume group bound to the replication policy.
New-IBMSVVolume Provisions volumes in the pool and enrolls them in the volume group.
New-IBMSVVolToHostMap Maps each volume to the target host for I/O access.

The Inventory File

All site-specific values live in a separate inventory file. Fill this in once per environment, then point any number of task scripts at it. Keeping configuration separate from logic makes scripts portable and version-control friendly.

pbr_inventory.ps1
# ===========================================================================
# PBR Inventory — fill in your values before running pbr_tasks.ps1
# ===========================================================================

$PrimaryClusterIP       = "10.10.10.1"
$PrimaryClusterUsername = "pwsh_user"
$PrimaryClusterPassword = "Str0ng$ecret!"

$SecondaryClusterIP       = "10.10.10.2"
$SecondaryClusterUsername = "pwsh_user"
$SecondaryClusterPassword = "Str0ng$ecret!"

$HostName        = "pwsh_host"       # host must already exist on primary cluster
$VolumePrefix    = "pwsh_vol_"       # volumes will be named pwsh_vol_1, pwsh_vol_2, ...
$VolumeSize      = 10                # size per volume
$VolumeUnit      = "gb"              # b | kb | mb | gb | tb | pb
$VolumeGroupName = "pwsh_vg"
$NumberOfVolumes = 10

# --- Policy names -----------------------------------------------------------
$ReplicationPolicyName = "pwsh_rp0"
$RpoAlertSeconds       = 300

# --- Pool names -------------------------------------------------------------
$PrimaryPoolName   = "site0pool0"
$SecondaryPoolName = "site1pool1"

# --- Truststore and partnership ---------------------------------------------
$PrimaryTruststoreName   = "pwsh_ts0"
$SecondaryTruststoreName = "pwsh_ts0"
$LinkBandwidthMbits      = 1000

PBR Setup Script

With the inventory filled in, the task script runs through all eight steps. Every cmdlet is idempotent — if an object already exists it is returned unchanged, so the script is safe to re-run after a partial failure.

pbr_setup.ps1
#Requires -Modules IBMStorageVirtualize

Import-Module IBMStorageVirtualize -ErrorAction Stop

. "$PSScriptRoot\pbr_inventory.ps1"

# --- Build credentials from inventory values --------------------------------
$PrimaryCredential = [pscredential]::new(
    $PrimaryClusterUsername,
    (ConvertTo-SecureString $PrimaryClusterPassword -AsPlainText -Force)
)
$SecondaryCredential = [pscredential]::new(
    $SecondaryClusterUsername,
    (ConvertTo-SecureString $SecondaryClusterPassword -AsPlainText -Force)
)

# ===========================================================================
Write-Host "[0] Fetch auth tokens — connect to both clusters"

Connect-IBMStorageVirtualize -Cluster $PrimaryClusterIP   -Credential $PrimaryCredential   -Primary -AllowCredentialCaching -AutoAddHostKey
Connect-IBMStorageVirtualize -Cluster $SecondaryClusterIP -Credential $SecondaryCredential -AllowCredentialCaching -AutoAddHostKey

# ===========================================================================
Write-Host "[1] Create truststore on both systems"

New-IBMSVTruststore `
    -Cluster              $PrimaryClusterIP `
    -Name                 $PrimaryTruststoreName `
    -RemoteTruststoreName $SecondaryTruststoreName `
    -RemoteCluster        $SecondaryClusterIP | Out-Null

# ===========================================================================
Write-Host "[2] Create partnership on both systems"

New-IBMSVPartnership `
    -Cluster            $PrimaryClusterIP `
    -Type               'FC' `
    -RemoteCluster      $SecondaryClusterIP `
    -LinkBandwidthMbits $LinkBandwidthMbits | Out-Null

# ===========================================================================
Write-Host "[3] Enable PBR on partnership on both sides"

Set-IBMSVPartnership `
    -Cluster       $PrimaryClusterIP `
    -RemoteCluster $SecondaryClusterIP `
    -PBRinUse      'yes'

# ===========================================================================
Write-Host "[4] Link pools — copy replication pool link UID from primary to secondary"

$replicationPoolLinkUid = (Get-IBMSVPool -Cluster $PrimaryClusterIP -ObjectName $PrimaryPoolName).replication_pool_link_uid

Set-IBMSVPool `
    -Cluster                $SecondaryClusterIP `
    -Name                   $SecondaryPoolName `
    -ReplicationPoolLinkUid $replicationPoolLinkUid

# ===========================================================================
Write-Host "[5] Creating replication policy"

$primaryClusterId   = (Get-IBMSVSystem -Cluster $PrimaryClusterIP).id
$secondaryClusterId = (Get-IBMSVSystem -Cluster $SecondaryClusterIP).id

New-IBMSVReplicationPolicy `
    -Cluster         $PrimaryClusterIP `
    -Name            $ReplicationPolicyName `
    -Topology        '2-site-async-dr' `
    -Location1System $primaryClusterId `
    -Location1IOGrp  0 `
    -Location2System $secondaryClusterId `
    -Location2IOGrp  0 `
    -RpoAlert        $RpoAlertSeconds | Out-Null

# ===========================================================================
Write-Host "[6] Creating volume group"

New-IBMSVVolumeGroup `
    -Cluster           $PrimaryClusterIP `
    -Name              $VolumeGroupName `
    -ReplicationPolicy $ReplicationPolicyName | Out-Null

# ===========================================================================
Write-Host "[7] Create volumes and add to volume group"

for ($i = 1; $i -le $NumberOfVolumes; $i++) {
    New-IBMSVVolume `
        -Cluster     $PrimaryClusterIP `
        -Name        "$VolumePrefix$i" `
        -Size        $VolumeSize `
        -Unit        $VolumeUnit `
        -Pool        $PrimaryPoolName `
        -VolumeGroup $VolumeGroupName | Out-Null
}

# ===========================================================================
Write-Host "[8] Mapping volumes to host '$HostName'..."

for ($i = 1; $i -le $NumberOfVolumes; $i++) {
    New-IBMSVVolToHostMap `
        -Cluster  $PrimaryClusterIP `
        -Volume   "$VolumePrefix$i" `
        -HostName $HostName | Out-Null
}

Write-Host "PBR setup complete."

Disconnect-IBMStorageVirtualize -Cluster $PrimaryClusterIP
Disconnect-IBMStorageVirtualize -Cluster $SecondaryClusterIP

Conclusion

The above PBR example highlights how PowerShell replaces lengthy manual configuration with a concise, repeatable workflow. By automating the orchestration of dependent tasks, it simplifies Policy-Based Replication for Windows and VMware administrators, enabling them to configure and manage replication with greater speed, consistency and efficiency.


#community-stories2
0 comments
20 views

Permalink