-
-
Save sean-perryman/7e8cbb638cd87950fe483bed35034c37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($addr="192.168.16.25", $syncAddr="172.16.32.1", $port=3261, $user="root", $password="starwind", | |
$addr2="192.168.16.26", $syncAddr2="172.16.32.2", $port2=$port, $user2=$user, $password2=$password, | |
$addr3="192.168.16.27", $syncAddr3="172.16.32.3", $port3=$port, $user3=$user, $password3=$password, | |
#common | |
$initMethod="Clear", | |
$size=7100, | |
$sectorSize=512, | |
$failover=0, | |
#primary node | |
$imagePath="My computer\C\Storage", | |
$imageName="HA_LUN1", | |
$createImage=$true, | |
$targetAlias="HA_LUN1", | |
$autoSynch=$true, | |
$poolName="Pool1", | |
$syncSessionCount=1, | |
$aluaOptimized=$true, | |
$cacheMode="wb", | |
$cacheSize=128, | |
$syncInterface=$("#p2={0}:3260;#p3={1}:3260" -f $syncAddr2,$syncAddr3), | |
$hbInterface=$("#p2={0}:3260;#p3={1}:3260" -f $addr2,$addr3), | |
#secondary node | |
$imagePath2="My computer\C\Storage", | |
$imageName2="HA_LUN2", | |
$createImage2=$true, | |
$targetAlias2="HA_LUN2", | |
$autoSynch2=$true, | |
$poolName2="Pool2", | |
$syncSessionCount2=1, | |
$aluaOptimized2=$false, | |
$cacheMode2=$cacheMode, | |
$cacheSize2=$cacheSize, | |
$syncInterface2=$("#p1={0}:3260;#p3={1}:3260" -f $syncAddr,$syncAddr3), | |
$hbInterface2=$("#p1={0}:3260;#p3={1}:3260" -f $addr,$addr3), | |
#third node | |
$imagePath3="My computer\C\Storage", | |
$imageName3="HA_LUN3", | |
$createImage3=$true, | |
$targetAlias3="HA_LUN3", | |
$autoSynch3=$true, | |
$poolName3="Pool3", | |
$syncSessionCount3=1, | |
$aluaOptimized3=$false, | |
$cacheMode3=$cacheMode, | |
$cacheSize3=$cacheSize, | |
$syncInterface3=$("#p1={0}:3260;#p2={1}:3260" -f $syncAddr,$syncAddr2), | |
$hbInterface3=$("#p1={0}:3260;#p2={1}:3260" -f $addr,$addr2) | |
) | |
Import-Module StarWindX | |
try | |
{ | |
Enable-SWXLog | |
$server = New-SWServer -host $addr -port $port -user $user -password $password | |
$server.Connect() | |
$firstNode = new-Object Node | |
$firstNode.HostName = $addr | |
$firstNode.ImagePath = $imagePath | |
$firstNode.ImageName = $imageName | |
$firstNode.Size = $size | |
$firstNode.CreateImage = $createImage | |
$firstNode.TargetAlias = $targetAlias | |
$firstNode.AutoSynch = $autoSynch | |
$firstNode.SyncInterface = $syncInterface | |
$firstNode.HBInterface = $hbInterface | |
$firstNode.PoolName = $poolName | |
$firstNode.SyncSessionCount = $syncSessionCount | |
$firstNode.ALUAOptimized = $aluaOptimized | |
$firstNode.SectorSize = $sectorSize | |
$firstNode.CacheMode = $cacheMode | |
$firstNode.CacheSize = $cacheSize | |
$firstNode.FailoverStrategy = $failover | |
$secondNode = new-Object Node | |
$secondNode.HostName = $addr2 | |
$secondNode.HostPort = $port2 | |
$secondNode.Login = $user2 | |
$secondNode.Password = $password2 | |
$secondNode.ImagePath = $imagePath2 | |
$secondNode.ImageName = $imageName2 | |
$secondNode.CreateImage = $createImage2 | |
$secondNode.TargetAlias = $targetAlias2 | |
$secondNode.AutoSynch = $autoSynch2 | |
$secondNode.SyncInterface = $syncInterface2 | |
$secondNode.HBInterface = $hbInterface2 | |
$secondNode.SyncSessionCount = $syncSessionCount2 | |
$secondNode.ALUAOptimized = $aluaOptimized2 | |
$secondNode.CacheMode = $cacheMode2 | |
$secondNode.CacheSize = $cacheSize2 | |
$secondNode.FailoverStrategy = $failover | |
$thirdNode = new-Object Node | |
$thirdNode.HostName = $addr3 | |
$thirdNode.HostPort = $port3 | |
$thirdNode.Login = $user3 | |
$thirdNode.Password = $password3 | |
$thirdNode.ImagePath = $imagePath3 | |
$thirdNode.ImageName = $imageName3 | |
$thirdNode.CreateImage = $createImage3 | |
$thirdNode.TargetAlias = $targetAlias3 | |
$thirdNode.AutoSynch = $autoSynch3 | |
$thirdNode.SyncInterface = $syncInterface3 | |
$thirdNode.HBInterface = $hbInterface3 | |
$thirdNode.SyncSessionCount = $syncSessionCount3 | |
$thirdNode.ALUAOptimized = $aluaOptimized3 | |
$thirdNode.CacheMode = $cacheMode3 | |
$thirdNode.CacheSize = $cacheSize3 | |
$thirdNode.FailoverStrategy = $failover | |
$device = Add-HADevice -server $server -firstNode $firstNode -secondNode $secondNode -thirdNode $thirdNode -initMethod $initMethod | |
$syncState = $device.GetPropertyValue("ha_synch_status") | |
while ($syncState -ne "1") | |
{ | |
# | |
# Refresh device info | |
# | |
$device.Refresh() | |
$syncState = $device.GetPropertyValue("ha_synch_status") | |
$syncPercent = $device.GetPropertyValue("ha_synch_percent") | |
Start-Sleep -m 2000 | |
Write-Host "Synchronizing: $($syncPercent)%" -foreground yellow | |
} | |
} | |
catch | |
{ | |
Write-Host $_ -foreground red | |
} | |
finally | |
{ | |
$server.Disconnect() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment