diff --git a/sql/database-create.sql b/sql/database-create.sql index dba5d1534f0d92072d899c38525ac3ef296ad611..008a6efca9849aa6d9cb90a9f7cd3bcf37f65b40 100644 --- a/sql/database-create.sql +++ b/sql/database-create.sql @@ -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, diff --git a/sql/database-fill.sql b/sql/database-fill.sql index f9911409237c3c5737682414fdc6b36863769076..aa44ff16dd93dbf73c9f74e8701582a2ef9d0128 100644 --- a/sql/database-fill.sql +++ b/sql/database-fill.sql @@ -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); diff --git a/sql/updates/4/227 b/sql/updates/4/227 new file mode 100644 index 0000000000000000000000000000000000000000..40fa27786cb1873833436dadbed2037f8ea2d422 --- /dev/null +++ b/sql/updates/4/227 @@ -0,0 +1,51 @@ +# +# 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; diff --git a/tbsetup/ns2ir/lanlink.tcl b/tbsetup/ns2ir/lanlink.tcl index 648a8ae5411724dacf5957ece7d1b16ac1807d18..491f616d8b7bfcb177668265260f62cf92cbe088 100644 --- a/tbsetup/ns2ir/lanlink.tcl +++ b/tbsetup/ns2ir/lanlink.tcl @@ -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] {