Commit d21d0505 authored by Weibin Sun's avatar Weibin Sun
Browse files

Openflow code

parent d883d8c5
......@@ -2412,3 +2412,98 @@ sub doTrunkDisable($$) {
if (!$errors);
return $errors;
}
#
# doOpenflowEnable(stacks, vlan)
# Enable Openflow on a VLAN
# Procurve stack only
#
sub doOpenflowEnable($$) {
my $stacks = shift;
my $vlan = shift;
#
# Sanity checking
#
if (@$stacks != 1) {
die "Enabling Openflow can process only one stack now\n" .
"Stacks are " . join(",",@$stacks) . "\n";
}
my $stack = $$stacks[0];
print "Enabling Openflow on VLAN $vlan ...\n"
if(!$quiet);
#
# TODO: check if Openflow has been enabled, now in HP stack code
#
if (!$stack->enableOpenflow($vlan)) {
return 1;
}
return 0;
}
#
# doOpenflowDisable(stack, vlan)
# Disable Openflow on a VLAN
# Procurve stack only
#
sub doOpenflowDisable($$) {
my $stacks = shift;
my $vlan = shift;
#
# Sanity checking
#
if (@$stacks != 1) {
die "Disabling Openflow can process only one stack now\n" .
"Stacks are " . join(",",@$stacks) . "\n";
}
my $stack = $$stacks[0];
print "Disabling Openflow on VLAN $vlan ...\n"
if(!$quiet);
#
# TODO: check if Openflow is enabled, now in HP stack code.
#
if (!$stack->disableOpenflow($vlan)) {
return 1;
}
#
# TODO:clear controllers/listeners here. Now in HP stack code.
#
return 0;
}
#
# doSetController(stack, vlan, controller)
# Set controller for an Openflow-enabled VLAN
# Procurve stack only
#
sub doSetController($$$) {
my $stacks = shift;
my $vlan - shift;
my $controller = shift;
#
# Sanity checking
#
if (@$stacks != 1) {
die "Set controller on a VLAN can process only one stack now\n" .
"Stacks are " . join(",",@$stacks) . "\n";
}
my $stack = $$stacks[0];
print "Set controller for VLAN $vlan ...\n"
if(!$quiet);
#
# TODO: Check if Openflow is enabled. But in fact it doesn't matter.
#
if (!$stack->setController($vlan, $controller)) {
return 1;
}
return 0;
}
......@@ -48,6 +48,14 @@ my $egressOID = "dot1qVlanStaticEgressPorts";
my $aftOID = "dot1qPortAcceptableFrameTypes";
my $createOID = "dot1qVlanStaticRowStatus";
#
# Openflow OIDs, only number format now.
#
my $ofOID = 'iso.org.dod.internet.private.enterprises.11.2.14.11.5.1.7.1.35';
my $ofEnableOID = $ofOID.'.1.1.2';
my $ofControllerOID = $ofOID.'.1.1.3';
my $ofListenerOID = $ofOID.'.1.1.4';
#
# Ports can be passed around in three formats:
# ifindex: positive integer corresponding to the interface index (eg. 42)
......@@ -1773,5 +1781,72 @@ sub unlock($) {
$lock_held = 0;
}
#
# Enable Openflow
#
sub enableOpenflow($$) {
my $self = shift;
my $vlan = shift;
my $RetVal;
$RetVal = $self->set([$ofEnableOID, $vlan, 1, "INTEGER"]);
if (!defined($RetVal)) {
warn "ERROR: Unable to enable Openflow on VLAN $vlan\n";
return 0;
}
return 1;
}
#
# Disable Openflow
#
sub disableOpenflow($$) {
my $self = shift;
my $vlan = shift;
my $RetVal;
$RetVal = $self->set([$ofEnableOID, $vlan, 2, "INTEGER"]);
if (!defined($RetVal)) {
warn "ERROR: Unable to disable Openflow on VLAN $vlan\n";
return 0;
}
return 1;
}
#
# Set controller
#
sub setController($$$) {
my $self = shift;
my $vlan = shift;
my $controller = shift;
my $RetVal;
$RetVal = $self->set([$ofControllerOID, $vlan, $controller, "OCTETSTR"]);
if (!defined($RetVal)) {
warn "ERROR: Unable to set controller on VLAN $vlan\n";
return 0;
}
return 1;
}
#
# Set listener
#
sub setListener($$$) {
my $self = shift;
my $vlan = shift;
my $listener = shift;
my $RetVal;
$RetVal = $self->set([$ofListenerOID, $vlan, $listener, "OCTETSTR"]);
if (!defined($RetVal)) {
warn "ERROR: Unable to set listener on VLAN $vlan\n";
return 0;
}
return 1;
}
# End with true
1;
......@@ -1149,6 +1149,80 @@ sub reapCall($$) {
return snmpit_jitdev::reapCall($proc);
}
sub enableOpenflow($$) {
my $self = shift;
my $vlan = shift;
my $dev;
#
# TODO: check if this is Procurve stack
# if ($self->{STACKID} neq "Procurve") {
#warn "ERROR: Openflow is supported on Procurve stack only.\n";
#return 0;
# }
# TODO: get Procurve3 device
# $dev = $self->{DEVICES}{"procurve3"};
#
return $dev->enableOpenflow($vlan);
}
sub disableOpenflow($$) {
my $self = shift;
my $vlan = shift;
my $dev;
#
# TODO: check if this is Procurve stack
# if ($self->{STACKID} neq "Procurve") {
#warn "ERROR: Openflow is supported on Procurve stack only.\n";
#return 0;
# }
# TODO: get Procurve3 device
# $dev = $self->{DEVICES}{"procurve3"};
#
return $dev->disableOpenflow($vlan);
}
sub setController($$$) {
my $self = shift;
my $vlan = shift;
my $controller = shift;
my $dev;
#
# TODO: check if this is Procurve stack
# if ($self->{STACKID} neq "Procurve") {
#warn "ERROR: Openflow is supported on Procurve stack only.\n";
#return 0;
# }
# TODO: get Procurve3 device
# $dev = $self->{DEVICES}{"procurve3"};
#
return $dev->setController($vlan, $controller);
}
sub setListener($$$) {
my $self = shift;
my $vlan = shift;
my $listener = shift;
my $dev;
#
# TODO: check if this is Procurve stack
# if ($self->{STACKID} neq "Procurve") {
#warn "ERROR: Openflow is supported on Procurve stack only.\n";
#return 0;
# }
# TODO: get Procurve3 device
# $dev = $self->{DEVICES}{"procurve3"};
#
return $dev->setListener($vlan, $listener);
}
package snmpit_jitdev;
use Dumpvalue;
......
Supports Markdown
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