Setup Replication Connections using PowerShell

Now that the new toolkit has been released its time to start with an example of using some of the new cmdlets. The focus of this post is setting up replication between a FA-420 and an FA-405.

The screenshots below show the two different arrays that will be connected for replication.

PureDemoArray (Replication Target)

 

MFT-PURE1 (Replication Source)

In order to setup the connection between both FlashArray’s you need a Connection Key from the replication target. In order to get the details for any FlashArray using PowerShell the Get-PfaConfiguration cmdlet is used to retrieve all of the details for that particular array.

With a few more lines of PowerShell we can automatically connect the Replication Target and Replication Source without the need to go between the two web management GUIs.

Import-Module PureStoragePowerShell -WarningAction SilentlyContinue

# 1) Connect to Replication Target Array and get the connection key
$ReplTarget = Get-PfaApiToken -FlashArray 10.21.23.152 -Username pureuser -Password pureuser
$ReplSession = Connect-PfaController -FlashArray 10.21.23.152 -API_Token $ReplTarget.api_token
$ReplArray = Get-PfaConfiguration -FlashArray 10.21.23.152 -Session $ReplSession
$ReplArray.ConnectionKey

# 2) Connect to the Replication Source Array
$SourceToken = Get-PfaApiToken -FlashArray 10.21.8.82 -Username pureuser -Password pureuser
$SourceSession = Connect-PfaController -FlashArray 10.21.8.82 -API_Token $SourceToken.api_token
New-PfaConnection -FlashArray 10.21.8.82 -ManagementAddress 10.21.23.152 `
    -ConnectionKey $ReplArray.ConnectionKey -ReplicationAddress 10.21.23.153 -Session $SourceSession

Note: I typically don’t use the ‘tick‘ mark for line continuation but I did in the above sample script for readability.

MSFT-PURE1 is now connected to the Replication Target array named PureDemoArray.

Viewing the PureDemoArray web management GUI we can see that the PureDemoArray is also connected to the Replication Source, MSFT-PURE1.

It is just as easy to remove a connection using Remove-PfaConnection.

Import-Module PureStoragePowerShell -WarningAction SilentlyContinue

$SourceToken = Get-PfaApiToken -FlashArray 10.21.8.82 -Username pureuser -Password pureuser
$SourceSession = Connect-PfaController -FlashArray 10.21.8.82 -API_Token $SourceToken.api_token

Remove-PfaConnection -FlashArray 10.21.8.82 -Name PureDemoArray -Session $SourceSession

 

Here is a quick video that shows everything working live.

Thanks,
barkz

Add Comment

Required fields are marked *. Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.