Commit 0e278b7e authored by Weibin Sun's avatar Weibin Sun

getUsedOpenflowListenerPorts in snmpit stack modules and devices are changed...

getUsedOpenflowListenerPorts in snmpit stack modules and devices are changed to return the ports rather than accept a hash reference. Add the empty OF functions to snmpit_nortel.pm. Print the OF listener string on each involved device. Fix a bug that snmpit.in doesnot print Done when OF operations are finished. The lengths of OF usage lines are reduced to fit the 80-ch width window.
parent a3e55dbf
......@@ -128,18 +128,20 @@ VLAN Control:
-F Create all vlans in the given stack on the leader for
use in leader->{ALLVLANSONLEADER} (Internal use only)
--of-enable <name> <pid> <eid>
Enable Openflow on VLAN with the name <name> that is associated
with the given experiment
Enable Openflow on VLAN with the name <name> that is
associated with the given experiment
--of-disable <name> <pid> <eid>
Disable Openflow on VLAN with the name <name> that is associated
with the given experiment
Disable Openflow on VLAN with the name <name> that is
associated with the given experiment
--of-controller <name> <pid> <eid> tcp:ip:port
Set controller for Openflow-enabled VLAN with the name <name> that is associated
with the given experiment
Set controller for Openflow-enabled VLAN with the
name <name> that is associated with the given
experiment
--of-listener <name> <pid> <eid>
Enable listener for Openflow-enabled VLAN with the name <name> that is associated
with the given experiment, snmpit will print out the listener connection
string.
Enable listener for Openflow-enabled VLAN with the
name <name> that is associated with the given
experiment, snmpit will print out the listener
connection string
Port Control:
-s List all ports, and show configuration information
......@@ -188,7 +190,8 @@ if ($opt{q}) {
$quiet = 1;
if ($opt{m} || $opt{o} || $opt{t} || $opt{r} || $opt{X} || $opt{T} ||
$opt{E} || $opt{U} || $opt{u} || $opt{d} || $opt{p} || $opt{e} ||
$opt{'of-enable'} || $opt{'of-disable'} || $opt{'of-controller'} || $opt{'of-listener'}) {
$opt{'of-enable'} || $opt{'of-disable'} || $opt{'of-controller'} ||
$opt{'of-listener'}) {
my $nulldev;
open($nulldev, ">>/dev/null");
select $nulldev; # supresses print foo(); without explicit fileglob
......@@ -840,7 +843,8 @@ COMMAND: foreach my $command (@commands) {
SWITCH: for ($stack_type) {
(/cisco/ || /catalyst/) && do {
require snmpit_cisco_stack;
$stack = new snmpit_cisco_stack($stack_id,$debug,$single_domain, @{$stacks{$stack_id}});
$stack = new snmpit_cisco_stack($stack_id,$debug,$single_domain,
@{$stacks{$stack_id}});
last;
}; # /cisco/
/intel/ && do {
......@@ -1001,7 +1005,6 @@ COMMAND: foreach my $command (@commands) {
last;
}; # /ofcontroller/ && do
(/oflistener/) && do {
#$exitval += doSetOpenflowListener(\@stacks,$vlans[0],$ofconnstr);
$exitval += doEnableOpenflowListener(\@stacks,$vlans[0]);
last;
}; # /oflistener/ && do
......@@ -2540,13 +2543,11 @@ sub doOpenflowEnable($$) {
print "Enabling Openflow on VLAN $vlan ...\n"
if (!$quiet);
foreach my $stack (@$stacks) {
if (!$stack->enableOpenflow($vlan)) {
$errors++;
}
$errors += $stack->enableOpenflow($vlan);
}
if (!$errors) {
print 'Done! \n' if (!$quiet);
print "Done! \n" if (!$quiet);
}
return $errors;
......@@ -2567,9 +2568,7 @@ sub doOpenflowDisable($$) {
print "Disabling Openflow on VLAN $vlan ...\n"
if (!$quiet);
foreach my $stack (@$stacks) {
if (!$stack->disableOpenflow($vlan)) {
$errors++;
}
$errors += $stack->disableOpenflow($vlan);
}
#
......@@ -2577,7 +2576,7 @@ sub doOpenflowDisable($$) {
#
if (!$errors) {
print 'Done! \n' if (!$quiet);
print "Done! \n" if (!$quiet);
}
return $errors;
......@@ -2599,13 +2598,11 @@ sub doSetOpenflowController($$$) {
print "Set controller for VLAN $vlan ...\n"
if (!$quiet);
foreach my $stack (@$stacks) {
if (!$stack->setOpenflowController($vlan, $controller)) {
$errors++;
}
$errors += $stack->setOpenflowController($vlan, $controller);
}
if (!$errors) {
print 'Done! \n' if (!$quiet);
print "Done! \n" if (!$quiet);
}
return $errors;
......@@ -2627,13 +2624,11 @@ sub doSetOpenflowListener($$$) {
print "Set listener for VLAN $vlan ...\n"
if (!$quiet);
foreach my $stack (@$stacks) {
if (!$stack->setOpenflowListener($vlan, $listener)) {
$errors++;
}
$errors += $stack->setOpenflowListener($vlan, $listener);
}
if (!$errors) {
print 'Done! \n' if (!$quiet);
print "Done! \n" if (!$quiet);
}
return $errors;
......@@ -2661,7 +2656,8 @@ sub doEnableOpenflowListener($$) {
#
oflock();
foreach my $stack (@$stacks) {
$stack->getUsedOpenflowListenerPorts(\%usedports);
my %tmports = $stack->getUsedOpenflowListenerPorts($vlan);
@usedports{ keys %tmports } = values %tmports;
}
# get the available port
......
......@@ -2328,8 +2328,13 @@ sub setOpenflowListener($$$) {
#
# Get used listener ports
#
sub getUsedOpenflowListenerPorts($$) {
sub getUsedOpenflowListenerPorts($) {
my $self = shift;
my %ports = ();
warn "ERROR: Cisco swith doesn't support Openflow now\n";
return %ports;
}
#
......
......@@ -1223,15 +1223,37 @@ sub setOpenflowListener($$$) {
#
# Get used Openflow listener ports
#
# getUsedOpenflowListenerPorts(self, vlan_id)
#
sub getUsedOpenflowListenerPorts($$) {
my $self = shift;
my $ports = shift;
my $vlan_id = shift;
my %ports = ();
foreach my $devicename (keys %{$self->{DEVICES}})
{
my $device = $self->{DEVICES}{$devicename};
$device->getUsedOpenflowListenerPorts($ports);
my $vlan_number = $device->findVlan($vlan_id, 2);
if (!$vlan_number) {
#
# Not sure if this is an error or not.
# It might be possible that not all devices in a stack have the given VLAN.
#
print "$device has no VLAN $vlan_id, ignore it. \n" if $self->{DEBUG};
} else {
if ($device->isOpenflowSupported()) {
my %tmports = $device->getUsedOpenflowListenerPorts();
@ports{ keys %tmports } = values %tmports;
} else {
#
# YES this be an error because the VLAN is on it.
#
warn "ERROR: Openflow is not supported on $devicename \n";
}
}
}
return %ports;
}
# End with true
......
......@@ -1498,8 +1498,13 @@ sub setOpenflowListener($$$) {
#
# Get used listener ports
#
sub getUsedOpenflowListenerPorts($$) {
sub getUsedOpenflowListenerPorts($) {
my $self = shift;
my %ports = ();
warn "ERROR: Foundry swith doesn't support Openflow now\n";
return %ports;
}
#
......
......@@ -57,7 +57,7 @@ my $ofEnableOID = $ofOID.'.1.1.2';
my $ofControllerOID = $ofOID.'.1.1.3';
my $ofListenerOID = $ofOID.'.1.1.4';
my $ofSupportOID = $ofOID.'.2.1.0';
my $ofListenerVarNameMarker = '11.2.14.11.5.1.7.1.35.1.1.4';
my $ofListenerVarNameMarker = '35.1.1.4';
#
# Ports can be passed around in three formats:
......@@ -1853,9 +1853,9 @@ sub setOpenflowListener($$$) {
#
# Get used listener ports
#
sub getUsedOpenflowListenerPorts($$) {
sub getUsedOpenflowListenerPorts($) {
my $self = shift;
my $ports = shift;
my %ports = ();
my $listener = [$ofListenerOID,0];
......@@ -1869,7 +1869,7 @@ sub getUsedOpenflowListenerPorts($$) {
$self->debug("listener: $varname $vlan $connstr \n");
if ($varname =~ /$ofListenerVarNameMarker/) {
my ($proto, $port) = split(":", $connstr);
$ports->{$port} = 1;
$ports{$port} = 1;
#
# the SNMP session with MIB gives varname with strings not numbers, but
......@@ -1883,6 +1883,8 @@ sub getUsedOpenflowListenerPorts($$) {
$self->{SESS}->getnext($listener);
}
} while ($varname =~ /$ofListenerVarNameMarker/);
return %ports;
}
......
......@@ -1288,8 +1288,13 @@ sub setOpenflowListener($$$) {
#
# Get used listener ports
#
sub getUsedOpenflowListenerPorts($$) {
sub getUsedOpenflowListenerPorts($) {
my $self = shift;
my %ports = ();
warn "ERROR: Intel swith doesn't support Openflow now\n";
return %ports;
}
#
......
......@@ -405,15 +405,37 @@ sub setOpenflowListener($$$) {
#
# Get used Openflow listener ports
#
# getUsedOpenflowListenerPorts(self, vlan_id)
#
sub getUsedOpenflowListenerPorts($$) {
my $self = shift;
my $ports = shift;
my $vlan_id = shift;
my %ports = ();
foreach my $devicename (keys %{$self->{DEVICES}})
{
my $device = $self->{DEVICES}{$devicename};
$device->getUsedOpenflowListenerPorts($ports);
my $vlan_number = $device->findVlan($vlan_id, 2);
if (!$vlan_number) {
#
# Not sure if this is an error or not.
# It might be possible that not all devices in a stack have the given VLAN.
#
print "$device has no VLAN $vlan_id, ignore it. \n" if $self->{DEBUG};
} else {
if ($device->isOpenflowSupported()) {
my %tmports = $device->getUsedOpenflowListenerPorts();
@ports{ keys %tmports } = values %tmports;
} else {
#
# YES this be an error because the VLAN is on it.
#
warn "ERROR: Openflow is not supported on $devicename \n";
}
}
}
return %ports;
}
# End with true
......
......@@ -1532,5 +1532,90 @@ sub unlock($) {
$lock_held = 0;
}
#
# Enable Openflow
#
sub enableOpenflow($$) {
my $self = shift;
my $vlan = shift;
my $RetVal;
#
# Nortel switch doesn't support Openflow yet.
#
warn "ERROR: Nortel swith doesn't support Openflow now";
return 0;
}
#
# Disable Openflow
#
sub disableOpenflow($$) {
my $self = shift;
my $vlan = shift;
my $RetVal;
#
# Nortel switch doesn't support Openflow yet.
#
warn "ERROR: Nortel swith doesn't support Openflow now";
return 0;
}
#
# Set controller
#
sub setOpenflowController($$$) {
my $self = shift;
my $vlan = shift;
my $controller = shift;
my $RetVal;
#
# Nortel switch doesn't support Openflow yet.
#
warn "ERROR: Nortel swith doesn't support Openflow now";
return 0;
}
#
# Set listener
#
sub setOpenflowListener($$$) {
my $self = shift;
my $vlan = shift;
my $listener = shift;
my $RetVal;
#
# Nortel switch doesn't support Openflow yet.
#
warn "ERROR: Nortel swith doesn't support Openflow now";
return 0;
}
#
# Get used listener ports
#
sub getUsedOpenflowListenerPorts($) {
my $self = shift;
my %ports = ();
warn "ERROR: Nortel swith doesn't support Openflow now\n";
return %ports;
}
#
# Check if Openflow is supported on this switch
#
sub isOpenflowSupported($) {
#
# Nortel switch doesn't support Openflow yet.
#
return 0;
}
# End with true
1;
......@@ -1305,7 +1305,10 @@ sub setOpenflowListener($$$) {
my $ok = $device->setOpenflowListener($vlan_number, $listener);
if (!$ok) { $errors++; }
else {print "Done! \n" if $self->{DEBUG};}
else {
print "Done! \n" if $self->{DEBUG};
print " Openflow listener on $devicename for VLAN $vlan_id is $listener \n";
}
} else {
#
# TODO: Should this be an error?
......@@ -1322,15 +1325,37 @@ sub setOpenflowListener($$$) {
#
# Get used Openflow listener ports
#
# getUsedOpenflowListenerPorts(self, vlan_id)
#
sub getUsedOpenflowListenerPorts($$) {
my $self = shift;
my $ports = shift;
my $vlan_id = shift;
my %ports = ();
foreach my $devicename (keys %{$self->{DEVICES}})
{
my $device = $self->{DEVICES}{$devicename};
$device->getUsedOpenflowListenerPorts($ports);
my $vlan_number = $device->findVlan($vlan_id, 2);
if (!$vlan_number) {
#
# Not sure if this is an error or not.
# It might be possible that not all devices in a stack have the given VLAN.
#
print "$device has no VLAN $vlan_id, ignore it. \n" if $self->{DEBUG};
} else {
if ($device->isOpenflowSupported()) {
my %tmports = $device->getUsedOpenflowListenerPorts();
@ports{ keys %tmports } = values %tmports;
} else {
#
# YES this be an error because the VLAN is on it.
#
warn "ERROR: Openflow is not supported on $devicename \n";
}
}
}
return %ports;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment