Pages

7/03/2013

Powershell: Compellent SAN configuration

Add Servers, Create boot volumes, map volumes to servers. Requires the right version of Compellent Storage Center and the Compellent plugin for Powershell

$user = Read-Host "userid"
$pw = Read-Host "Enter Password for $user" -AsSecureString
$san1 = get-scconnection -HostName san1 -User $user -Password $pw
$san2 = get-scconnection -HostName san2 -User $user -Password $pw
#$pass ='' #erase plain txt pw
#remove-scserver -connection $san1 $server

$inputfile = ".\test.csv"
$profiles = get-content $inputfile

foreach ($line in $profiles) {
$line
 $line = ($line -split',')
 $profile = $line[0]
 $wwn1 = $line[1]
 $wwn2 = $line[2]
 
 #Create Server
 $s1server = new-scserver -connection $san1 -name $profile
 $s2server = new-scserver -connection $san2 -name $profile

 #Set WWNs
 add-scserverport -connection $san1 -scserver $s1server -worldwidenames $wwn1
 add-scserverport -connection $san1 -scserver $s1server -worldwidenames $wwn2
 add-scserverport -connection $san2 -scserver $s2server -worldwidenames $wwn1
 add-scserverport -connection $san2 -scserver $s2server -worldwidenames $wwn2
 #Set Server OS Type 
 $s1ostype = get-SCOSType -index 35 -connection $san1
 $s1server = get-SCServer -connection $san1 -name $profile
 $s2ostype = get-SCOSType -index 35 -connection $san2
 $s2server = get-SCServer -connection $san2 -name $profile
 set-scserver $s1server -connection $san1 -SCOSType $s1ostype
 set-scserver $s2server -connection $san2 -SCOSType $s2ostype

 #Create Boot LUN
 #use "Boot LUNs" storage profile
 $storageprofile = get-scstorageprofile -connection $san2 -name "Boot LUNs"
 $volname = $profile+"_boot"
 $folder = get-scvolumefolder -connection $san2 -name "BOOT LUNS"
 $volume = new-scvolume -connection $san2 -name $volname -parentfolder $folder -scstorageprofile $storageprofile -size 10g
 #map volume
 $map = new-scvolumemap -scvolume $volume -scserver $s2server -connection $san2
}#end foreach profile
Remove-SCConnection $san1
Remove-SCConnection $san2

No comments: