Once of my favorite features on Cisco MDS switches is Device Aliasing. It is, simply put, aliases for World Wide Names which can be referenced in your config rather than a cryptic WWN. For a good overview on Device Aliasing head over to Scott Lowe’s blog post on the subject. Recently I had an environment which wasn’t using device aliasing at all – something I wanted to rectify. Mapping over 300 World Wide Names to host names was a daunting task, so I decided to automate it! Big surprise, right?
I create a Perl script which takes a WWN as input and gives output, based on zone names, which can be ran on an MDS switch to create an alias. The trick is figuring out the name of the server, so I turned to my zones. My host names are included in my zoning naming standard, like this:
As you can see my zones follow a standard where the 3rd peice of information is the name. Running this script with the WWN as an argument is as simple as shown here:
[box]cincystorage@syncli01 pub $ ./mk_dev_alias.pl 21:00:00:24:df:3d:2a:48
(10.50.28.3) device-alias name testserverpwwn 21:00:00:24:df:3d:2a:48[/box]
Before we ca do any of this we have to configure three lines in the script: the switch ip addresses, the delimiter in the zone names (underscore in my case), and the position of the server name in the zone name . What happens is the zone name is split based on the define delimiter, underscore, and the position of the server name is referenced by number starting with 0. In the above example the position is 2. Putting all that information into the script is easy in your favorite text editor. Near the top you’ll see the following lines to be edited:
my @switches = ("10.10.2.3", "10.10.2.4");
my $delim = "_";
my $pos = 2;
That it for now, in my next post i’ll show you how I ran this for an entire switch rather than passing a wwn. In the mean time, you can check out the script here:
Comments are closed, but trackbacks and pingbacks are open.