Home > Command Line > Creating iGroups on the DR filer

Creating iGroups on the DR filer

January 22nd, 2009

This is another script I wrote to aid in site failover. Basically the snapmirror script works great to bring volumes online, but if everything is in VMware (and as such iSCSI from within the VM), you want these to be automatically re-mapped, and save you some leg work!

Well, this script would run from a server sat in the DR location that has access to the primary filers. I’ve tried to make this script pretty dynamic, so you can put in as many primary filers as you want (create a ‘primary_filers.txt’ file with 1 filer name per line). However it only fails over to one filer on the DR side. This would be easily remedied, but again, just showing a concept of how easy this sort of thing is to achieve.

The difficulty here is that ‘igroup show’ outputs ‘FCP’ and ‘iSCSI’, where as ‘igroup create’ requests you use ‘f’ and ‘i’, so a bit more scripting in the middle to solve this.

This script creates a script (and if run as a cron, simply overwrites it each time) that can be run to recreate all the iGroups on the DR filer. Really handy if you have a few LUNs that need mapping. Even doing this manually for 10 is a pain. Most of my customers have at least 50+

[root@esx101 root]# cat igroups.sh
#Script to auto-generate an iGroup create script for site failover


echo “#!/bin/sh” > igroup_create.sh
echo “#iGroup Create Script AutoGenerated on `date`” >> igroup_create.sh
echo >> igroup_create.sh

for filer in `cat primary_filers.txt`; do
 ssh -c 3des $filer igroup show > igroups.txt
 while read line
  check=`echo “$line” | grep “ostype:” | awk ‘{print $3}’`
  if [ “$check” = “(ostype:” ]; then
   check=`echo “$line” | awk ‘{print $2}’`
   if [ “$check” = “(FCP)” ]; then
   elif [ “$check” = “(iSCSI)” ]; then
   igroup_os=`echo “$line” | awk ‘{print $4}’| cut -d”)” -f1`
   igroup_name=`echo “$line” | grep “ostype:” | awk ‘{print $1}’`
   igroup_create=”igroup create -$prot -t $igroup_os $igroup_name”
   echo ssh -c 3des $dr_filer $igroup_create >> igroup_create.sh
   igroup_member=`echo “$line” | awk ‘{print $1}’`
   igroup_add=”igroup add $igroup_name $igroup_member”
   echo ssh -c 3des $dr_filer $igroup_add >> igroup_create.sh
 done < “igroups.txt”
rm -f igroups.txt

Command Line , , ,

  1. No comments yet.
  1. No trackbacks yet.

This site is not affiliated or sponsored in anyway by NetApp or any other company mentioned within.
%d bloggers like this: