Friday, 14 September 2018

PowerShell to Update Clusters with Multiple Cluster Peers in Multiple IPSpaces

Not something I’m likely to use where I am at-the-moment seeing as there are certain restrictions. Still, I thought I’d show how easy it would be to use the DataONTAP PowerShell Toolkit to connect to a cluster, find all the cluster peers, peer IPSpaces, and intercluster LIFs in each of those IPSpaces, and then connect to all the peer clusters and update the cluster peer's peer addresses. This is something you’d only really be interested in doing if expanding/contracting a cluster/clusters, or checking that existing clusters have their ‘Remote Intercluster Addresses’ configured correctly (‘Active IP Addresses’ manage themselves to a degree.)

Image: Update Cluster Peers in action

Note i: The script was tested with ONTAP 9.0RC1 and the DataONTAP PowerShell ToolKit 4.0.0.231 (I’m not sure why I had to put a dummy passphrase in the script, perhaps this “bug” is fixed in later versions.)
Note ii: Assumptions are that the same credentials can login to all the involved clusters, IPSpace names are consistent...

The Script


## SOURCE CLUSTER ##

Import-Module DataONTAP
$cluster  = Read-Host "Enter Cluster Name"
$username = Read-Host "Enter Admin User  "
$password = Read-Host "Enter Password    " -AsSecureString
$credential = New-Object System.Management.Automation.PsCredential($username,$password)
Connect-NcController $cluster -Credential $credential

$Peers = Get-NcClusterPeer
$Query = Get-NcNetInterface -Template
$Query.role = "intercluster"
$IcInts = Get-NcNetInterface -Query $Query

## INTERCLUSTER LIFS to IPSPACES (I2I) ##

[System.Object]$I2I = @{}
[System.Array]$I2I.IPSs = @()

$IcInts | Foreach{
  [Int]$Unique = ($I2I.IPSs).count
  [System.Array]$I2I.IPSs = ($I2I.IPSs += $_.ipspace) | Select-Object -Unique
  If($Unique -ne ($I2I.IPSs).count){[System.Array]$I2I.($_.Ipspace) = @()}
  $I2I.($_.Ipspace) += ($_.Address)
}

## PEER CLUSTERS ##

$Peers | Foreach{
  Connect-NcController $_.ClusterName -Credential $credential
  [String]$IPspace = (Get-NcClusterPeer -ClusterName $cluster).IpspaceName
  [Void](Get-NcClusterPeer -ClusterName $cluster | Set-NcClusterPeer -Address ($I2I.$IPspace) -Passphrase "anything")
}


1 comment:

  1. The best extravagant time in the world! If you want these cheap air max 90 uk, would you like these nikes? Has this happened but stopped? replica nike air max 90,best nike air max 95,fake nike air max 95 360,copy nike air max 97Because they are expensive for your steps, this is the place that is best for you. First of all, we should confirm this

    ReplyDelete