Perl Client
This appendix provides information about the Perl client, installing ActiveState Perl, and the SOAP:Lite package.
This appendix contains the following sections:
Before executing the Perl script, install ActiveState Perl and the SOAP:Lite package.
Installing Perl
Step 1
Download Perl from http://www.perl.org/get.html
Note
Choose and download the appropriate Perl version for your operating system.
Step 2
Run the downloaded executable file to install Perl.
Step 3
To verify whether Perl has been installed properly, use the perl -v CLI command in the command prompt.
If the installation is proper, the details of the installed version of Perl are displayed.
Running the Perl Clients
Note
To run a Perl client, the client file and its module file need to be in the same Perl folder.
From the Perl folder where the source files exist, enter the following command:
perl Client-File-Name FM-Server-IP Username password
Figure B-1 Running a Perl Client
Running the Zone Client
To run the zone client, the files zoneClient.plx and zoneModule.plx need to be in same directory.
From the Perl folder where the source files exist, enter the following command:
perl zoneClient.plx FM-Server-IP Username password
Running the Statistics Client
To run the statistics client, the files statistics.plx and statisticsModule.plx need to be in same directory.
From the Perl folder where the source files exist, enter the following command:
perl statistics.plx FM-Server-IP Username password
Sample Code
Note ●
The sample code provided here works only with DCNM release 6.1(x) and later. For prior DCNM versions, you need to make changes to the namespace base on the WSDL.
- To collect statistics related data, you need to turn on the PM.
Example B-1 ZoneClient.plx
# Description: zoneClient
my $vsan_wwn = '20:01:00:0d:ec:19:6a:81';
my $wwn = '20:00:00:0d:ec:19:6a:80';
my $zoneMemberFormat = 1;
my $zoneMemberIvrFabricIndex = -1;
my $zoneMemberIvrVsanIndex = -1;
my $zoneMemberId = 'b1a2334455667788';
my $zoneMemberLunId = '';
my $zoneSetName = 'ZoneSet5';
require 'zoneModule.plx';
($url,$username,$password) = @ARGV;
my $token = getToken($url,$username,$password);
print "\nError in getToken call \n";
my $zoneIndex = createZone($token,$vsanId,$vsan_wwn,$wwn,$zoneName,$readOnly,$broadcast,$qos,$qosPriority);
print "\nError in createZone call \n";
my $status = addZoneMemberToZone($token,$vsanId,$vsan_wwn,$wwn,$zoneName,$zoneMemberType,$zoneMemberFormat,$zoneMemberIvrFabricIndex,$zoneMemberIvrVsanIndex,$zoneMemberId,$zoneMemberLunId);
print "\nError in addZoneMemberToZone call \n";
my $zoneSetIndex = createZoneSet($token,$vsanId,$vsan_wwn,$wwn,$zoneSetName);
print "\nError in createZoneSet call \n";
my $status = addZoneToZoneset($token,$vsanId,$vsan_wwn,$wwn,$zoneIndex,$zoneName,$readOnly,$broadcast,$qos,$qosPriority,$zoneMemberDbId,$zoneMemberType,$zoneLastModtime,$zoneMemberLunId,$zoneisIvr,$zoneSetIndex,$zoneSetName,$active);
print "\nError in addZoneToZoneset call \n";
$status = activateZoneset($token,$vsanId,$vsan_wwn,$wwn,$zoneSetName);
print "\nError in activateZoneset call \n";
Example B-2 ZoneModule.plx
($url,$username,$password) = @_;
#->uri('http://ep.jaxws.dcbu.cisco.com/')
->proxy('https://'.$url.'/LogonWSService/LogonWS?wsdl')
->ns('http://ep.jaxws.dcbu.cisco.com/','namesp1');
my $username = SOAP::Data->type('string')->name('username')->value($username);
my $password = SOAP::Data->type('string')->name('password')->value($password);
my $expiration = SOAP::Data->type('long')->name('expiration')->value(100000000);
# Calling requestToken method
my $result = $client->requestToken($username,$password,$expiration);
unless ($result->fault) {
my $token = $result->result();
($token,$arg_vsanId,$arg_vsanwwn,$arg_wwn,$arg_zoneName,$arg_readOnly,$arg_broadcast,$arg_qos,$arg_qosPriority) = @_;
my $VsanKey = SOAP::Data->name("vsanKey" => \SOAP::Data->value(
SOAP::Data->name("vsanID" => $arg_vsanId),
SOAP::Data->name("pWwn" => \SOAP::Data->value(SOAP::Data->name("value" => $arg_vsanwwn)))->type("Wwn")))->type("VsanKey");
my $Wwn = SOAP::Data->name("switchKey" => \SOAP::Data->value(
SOAP::Data->name("wwn" => \SOAP::Data->value(SOAP::Data->name("value"=>$arg_wwn)))->type("Wwn")))->type("WwnKey");
my $zName = SOAP::Data->name("zoneName"=>$arg_zoneName);
my $readOnly = SOAP::Data->name("readOnly")->value($arg_readOnly);
my $broadcast = SOAP::Data->name("broadcast")->value($arg_broadcast);
my $qos = SOAP::Data->type('boolean')->name("qos")->value($arg_qos);
my $qosPriority = SOAP::Data->type('int')->name("qosPriority")->value($arg_qosPriority);
my $header = SOAP::Header->name('token')->prefix('m')->value($token)->uri('http://ep.cisco.dcbu.cisco.com')->type('string');
#->uri('http://ep.san.jaxws.dcbu.cisco.com/')
->proxy('https://'.$url.'/ZoneManagerWSService/ZoneManagerWS?wsdl')
->ns('http://ep.san.jaxws.dcbu.cisco.com/','namesp2');
# Calling createZone method
my $result = $client->createZone($header,$VsanKey,$Wwn,$zName,$readOnly,$broadcast,$qos,$qosPriority);
unless ($result->fault) {
return $result->valueof('//index');
# Adding Zone Member To Zone
sub addZoneMemberToZone {
my $arg_zoneMemberFormat;
my $arg_zoneMemberIvrFabricIndex;
my $arg_zoneMemberIvrVsanIndex;
($token,$arg_vsanId,$arg_vsanwwn,$arg_wwn,$arg_zoneName,$arg_zoneMemberType,$arg_zoneMemberFormat,$arg_zoneMemberIvrFabricIndex,$arg_zoneMemberIvrVsanIndex,$arg_zoneMemberId,$arg_zoneMemberLunId) = @_;
my @hex = ($arg_zoneMemberId =~ /(..)/g);
my @dec = map { hex($_) } @hex;
my @zoneMemberId = map { pack('C',$_) } @dec;
my $arg_zoneMemberId = join("",@zoneMemberId);
#->uri('http://ep.san.jaxws.dcbu.cisco.com/')
->proxy('https://'.$url.'/ZoneManagerWSService/ZoneManagerWS?wsdl')
->ns('http://ep.san.jaxws.dcbu.cisco.com/','namesp3');
my $VsanKey = SOAP::Data->name("vsanKey" => \SOAP::Data->value(
SOAP::Data->name("vsanID" => $arg_vsanId),
SOAP::Data->name("pWwn" => \SOAP::Data->value(SOAP::Data->name("value" => $arg_vsanwwn)))->type("Wwn")))->type("VsanKey");
my $Wwn = SOAP::Data->name("switchKey" => \SOAP::Data->value(
SOAP::Data->name("wwn" => \SOAP::Data->value(SOAP::Data->name("value"=>$arg_wwn)))->type("Wwn")))->type("WwnKey");
my $zName = SOAP::Data->name("zoneName"=>$arg_zoneName);
my $zMemberType = SOAP::Data->name("zoneMemberType")->value($arg_zoneMemberType);
my $zMemberFormat = SOAP::Data->name("zoneMemberFormat")->value($arg_zoneMemberFormat);
my $zMemberIvrFabricIndex = SOAP::Data->name('zoneMemberIvrFabricIndex')->value($arg_zoneMemberIvrFabricIndex);
my $zMemberIvrVsanIndex = SOAP::Data->type('int')->name("zoneMemberIvrVsanIndex")->value($arg_zoneMemberIvrVsanIndex);
my $zMemberId = SOAP::Data->name("zoneMemberId")->value($arg_zoneMemberId);
my $zMemberLunId = SOAP::Data->name("zoneMemberLunId")->value(arg_zoneMemberLunId);
my $header = SOAP::Header->name('token')->prefix('m')->value($token)->uri('http://ep.cisco.dcbu.cisco.com')->type('string');
my $result = $client->addZoneMemberToZone($header,$VsanKey,$Wwn,$zName,$zMemberType,$zMemberFormat,$zMemberIvrFabricIndex,$zMemberIvrVsanIndex,$zMemberId,$zMemberLunId);
unless ($result->fault) {
($token,$arg_vsanId,$arg_vsanwwn,$arg_wwn,$arg_zoneSetName) = @_;
#->uri('http://ep.san.jaxws.dcbu.cisco.com/')
->proxy('https://'.$url.'/ZoneManagerWSService/ZoneManagerWS?wsdl')
->ns('http://ep.san.jaxws.dcbu.cisco.com/','namesp4');
# Creating complex data type
my $VsanKey = SOAP::Data->name("vsanKey" => \SOAP::Data->value(
SOAP::Data->name("vsanID" => $arg_vsanId),
SOAP::Data->name("pWwn" => \SOAP::Data->value(SOAP::Data->name("value" => $arg_vsanwwn)))->type("Wwn")))->type("VsanKey");
my $Wwn = SOAP::Data->name("switchKey" => \SOAP::Data->value(
SOAP::Data->name("wwn" => \SOAP::Data->value(SOAP::Data->name("value"=>$arg_wwn)))->type("Wwn")))->type("WwnKey");
my $zSetName = SOAP::Data->name("zoneSetName"=>$arg_zoneSetName);
my $header = SOAP::Header->name('token')->prefix('m')->value($token)->uri('http://ep.cisco.dcbu.cisco.com')->type('string');
# Calling createZone method
my $result = $client->createZoneSet($header,$VsanKey,$Wwn,$zSetName);
unless ($result->fault) {
return $result->valueof('//index')."\n";
($token,$arg_vsanId,$arg_vsanwwn,$arg_wwn,$arg_index,$arg_zoneName,$arg_readOnly,$arg_broadcast,$arg_qos,$arg_qosPriority,$arg_zoneMemberDbId,$arg_memberType,$arg_zoneLastModtime,$arg_zoneMemberLunId,$arg_isIvr,$arg_zoneSetindex,$arg_zoneSetName,$active) = @_;
#->uri('http://ep.san.jaxws.dcbu.cisco.com/')
->proxy('https://'.$url.'/ZoneManagerWSService/ZoneManagerWS?wsdl')
->ns('http://ep.san.jaxws.dcbu.cisco.com/','namesp5');
# Creating complex data type
my $VsanKey = SOAP::Data->name("vsanKey" => \SOAP::Data->value(
SOAP::Data->name("vsanID" => $arg_vsanId),
SOAP::Data->name("pWwn" => \SOAP::Data->value(SOAP::Data->name("value" => $arg_vsanwwn)))->type("Wwn")))->type("VsanKey");
my $Wwn = SOAP::Data->name("switchKey" => \SOAP::Data->value(
SOAP::Data->name("wwn" => \SOAP::Data->value(SOAP::Data->name("value"=>$arg_wwn)))->type("Wwn")))->type("WwnKey");
my $zoneDO = SOAP::Data->name("zoneDo"=> \SOAP::Data->value(
SOAP::Data->name("index"=>$arg_index),
SOAP::Data->name("name"=>$arg_zoneName),
SOAP::Data->name("readonly"=>$arg_readonly),
SOAP::Data->name("qos"=>$arg_qos),
SOAP::Data->name("qosPriority"=>arg_qosPriority),
SOAP::Data->name("broadcast"=>$arg_broadcast),
SOAP::Data->name("active"=>$active),
SOAP::Data->name("zoneLastModtime"=>arg_zoneLastModtime),
SOAP::Data->name("zoneMemberDbId"=>$arg_zoneMemberDbId),
SOAP::Data->name("vsanId"=>$arg_vsanId),
SOAP::Data->name("isIvr"=>$arg_isIvr),
SOAP::Data->name("memberType"=>$arg_memberType),
SOAP::Data->name("lunId"=>$arg_zoneMemberLunId)))->type("zone");
my $zoneSetDO = SOAP::Data->name("zoneSetDo"=> \SOAP::Data->value(
SOAP::Data->name("index"=>$arg_zoneSetindex),
SOAP::Data->name("name"=>$arg_zoneSetName),
SOAP::Data->name("active"=>$active),
SOAP::Data->name("zoneLastModified"=>$arg_zoneLastModtime)))->type("ZoneSet");
my $header = SOAP::Header->name('token')->prefix('m')->value($token)->uri('http://ep.cisco.dcbu.cisco.com')->type('string');
# Calling addZonetoZoneSet method
my $result = $client->addZoneToZoneset($header,$VsanKey,$Wwn,$zoneDO,$zoneSetDO);
unless ($result->fault) {
($token,$arg_vsanId,$arg_vsanwwn,$arg_wwn,$arg_zoneSetName) = @_;
#->uri('http://ep.san.jaxws.dcbu.cisco.com/')
->proxy('https://'.$url.'/ZoneManagerWSService/ZoneManagerWS?wsdl')
->ns('http://ep.san.jaxws.dcbu.cisco.com/','namesp6');
# Creating complex data type
my $VsanKey = SOAP::Data->name("vsanKey" => \SOAP::Data->value(
SOAP::Data->name("vsanID" => $arg_vsanId),
SOAP::Data->name("pWwn" => \SOAP::Data->value(SOAP::Data->name("value" => $arg_vsanwwn)))->type("Wwn")))->type("VsanKey");
my $Wwn = SOAP::Data->name("switchKey" => \SOAP::Data->value(
SOAP::Data->name("wwn" => \SOAP::Data->value(SOAP::Data->name("value"=>$arg_wwn)))->type("Wwn")))->type("WwnKey");
my $zSetName = SOAP::Data->name("zoneSetName"=>$arg_zoneSetName);
my $header = SOAP::Header->name('token')->prefix('m')->value($token)->uri('http://ep.cisco.dcbu.cisco.com')->type('string');
# Calling activateZoneset method
my $result = $client->activateZoneset($header,$VsanKey,$Wwn,$zSetName);
unless ($result->fault) {
Example B-3 StatisticsClient.plx
# File: StatisticsClient.plx
# Description: Statistics Client
my $sortField = 'rxTxStr';
require 'statisticsModule.plx';
($url,$username,$password) = @ARGV;
my $token = getToken($url,$username,$password);
($rrdFile,$fid,$pmType) = getIslStatList($token,$fabricDbId,$switchDbId,$vsanDbId,$sortField,$sortType,$limit,$groupId,$isGroup,$networkType,$filterStr,$temp,$startIdx,$recordSize);
for (my $i=0;$i<1;$i++) {
getPmChartData($token,@$rrdFile[$i],@$pmType[$i],@$fid[$i],$interval). "\n";
Example B-4 StatisticsModule.plx
($url,$username,$password) = @_;
#->uri('http://ep.jaxws.dcbu.cisco.com/')
->proxy('https://'.$url.'/LogonWSService/LogonWS?wsdl')
-> ns('http://ep.jaxws.dcbu.cisco.com/','namesp1');
my $username = SOAP::Data->type('string')->name('username')->value($username);
my $password = SOAP::Data->type('string')->name('password')->value($password);
my $expiration = SOAP::Data->type('long')->name('expiration')->value(100000000);
# Calling requestToken method
my $result = $client->requestToken($username,$password,$expiration);
unless ($result->fault) {
my $token = $result->result();
($token,$arg_fabricDbId,$arg_switchDbId,$arg_vsanDbId,$arg_sortField,$arg_sortType,$arg_limit,$arg_groupId,$arg_isGroup,$arg_networkType,$arg_filterStr,$arg_interval,$arg_startIdx,$arg_recordSize) = @_;
my $DbFilter= SOAP::Data->name("arg0" => \SOAP::Data->value(
SOAP::Data->name("fabricDbId" => $arg_fabricDbId),
SOAP::Data->name("switchDbId" => $arg_switchDbId),
SOAP::Data->name("vsanDbId" => $arg_vsanDbId),
SOAP::Data->name("sortField" => $arg_sortField),
SOAP::Data->name("sortType" => $arg_sortType),
SOAP::Data->name("limit" => $arg_limit),
SOAP::Data->name("groupId" => $arg_groupId),
SOAP::Data->name("isGroup" => $arg_isGroup)->type("boolean"),
SOAP::Data->name("networkType" => $arg_networkType),
SOAP::Data->name("filterStr" => $arg_filterStr)))->type("DbFilter");
my $interval = SOAP::Data->type("string")->name("arg1")->value($arg_interval);
my $data_startIdx = SOAP::Data->name("arg2"=>$arg_startIdx);
my $data_recordSize = SOAP::Data->name("arg3"=>$arg_recordSize);
my $header = SOAP::Header->name('token')->prefix('m')->value($token)->uri('http://ep.cisco.dcbu.cisco.com')->type('string');
#my $header = SOAP::Header->name('token')->prefix('m')->value($token)->type('string');
#->uri('http://ep.san.jaxws.dcbu.cisco.com/')
->proxy('https://'.$url.'/StatisticsWSService/StatisticsWS?wsdl')
-> ns('http://ep.san.jaxws.dcbu.cisco.com/','namesp2');
# Calling getIslStatDataLength method
my $result = $client->getIslStatList($header,$DbFilter,$interval,$data_startIdx,$data_recordSize);
unless ($result->fault) {
print "\ngetIslStatList\n\n";
my @fabric = $result->valueof('//item/fabric');
my @title = $result->valueof('//item/title');
my @maxTxStr = $result->valueof('//item/maxTxStr');
my @maxRxStr = $result->valueof('//item/rxTxStr');
my @rxTx = $result->valueof('//item/rxTx');
print "---------------------------------------------------------\n";
print "Fabric -> ". $fabric[$i]. "\n";
print "Title -> ". $title[$i]. "\n";
print "maxTxStr -> ". $maxTxStr[$i]. "\n";
print "maxRxStr -> ". $maxRxStr[$i]. "\n";
print "rxTx -> ". $rxTx[$i]. "\n";
print "---------------------------------------------------------\n";
my @rrdFile = $result->valueof('//item/rrdFile');
my @fid = $result->valueof('//item/fid');
my @pmType = $result->valueof('//item/pmtype');
return (\@rrdFile,\@fid,\@pmType);
($token,$arg_rrd,$arg_pmType,$arg_fid,$arg_interval) = @_;
my $data_rrd = SOAP::Data->type("string")->name("arg0")->value($arg_rrd);
my $data_pmType = SOAP::Data->name("arg1")->value($arg_pmType);
my $data_fid = SOAP::Data->name("arg2"=>$arg_fid);
my $data_interval = SOAP::Data->name("arg3"=>$arg_interval);
my $header = SOAP::Header->name('token')->prefix('m')->value($token)->uri('http://ep.cisco.dcbu.cisco.com')->type('string');
#->uri('http://ep.san.jaxws.dcbu.cisco.com/')
->proxy('https://'.$url.'/StatisticsWSService/StatisticsWS?wsdl')
-> ns('http://ep.san.jaxws.dcbu.cisco.com/','namesp3');
# Calling getPmChartData method
my $result = $client->getPmChartData($header,$data_rrd,$data_pmType,$data_fid,$data_interval);
unless ($result->fault) {
print "\n\nGetPmChartData\n\n";
my @item = $result->valueof('//item/item');
for(my $i=2;$i<30;$i=$i+3) {
print "---------------------------------------------------------\n";
print "Rx -> ".$item[$i-2]."\n";
print "Tx -> ".$item[$i-1]."\n";
print "Time -> ".scalar localtime($item[$i]). "\n";
print "---------------------------------------------------------\n";