There
have been a number of times where I've need to take zoning from one
fabric, and create it on another fabric. Typically this is when doing
switch migrations where I am going to create one or more new fabrics,
re-create the zoning, then move the host and storage FC cables one
fabric at a time.
This happened recently when I was migrating to new switches, and the old switches didn't have a license to create an ISL.
This is also a handy way to have a backup of your zoning configuration.
I have a linux VM running on my laptop with ksh installed, so I can just use it there.
All
you need is to SSH into the switch you want to grab the zoning off and
run the command "zoneshow". Put the full output into a text file onto
the linux or AIX server you are going to run the script on, fill out the
variables in the script with the config name you want to use, and if
you want to create the config, and it will spit out the commands to
create the zoning.
These are:
- zonecreate (create the zones)
- cfgcreate (create the zoning config)
- cfgadd (add the zones to your zoning configuration)
- cfgsave (save the defined zoning configuration)
- cfgenable (enable the zoning configuration to the fabric)
Hopefully this saves someone some time.
#!/bin/ksh
#set -x v
ZON EFIL E=/p ath_ to_z ones how_ outp ut.t x t
NEW _CFG NAME ="my _new _zon e_co nfig _nam e "
CRE ATE_ CFG= "no "
# Grab the Aliases
cat $ZONEFILE |grep -n alias: | sed "s/://g" | { while read OUTPUT
do
ALINAME=`print $OUTPUT |awk '{print $3}'`
THISLINE=`print $OUTPUT |awk '{print $1}'`
NEXTLINE=`expr $THISLINE + 1`
MEMBERS=`head -${NEXTLINE} $ZONEFILE |tail -1`
echo alicreate $ALINAME"," "'"$MEMBERS"'"
done }
# Grab the Zones
STOPLINE=`cat $ZONEFILE |grep -n "Effective" | sed "s/:/ /g" |awk '{print $1}'`
head -${STOPLINE} ${ZONEFILE} |grep -n zone: | sed "s/:/ /g" | { while read OUTPUT
do
ZONENAME=`print $OUTPUT |awk '{print $3}'`
THISLINE=`print $OUTPUT |awk '{print $1}'`
NEXTLINE=`expr $THISLINE + 1`
MEMBERS=`head -${NEXTLINE} $ZONEFILE |tail -1`
echo zonecreate $ZONENAME"," "'"$MEMBERS"'"
done }
# Create the zone config if required
case CREATE_CFG in
yes| Yes| YES| y )
*)
;;
esac
# Add to the zone config
head -${STOPLINE} ${ZONEFILE} |grep zone: | sed "s/:/ /g" | { while read OUTPUT
do
ZONENAME=`print $OUTPUT |awk '{print $2}'`
echo cfgadd $NEW_CFGNAME"," $ZONENAME
done }
# Save and Activate
echo cfgsave
echo cfgenable $NEW_CFGNAME
0 comments:
Post a Comment