Commit 61183a40 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Be sure to disable openflow on vlans during teardown, since

there is no way to delete the controller/listener stuff.
parent 5dcc4cc4
......@@ -1966,7 +1966,7 @@ sub doVlansFromTables($$@) {
#
# A much more right place for the openflow settings is CreateOneVlan,
# however, it is called by sync vlan function and others, which don't destroy
# the existing vlan_arrtibutes rows.
# the existing lan_attributes rows.
#
# TODO: Move this part to CreateOneVlan and Make sure the existed
# vlan_attributes rows are deleted
......@@ -1974,19 +1974,18 @@ sub doVlansFromTables($$@) {
my $ofenabled;
$vlan->GetAttribute("ofenabled", \$ofenabled);
if (defined($ofenabled) && $ofenabled == 1) {
$errors += doOpenflowEnable($stacks, $vlanid);
my $ofcontroller;
$vlan->GetAttribute("ofcontroller", \$ofcontroller);
if (defined($ofcontroller) && $ofcontroller ne "") {
$errors += doSetOpenflowController($stacks, $vlanid, $ofcontroller);
$errors += doSetOpenflowController($stacks, $vlanid,
$ofcontroller);
}
$errors += doEnableOpenflowListener($stacks, $vlanid);
$errors += doOpenflowEnable($stacks, $vlanid);
# doEnableOpenflowListener updates the lan_arrtibutes table, so vlan
# should refresh itself. But here vlan will not be used any more, so
# maybe we can comment this refresh.
# doEnableOpenflowListener updates the lan_arrtibutes table,
# so vlan should refresh itself. But here vlan will not be
# used any more, so maybe we can comment this refresh.
$vlan->Refresh();
}
......@@ -2036,8 +2035,8 @@ sub doVlansFromTables($$@) {
# Set openflow
#
# A much more right place for the openflow settings is CreateOneVlan,
# however, it is called by sync vlan function and others, which don't destroy
# the existing vlan_arrtibutes rows.
# however, it is called by sync vlan function and others, which\
# don't destroy the existing lan_attributes rows.
#
# TODO: Move this part to CreateOneVlan and Make sure the existed
# vlan_attributes rows are deleted
......@@ -2045,19 +2044,17 @@ sub doVlansFromTables($$@) {
my $ofenabled;
$vlan->GetAttribute("ofenabled", \$ofenabled);
if (defined($ofenabled) && $ofenabled == 1) {
$errors += doOpenflowEnable($stacks, $vlanid);
my $ofcontroller;
$vlan->GetAttribute("ofcontroller", \$ofcontroller);
if (defined($ofcontroller) && $ofcontroller ne "") {
$errors += doSetOpenflowController($stacks, $vlanid, $ofcontroller);
}
$errors += doEnableOpenflowListener($stacks, $vlanid);
$errors += doOpenflowEnable($stacks, $vlanid);
# doEnableOpenflowListener updates the lan_arrtibutes table, so vlan
# should refresh itself. But here vlan will not be used any more, so
# maybe we can comment this refresh.
# doEnableOpenflowListener updates the lan_attributes table, so
# vlan should refresh itself. But here vlan will not be
# used any more, so maybe we can comment this refresh.
$vlan->Refresh();
}
}
......@@ -2218,6 +2215,19 @@ sub doReset($@) {
# In case of error, do not clear the DB state.
my %notdeleted = ();
# Get a list of openflow enabled vlans we have to undo.
my %ofenabled = ();
foreach my $vlan_id (@vlans) {
my $vlan = VLan->Lookup($vlan_id);
my $flag;
$vlan->GetAttribute("ofenabled", \$flag);
if (defined($flag) && $flag == 1) {
$ofenabled{"$vlan_id"} = 1;
}
}
$debug = 1;
#
......@@ -2263,6 +2273,15 @@ sub doReset($@) {
# $stack->FlipDebug(1);
my @existant_vlans = $stack->existantVlans(@vlans);
#
# Disable openflow if needed.
#
foreach my $vlan_id (@existant_vlans) {
if (exists($ofenabled{"$vlan_id"})) {
$errors += doOpenflowDisable($stacks, $vlan_id);
}
}
if (!$stack->removeVlan(@existant_vlans)) {
#
# Find out what still exists so that we keep the DB state.
......@@ -3927,6 +3946,7 @@ sub doOpenflowDisable($$) {
print "Disabling Openflow on VLAN $vlan ...\n"
if (!$quiet);
foreach my $stack (@$stacks) {
$stack->FlipDebug(1);
$errors += $stack->disableOpenflow($vlan);
}
......
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