Automate Creation of New V-Servers with Powershell with ls mirrors

by Frequent Contributor on ‎2013-05-13 12:05 PM

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

Warning!

This NetApp Community is public and open website that is indexed by search engines such as Google. Participation in the NetApp Community is voluntary. All content posted on the NetApp Community is publicly viewable and available. This includes the rich text editor which is not encrypted for https.

In accordance to our Code of Conduct and Community Terms of Use DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information
  • Copyrighted materials without the permission of the copyright owner

Files and content that do not abide by the Community Terms of Use or Code of Conduct will be removed. Continued non-compliance may result in NetApp Community account restrictions or termination.