NAME
Net::Telnet::Brcd - Perl libraries to contact Brocade switch
SYNOPSIS
use Net::Telnet::Brcd;
my $sw = new Net::Telnet::Brcd;
$sw->connect($sw_name,$user,$pass) or die "\n";
%wwn_port = $sw->switchShow(-bywwn=>1);
my @lines = $sw->cmd("configShow");
DESCRIPTION
Perl libraries to contact Brocade switch with a telnet session. You could set this environment variable to simplify coding:
BRCD_USER
-
login name
BRCD_PASS
-
login password
BRCD_SWITCH
-
switch name or IP address
FUNCTIONS
new
my $brcd = new Net::Telnet::Brcd;
Initialize Brocade object. No arguments needed.
connect
$brcd->connect($switch,$user,$pass);
Connect to a Brocade switch with a telnet session. Return undef on error. Do it before any switch command.
The object '$brcd' store the telnet session. If you want simultaneous connection you need an other object.
cmd
my @results=$brcd->cmd("configShow");
Send a Brocade command to the switch and return all the lines. Line are cleaned (no \r \n).
If command parameters is given by array:
my @results=$brcd->cmd("aliAdd","toto",":00:00:0:5:4:54:4:5");
The command generated are:
aliAdd "toto", ":00:00:0:5:4:54:4:5"
aliShow
my %alias_to_wwn = $brcd->aliShow();
Send command aliShow all and return a hash with key
as alias and WWN as value. If you use option -bywwn
, key is WWN and value is alias:
my %wwn_to_alias = $brcd->aliShow(-bywwn => 1);
By default, option -onlywwn
is activated. The command get only WWN mapping. If you use alias with port number use option -byport =
1>. If you have mixed alias, desactivate -onlywwn =
0>.
zoneShow
my %zone = $brcd->zoneShow();
Return a hash with one key is a zone and value an array of alias member or WWN or ports.
my %zone = $brcd->zoneShow();
foreach my $zone (%zone) {
print "$zone:\n\t";
print join("; ", keys %{$zone{$zone}} ),"\n";
}
If you set option -bymember=1
, you have a hash with key a member and value an array of zones where member exists.
It's important to run this command before using the followings functions.
zoneMember
my @member = $brcd->zoneMember("z_sctxp004_0");
Return an array of member of one zone. Need to execute $brcd-
zoneShow> before.
memberZone
my @zones = $brcd->memberZone("w_sctxp004_0");
Return an array of zones where member exist. Need to execute $brcd-
zoneShow> before.
switchShow
my %port = $brcd->switchShow();
This function send the switchShow command on the connected switch (see only one switch not all the fabric). It returns the following structure:
$port{port number}->{SPEED} = <2G|1G|...>
->{STATUS} = <OnLine|NoLight|...>
->{SLOT} = blade number
->{NUMBER} = port number on blade
->{TYPE} = <E-Port|F-Port|...>
->{WWN} if connected
If you set -bywwn=1
, it's return only a hash of WWN as key and port number as value.
my %wwn_to_port = $brcd->switchShow(-bywwn => 1);
If you set -withportname=1
, the portName command is execute on each port of the switch to get the portname.
toSlot
my ($slot,$slot_number) = $brcd->toSlot(36);
my $slot_address = $brcd->toSlot(36);
The function need to have an exectution of $brcd-
switchShow>. It's usefull for a Director Switch to have the translation between absolute port number and slot/port number value.
If you use it in scalar context, the command return the string slot/slot_number
(portShow format).
portShow
my %port = $brcd->portShow($port_number);
my $portname = $brcd->portShow($port_number);
Need to have running the $brcd-
switchShow> command. The function use the toSlot
function before sending the portShow command.
In array context, function return a hash with key as the portName. In scalar context returns the portname.
output
print $brcd->output();
Return the last function output.
wwn_re
my $wwn_re = $brcd->wwn_re();
if (m/($wwn_re)/) {
...
}
Return the WWN re.
fabricShow
my %fabric = $brcd->fabricShow();
Return a hash with all the switch in the fabric. Return the result byswitch name -byswitch
or -bydomain=1
.
currentFabric
my $dns_fabric = $brcd->currentFabric();
Return the current fabric NAME.
isWwn
if ($brcd->isWwn($str)) {
...
}
Test a string to check if it is a WWN.
portAlias
my ($domain, $port_number) = $brcd->portAlias("199,6");
Split a string whith zoning format in domain and port number in the switch.
SEE ALSO
Brocade Documentation, BrcdAPI, Net::Telnet.
BUGS
...
AUTHOR
Laurent Bendavid, <bendavid.laurent@fre.fr>
COPYRIGHT AND LICENSE
Copyright (C) 2005 by Laurent Bendavid
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.
- Version
-
1.3
- History
-
Created 6/27/2005, Modified 3/26/07 18:32:59