Commit 43a804e9 authored by Leigh Stoller's avatar Leigh Stoller

Add slots to virt_lans to rationalize the relationship between

virt_lans and virt_nodes. The intent is to migrate away from
the convention we use in virt_nodes:ips and virt_lans:member
to a more acceptable representation (one that does not rely
on textual conventions like space separated lists of colon
seperated entities. Instead:

	virt_nodes
		vname:	nodeA
        virt_lans
		vname:  link0
		vport:  0
		ip:     1.1.1.2

		vname:  link1
		vport:  1
		ip:     1.1.2.2

	alter table virt_lans add vnode varchar(32) NOT NULL default '' \
		after vname;
	alter table virt_lans add vport tinyint(3) NOT NULL default '0' \
		after vnode;
        alter table virt_lans add ip varchar(15) NOT NULL default '' \
		after vport;

Then run this script to update these new fields from the
existing ips,member slots. This must be run after installing
the parser changes, or you can just run it again.

	./ipmember.pl

This is a transitional phase; the old slots will be left in place
until they are no longer used, at which time we will also add a
unique key to the table (pid,eid,vname,vnode,vport). assign_wrapper
will be the hardest to change, but other scripts should be easy.

Whats vport about? Rather then rely on IP addresses to form a
unique key, we use vport (a small integer) so that we can delay the
IP assignment until later (after initial DB insertion).
parent 6d82dd53
......@@ -1634,6 +1634,9 @@ CREATE TABLE virt_lans (
pid varchar(12) NOT NULL default '',
eid varchar(32) NOT NULL default '',
vname varchar(32) NOT NULL default '',
vnode varchar(32) NOT NULL default '',
vport tinyint(3) NOT NULL default '0',
ip varchar(15) NOT NULL default '',
delay float(10,2) default '0.00',
bandwidth int(10) unsigned default NULL,
est_bandwidth int(10) unsigned default NULL,
......
......@@ -507,6 +507,9 @@ 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','vnode','text','redirect','virt_nodes:vname',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','vport','int','redirect','default:tinyint',0,99,NULL);
REPLACE INTO table_regex VALUES ('virt_lans','ip','text','regex','^(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})$',0,15,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','redirect','default:float',0,1,NULL);
......
......@@ -1557,3 +1557,43 @@ last_net_act,last_cpu_act,last_ext_act);
way to figure out which new node is which.
alter table new_nodes add column identifier varchar(255);
1.249: Add slots to virt_lans to rationalize the relationship between
virt_lans and virt_nodes. The intent is to migrate away from
the convention we use in virt_nodes:ips and virt_lans:member
to a more acceptable representation (one that does not rely
on textual conventions like space separated lists of colon
seperate entities. Instead:
virt_nodes
vname: nodeA
virt_lans
vname: link0
vport: 0
ip: 1.1.1.2
vname: link1
vport: 1
ip: 1.1.2.2
alter table virt_lans add vnode varchar(32) NOT NULL default '' \
after vname;
alter table virt_lans add vport tinyint(3) NOT NULL default '0' \
after vnode;
alter table virt_lans add ip varchar(15) NOT NULL default '' \
after vport;
Then run this script to update these new fields from the
existing ips,member slots. This must be run after installing
the parser changes, or you can just run it again.
./ipmember.pl
This is a transitional phase; the old slots will be left in place
until they are no longer used, at which time we will also add a
unique key to the table (pid,eid,vname,vnode,vport). assign_wrapper
will be the hardest to change, but other scripts should be easy.
Whats vport about? Rather then rely on IP addresses to form a
unique key, we use vport (a small integer) so that we can delay the
IP assignment until later (after initial DB insertion).
#!/usr/bin/perl -w
use English;
use Errno;
use lib "/usr/testbed/lib";
use libdb;
use libtestbed;
my $allexp_result =
DBQueryFatal("select pid,eid from experiments");
while (my ($pid,$eid) = $allexp_result->fetchrow_array) {
my %ips = ();
my $query_result =
DBQueryFatal("select vname,ips from virt_nodes ".
"where pid='$pid' and eid='$eid'");
while (my ($vnode,$ips) = $query_result->fetchrow_array) {
# Take apart the IP list.
foreach $ipinfo (split(" ", $ips)) {
my ($port,$ip) = split(":",$ipinfo);
$ips{"$vnode:$port"} = $ip;
}
}
$query_result =
DBQueryFatal("select vname,member from virt_lans ".
"where pid='$pid' and eid='$eid'");
while (my ($vname,$member) = $query_result->fetchrow_array) {
my ($vnode,$port) = split(":", $member);
my $ip = $ips{$member};
DBQueryFatal("update virt_lans set ".
"vnode='$vnode',ip='$ip',vport='$port' ".
"where pid='$pid' and eid='$eid' and ".
"vname='$vname' and member='$member'");
}
}
......@@ -553,10 +553,20 @@ Link instproc updatedb {DB} {
set wait_ [$linkqueue set wait_]
set setbit_ [$linkqueue set setbit_]
set droptail_ [$linkqueue set drop-tail_]
#
# Note; we are going to deprecate virt_lans:member and virt_nodes:ips
# Instead, store vnode,vport,ip in the virt_lans table. To get list
# of IPs for a node, join virt_nodes with virt_lans. port number is
# no longer required, but we maintain it to provide a unique key that
# does not depend on IP address.
#
set port [lindex $nodeport 1]
set ip [$node ip $port]
set nodeportraw [join $nodeport ":"]
set fields [list "vname" "member" "mask" "delay" "rdelay" "bandwidth" "rbandwidth" "lossrate" "rlossrate" "cost" "widearea" "emulated" "uselinkdelay" "nobwshaping" "usevethiface" "q_limit" "q_maxthresh" "q_minthresh" "q_weight" "q_linterm" "q_qinbytes" "q_bytes" "q_meanpsize" "q_wait" "q_setbit" "q_droptail" "q_red" "q_gentle" "trivial_ok"]
set fields [list "vname" "member" "mask" "delay" "rdelay" "bandwidth" "rbandwidth" "lossrate" "rlossrate" "cost" "widearea" "emulated" "uselinkdelay" "nobwshaping" "usevethiface" "q_limit" "q_maxthresh" "q_minthresh" "q_weight" "q_linterm" "q_qinbytes" "q_bytes" "q_meanpsize" "q_wait" "q_setbit" "q_droptail" "q_red" "q_gentle" "trivial_ok" "vnode" "vport" "ip"]
# Treat estimated bandwidths differently - leave them out of the lists
# unless the user gave a value - this way, they get the defaults if not
......@@ -569,7 +579,7 @@ Link instproc updatedb {DB} {
lappend fields "rest_bandwidth"
}
set values [list $self $nodeportraw $netmask $delay($nodeport) $rdelay($nodeport) $bandwidth($nodeport) $rbandwidth($nodeport) $loss($nodeport) $rloss($nodeport) $cost($nodeport) $widearea $emulated $uselinkdelay $nobwshaping $useveth $limit_ $maxthresh_ $thresh_ $q_weight_ $linterm_ ${queue-in-bytes_} $bytes_ $mean_pktsize_ $wait_ $setbit_ $droptail_ $red_ $gentle_ $trivial_ok]
set values [list $self $nodeportraw $netmask $delay($nodeport) $rdelay($nodeport) $bandwidth($nodeport) $rbandwidth($nodeport) $loss($nodeport) $rloss($nodeport) $cost($nodeport) $widearea $emulated $uselinkdelay $nobwshaping $useveth $limit_ $maxthresh_ $thresh_ $q_weight_ $linterm_ ${queue-in-bytes_} $bytes_ $mean_pktsize_ $wait_ $setbit_ $droptail_ $red_ $gentle_ $trivial_ok $node $port $ip]
if { [info exists ebandwidth($nodeport)] } {
lappend values $ebandwidth($nodeport)
......@@ -658,6 +668,16 @@ Lan instproc updatedb {DB} {
set setbit_ [$linkqueue set setbit_]
set droptail_ [$linkqueue set drop-tail_]
#
# Note; we are going to deprecate virt_lans:member and virt_nodes:ips
# Instead, store vnode,vport,ip in the virt_lans table. To get list
# of IPs for a node, join virt_nodes with virt_lans. port number is
# no longer required, but we maintain it to provide a unique key that
# does not depend on IP address.
#
set port [lindex $nodeport 1]
set ip [$node ip $port]
set nodeportraw [join $nodeport ":"]
set is_accesspoint 0
......@@ -665,7 +685,7 @@ Lan instproc updatedb {DB} {
set is_accesspoint 1
}
set fields [list "vname" "member" "mask" "delay" "rdelay" "bandwidth" "rbandwidth" "lossrate" "rlossrate" "cost" "widearea" "emulated" "uselinkdelay" "nobwshaping" "usevethiface" "q_limit" "q_maxthresh" "q_minthresh" "q_weight" "q_linterm" "q_qinbytes" "q_bytes" "q_meanpsize" "q_wait" "q_setbit" "q_droptail" "q_red" "q_gentle" "trivial_ok" "protocol" "is_accesspoint"]
set fields [list "vname" "member" "mask" "delay" "rdelay" "bandwidth" "rbandwidth" "lossrate" "rlossrate" "cost" "widearea" "emulated" "uselinkdelay" "nobwshaping" "usevethiface" "q_limit" "q_maxthresh" "q_minthresh" "q_weight" "q_linterm" "q_qinbytes" "q_bytes" "q_meanpsize" "q_wait" "q_setbit" "q_droptail" "q_red" "q_gentle" "trivial_ok" "protocol" "is_accesspoint" "vnode" "vport" "ip"]
# Treat estimated bandwidths differently - leave them out of the lists
# unless the user gave a value - this way, they get the defaults if not
......@@ -678,7 +698,7 @@ Lan instproc updatedb {DB} {
lappend fields "rest_bandwidth"
}
set values [list $self $nodeportraw $netmask $delay($nodeport) $rdelay($nodeport) $bandwidth($nodeport) $rbandwidth($nodeport) $loss($nodeport) $rloss($nodeport) $cost($nodeport) $widearea $emulated $uselinkdelay $nobwshaping $useveth $limit_ $maxthresh_ $thresh_ $q_weight_ $linterm_ ${queue-in-bytes_} $bytes_ $mean_pktsize_ $wait_ $setbit_ $droptail_ $red_ $gentle_ $trivial_ok $protocol $is_accesspoint]
set values [list $self $nodeportraw $netmask $delay($nodeport) $rdelay($nodeport) $bandwidth($nodeport) $rbandwidth($nodeport) $loss($nodeport) $rloss($nodeport) $cost($nodeport) $widearea $emulated $uselinkdelay $nobwshaping $useveth $limit_ $maxthresh_ $thresh_ $q_weight_ $linterm_ ${queue-in-bytes_} $bytes_ $mean_pktsize_ $wait_ $setbit_ $droptail_ $red_ $gentle_ $trivial_ok $protocol $is_accesspoint $node $port $ip]
if { [info exists ebandwidth($nodeport)] } {
lappend values $ebandwidth($nodeport)
......
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