I have been working on some scripts to allow the rapid creation of vservers where we can also create ls mirrors on all nodes.
Here is what I have come up with so far.
I have set this up using a text file with one or more vservers to create first line is required.
name,RootVolumeSecurityStyle,rootvolumeaggregate,NameServerSwitch,NameMappingSwitch,Language,Create_ls
vs01_vmware_de,ntfs,n1_aggr1,file,file,en_us.utf_8,true
vs02_nfs_de,ntfs,n2_aggr2,file,file,en_us.utf_8,true
# The script assumes import-module dataontap ; connect-nccontroller mycluster
$vservers = import-csv vservers.csv
$vservers | foreach {
new-ncvserver -name $_.name -RootVolume $($_.name+"_root") -RootVolumeAggregate $_.rootvolumeaggregate -NameServerSwitch $_.NameServerSwitch -RootVolumeSecurityStyle $_.RootVolumeSecurityStyle -NameMappingSwitch $_.NameMappingSwitch -Language $_.Language
}
#Query the Cluster and look for aggr1 to add the ls mirror to that aggreagate
$q = Get-NcAggr -Template
$q.Name = "*aggr1*"
#Loop through the vservers
#Loop through the aggregates queried
#Append _ls to the Name of the root volume
#remove dashes in the name
# I static set the volume size to 100m
$vservers | foreach {
if ($_.Create_ls -eq $true){
foreach ($ag in (Get-NcAggr -Query $q).name){
$lsvs = $_.name + "_" + (Get-NcAggr $ag).nodes.replace("-","_") + "_LS"
new-ncvol -Name $lsvs -Size 100m -Type dp -Aggregate $ag -JunctionPath $null -VserverContext $_.name | out-null
New-NcSnapmirror -Source ("//" + $_.name + "/" + $($_.name+"_root")) -Destination ("//" + $_.name + "/" + $lsvs) -Type LS |Set-NcSnapmirror -Schedule 5min |out-null
}
# After all mirrors have been added initialize the mirrors
Invoke-NcSnapmirrorLsInitialize ("//" + $_.name + "/" + $($_.name+"_root"))
}}
Enjoy,
John