Commit a4821544 authored by Leigh B Stoller's avatar Leigh B Stoller

No longer rely on mysql ordering of nodes in a link; this was always a

bad thing to do, and has recently stopped working. Use an index
ordering slot instead.
parent e87ca891
......@@ -3948,6 +3948,7 @@ CREATE TABLE `virt_lans` (
`vname` varchar(32) NOT NULL default '',
`vnode` varchar(32) NOT NULL default '',
`vport` tinyint(3) NOT NULL default '0',
`vindex` int(11) NOT NULL default '-1',
`ip` varchar(15) NOT NULL default '',
`delay` float(10,2) default '0.00',
`bandwidth` int(10) unsigned default NULL,
......
......@@ -693,6 +693,7 @@ REPLACE INTO table_regex VALUES ('virt_agents','objecttype','int','redirect','de
REPLACE INTO table_regex VALUES ('virt_lans','pid','text','redirect','projects:pid',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','eid','text','redirect','experiments:eid',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','vname','text','redirect','virt_nodes:vname',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','vindex','int','redirect','default:int',0,4098,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','delay','float','redirect','default:float',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','bandwidth','int','redirect','default:int',0,2147483647,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','lossrate','float','function','_checklossrate',0,1,NULL);
......
#
# Add extenal references slots to nodes table, as for geni.
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBSlotExists("virt_lans", "vindex")) {
DBQueryFatal("alter table virt_lans add ".
"vindex int(11) NOT NULL default '-1' after vport");
}
DBQueryFatal("replace into table_regex VALUES ".
" ('virt_lans','vindex','int','redirect','default:int', ".
" 0,4098,NULL)");
my $query_result =
DBQueryFatal("select * from virt_lans order by exptidx,vname,vindex");
my $curexp = -1;
my $curlan = "";
my $curidx = 0;
while (my $rowref = $query_result->fetchrow_hashref()) {
my $exptidx = $rowref->{'exptidx'};
my $vname = $rowref->{'vname'};
my $vnode = $rowref->{'vnode'};
my $vport = $rowref->{'vport'};
my $vindex = $rowref->{'vindex'};
# Already done.
next
if ($vindex != -1);
if ($exptidx != $curexp || $vname ne $curlan) {
$curidx = 0;
}
DBQueryFatal("update virt_lans set vindex=$curidx ".
"where exptidx='$exptidx' and vname='$vname' and ".
" vnode='$vnode' and vport='$vport'");
$curidx++;
$curexp = $exptidx;
$curlan = $vname;
}
return 0;
}
1;
......@@ -779,6 +779,7 @@ Link instproc updatedb {DB} {
$self instvar implemented_by
$self instvar ofenabled
$self instvar ofcontroller
set vindex 0
$sim spitxml_data "virt_lan_lans" [list "vname" "failureaction"] [list $self $failureaction]
......@@ -925,6 +926,10 @@ Link instproc updatedb {DB} {
lappend values ""
}
lappend fields "vindex"
lappend values $vindex
set vindex [expr $vindex + 1]
$sim spitxml_data "virt_lans" $fields $values
}
}
......@@ -964,6 +969,7 @@ Lan instproc updatedb {DB} {
$self instvar fixed_iface
$self instvar ofenabled
$self instvar ofcontroller
set vindex 0
if {$modelnet_cores > 0 || $modelnet_edges > 0} {
perror "Lans are not allowed when using modelnet; just duplex links."
......@@ -1108,6 +1114,10 @@ Lan instproc updatedb {DB} {
lappend values ""
}
lappend fields "vindex"
lappend values $vindex
set vindex [expr $vindex + 1]
$sim spitxml_data "virt_lans" $fields $values
foreach setting_key [array names member_settings] {
......
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