Commit 425b4e47 authored by Shashi Guruprasad's avatar Shashi Guruprasad

Minimal NSE related changes on the mainbed so that I can work

in the dev tree. I'm tired of problems on the mini that wastes
my time.

Changes include 2 new tmcd commands: tmcc routelist returns
the routes for all the vnodes hosted on a pnode. tmcc role
returns the role of a reserved node, like 'virthost' or
'simhost.  tmcc ifconfig now reports an RTABID field which
is calculated in assign wrapper. All the new changes
in assign wrapper will be checked in after I finish testing.

All the DB changes are in: simnode_capacity in node_types, rtabid in
interfaces and veth_interfaces. New NSE event_objtype and NSEEVENT
event_eventtype. Changed the erole field in the reserved table
to have 'simhost' instead of 'simnode'. Changed the correspoding
libdb subroutines.
parent 9162ab78
......@@ -118,7 +118,7 @@ use Exporter;
TBDB_JAILIPBASE TBDB_JAILIPMASK
TBDB_RSRVROLE_NODE TBDB_RSRVROLE_VIRTHOST TBDB_RSRVROLE_DELAYNODE
TBDB_RSRVROLE_SIMNODE
TBDB_RSRVROLE_SIMHOST
TBDB_EXPT_WORKDIR
TBSetNodeEventState TBGetNodeEventState
......@@ -529,7 +529,7 @@ sub TBDB_JAILIPMASK() { "@JAILIPMASK@"; }
sub TBDB_RSRVROLE_NODE() { "node"; }
sub TBDB_RSRVROLE_VIRTHOST() { "virthost"; }
sub TBDB_RSRVROLE_DELAYNODE() { "delaynode"; }
sub TBDB_RSRVROLE_SIMNODE() { "simnode"; }
sub TBDB_RSRVROLE_SIMHOST() { "simhost"; }
# Interfaces roles.
sub TBDB_IFACEROLE_CONTROL() { "ctrl"; }
......
......@@ -21,6 +21,7 @@ char *tbdb_objecttypes[] = {
TBDB_OBJECTTYPE_FRISBEE,
TBDB_OBJECTTYPE_SIMULATOR,
TBDB_OBJECTTYPE_LINKTEST,
TBDB_OBJECTTYPE_NSE,
0,
};
......@@ -38,6 +39,7 @@ char *tbdb_eventtypes[] = {
TBDB_EVENTTYPE_HALT,
TBDB_EVENTTYPE_SWAPOUT,
TBDB_EVENTTYPE_NSESWAP,
TBDB_EVENTTYPE_NSEEVENT,
TBDB_NODESTATE_ISUP,
TBDB_NODESTATE_REBOOTED,
TBDB_NODESTATE_REBOOTING,
......@@ -92,3 +94,4 @@ tbdb_valideventtype(char *foo)
}
return 0;
}
......@@ -37,6 +37,7 @@
#define TBDB_OBJECTTYPE_FRISBEE "FRISBEE"
#define TBDB_OBJECTTYPE_SIMULATOR "SIMULATOR"
#define TBDB_OBJECTTYPE_LINKTEST "LINKTEST"
#define TBDB_OBJECTTYPE_NSE "NSE"
#define TBDB_EVENTTYPE_START "START"
#define TBDB_EVENTTYPE_STOP "STOP"
......@@ -51,6 +52,7 @@
#define TBDB_EVENTTYPE_HALT "HALT"
#define TBDB_EVENTTYPE_SWAPOUT "SWAPOUT"
#define TBDB_EVENTTYPE_NSESWAP "NSESWAP"
#define TBDB_EVENTTYPE_NSESWAP "NSEEVENT"
#define TBDB_NODESTATE_ISUP "ISUP"
#define TBDB_NODESTATE_REBOOTED "REBOOTED"
......
......@@ -460,6 +460,7 @@ CREATE TABLE interfaces (
role enum('ctrl','expt','jail','fake','other','gw') default NULL,
current_speed enum('100','10','1000') NOT NULL default '100',
duplex enum('full','half') NOT NULL default 'full',
rtabid smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (node_id,card,port),
KEY mac (mac),
KEY IP (IP)
......@@ -761,6 +762,7 @@ CREATE TABLE node_types (
issubnode tinyint(4) NOT NULL default '0',
isplabdslice tinyint(4) NOT NULL default '0',
issimnode tinyint(4) NOT NULL default '0',
simnode_capacity smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (type)
) TYPE=MyISAM;
......@@ -1125,7 +1127,7 @@ CREATE TABLE reserved (
eid varchar(32) NOT NULL default '',
rsrv_time timestamp(14) NOT NULL,
vname varchar(32) default NULL,
erole enum('node','virthost','delaynode','simnode') NOT NULL default 'node',
erole enum('node','virthost','delaynode','simhost') NOT NULL default 'node',
PRIMARY KEY (node_id),
UNIQUE KEY vname (pid,eid,vname)
) TYPE=MyISAM;
......@@ -1479,6 +1481,7 @@ CREATE TABLE veth_interfaces (
mask varchar(15) default NULL,
iface varchar(10) default NULL,
vnode_id varchar(32) default NULL,
rtabid smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (node_id,veth_id),
KEY IP (IP)
) TYPE=MyISAM;
......
......@@ -77,6 +77,7 @@ REPLACE INTO event_eventtypes VALUES (9,'RESET');
REPLACE INTO event_eventtypes VALUES (10,'KILL');
REPLACE INTO event_eventtypes VALUES (11,'HALT');
REPLACE INTO event_eventtypes VALUES (12,'SWAPOUT');
REPLACE INTO event_eventtypes VALUES (13,'NSEEVENT');
--
-- Dumping data for table `event_objecttypes`
......@@ -91,6 +92,7 @@ REPLACE INTO event_objecttypes VALUES (4,'PROGRAM');
REPLACE INTO event_objecttypes VALUES (5,'FRISBEE');
REPLACE INTO event_objecttypes VALUES (6,'SIMULATOR');
REPLACE INTO event_objecttypes VALUES (7,'LINKTEST');
REPLACE INTO event_objecttypes VALUES (8,'NSE');
--
-- Dumping data for table `exported_tables`
......
-- MySQL dump 8.22
-- MySQL dump 8.23
--
-- Host: localhost Database: tbdb
---------------------------------------------------------
-- Server version 3.23.54-log
-- Server version 3.23.58-log
--
-- Dumping data for table 'sitevariables'
-- Dumping data for table `sitevariables`
--
INSERT INTO sitevariables VALUES ('general/testvar',NULL,'43','A test variable');
INSERT INTO sitevariables VALUES ('web/nologins',NULL,'0','Non-zero value indicates that no non-admin user may log into the Web Interface.');
INSERT INTO sitevariables VALUES ('web/message',NULL,'','Message to place in large lettering under the login message on the Web Interface.');
INSERT INTO sitevariables VALUES ('idle/threshold',NULL,'4','Number of hours of inactivity for a node/expt to be considered idle.');
INSERT INTO sitevariables VALUES ('idle/threshold','1','4','Number of hours of inactivity for a node/expt to be considered idle.');
INSERT INTO sitevariables VALUES ('idle/mailinterval',NULL,'4','Number of hours since sending a swap request before sending another one. (Timing of first one is determined by idle/threshold.)');
INSERT INTO sitevariables VALUES ('idle/cc_grp_ldrs',NULL,'3','Start CC\'ing group and project leaders on idle messages on the Nth message.');
INSERT INTO sitevariables VALUES ('batch/retry_wait',NULL,'900','Number of seconds to wait before retrying a failed batch experiment.');
......@@ -21,6 +21,6 @@ INSERT INTO sitevariables VALUES ('swap/autoswap_warn',NULL,'60','Number of minu
INSERT INTO sitevariables VALUES ('idle/batch_threshold',NULL,'30','Number of minutes of inactivity for a batch node/expt to be considered idle.');
INSERT INTO sitevariables VALUES ('general/recently_active',NULL,'14','Number of days to be considered a recently active user of the testbed.');
INSERT INTO sitevariables VALUES ('plab/load_metric',NULL,'load_fifteen','GMOND load metric to use (load_one, load_five, load_fifteen)');
INSERT INTO sitevariables VALUES ('plab/max_load',NULL,'5.0','Load at which to stop admitting jobs (0==admit nothing, 1000==admit all)');
INSERT INTO sitevariables VALUES ('plab/max_load','8.0','5.0','Load at which to stop admitting jobs (0==admit nothing, 1000==admit all)');
INSERT INTO sitevariables VALUES ('plab/min_disk',NULL,'10.0','Minimum disk space free at which to stop admitting jobs (0==admit all, 100==admit none)');
......@@ -2222,7 +2222,7 @@ sub InitPnode($pnode, $vnode)
" where node_id='$pnode'");
$vname = "nsenode${nsenode_id}";
$role = TBDB_RSRVROLE_SIMNODE;
$role = TBDB_RSRVROLE_SIMHOST;
$nsenode_id++;
# Right now, we have only one row for nseconfigs per experiment.
......
......@@ -215,6 +215,8 @@ COMMAND_PROTOTYPE(dosyncserver);
COMMAND_PROTOTYPE(dokeyhash);
COMMAND_PROTOTYPE(doeventkey);
COMMAND_PROTOTYPE(dofullconfig);
COMMAND_PROTOTYPE(doroutelist);
COMMAND_PROTOTYPE(dorole);
/*
* The fullconfig slot determines what routines get called when pushing
......@@ -277,6 +279,8 @@ struct command {
{ "keyhash", FULLCONFIG_ALL, dokeyhash},
{ "eventkey", FULLCONFIG_ALL, doeventkey},
{ "fullconfig", FULLCONFIG_NONE, dofullconfig},
{ "routelist", FULLCONFIG_PHYS, doroutelist},
{ "role", FULLCONFIG_PHYS, dorole},
};
static int numcommands = sizeof(command_array)/sizeof(struct command);
......@@ -1022,9 +1026,9 @@ COMMAND_PROTOTYPE(doifconfig)
* Find all the interfaces.
*/
res = mydb_query("select card,IP,IPalias,MAC,current_speed,duplex, "
" IPaliases,iface,role,mask "
" IPaliases,iface,role,mask,rtabid "
"from interfaces where node_id='%s'",
10, reqp->nodeid);
11, reqp->nodeid);
if (!res) {
error("IFCONFIG: %s: DB Error getting interfaces!\n",
reqp->nodeid);
......@@ -1099,6 +1103,12 @@ COMMAND_PROTOTYPE(doifconfig)
(strcmp(reqp->class, "ixp") ?
"" : iface));
}
if (vers >= 14) {
bufp += OUTPUT(bufp, ebufp - bufp,
" RTABID=%s", row[10] );
}
OUTPUT(bufp, ebufp - bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
if (verbose)
......@@ -1128,12 +1138,12 @@ COMMAND_PROTOTYPE(doifconfig)
/*
* Find all the veth interfaces.
*/
res = mydb_query("select v.veth_id,v.IP,v.mac,i.mac,v.mask "
res = mydb_query("select v.veth_id,v.IP,v.mac,i.mac,v.mask,v.rtabid "
" from veth_interfaces as v "
"left join interfaces as i on "
" i.node_id=v.node_id and i.iface=v.iface "
"where v.node_id='%s' and %s",
5, reqp->pnodeid, buf);
6, reqp->pnodeid, buf);
if (!res) {
error("IFCONFIG: %s: DB Error getting veth interfaces!\n",
reqp->nodeid);
......@@ -1144,6 +1154,7 @@ COMMAND_PROTOTYPE(doifconfig)
return 0;
}
while (nrows) {
char *bufp = buf;
row = mysql_fetch_row(res);
/*
......@@ -1151,12 +1162,18 @@ COMMAND_PROTOTYPE(doifconfig)
* no underlying phys interface (say, colocated nodes in a
* link).
*/
OUTPUT(buf, sizeof(buf),
bufp += OUTPUT(bufp, ebufp - bufp,
"IFACETYPE=veth "
"INET=%s MASK=%s ID=%s VMAC=%s PMAC=%s\n",
"INET=%s MASK=%s ID=%s VMAC=%s PMAC=%s",
row[1], CHECKMASK(row[4]), row[0], row[2],
row[3] ? row[3] : "none");
if (vers >= 14) {
bufp += OUTPUT( bufp, ebufp - bufp,
" RTABID=%s", row[5] );
}
OUTPUT(bufp, ebufp - bufp, "\n");
client_writeback(sock, buf, strlen(buf), tcp);
if (verbose)
info("IFCONFIG: %s", buf);
......@@ -3299,9 +3316,9 @@ COMMAND_PROTOTYPE(donseconfigs)
}
res = mydb_query("select nseconfig from nseconfigs as nse "
"where nse.vname='%s' and "
" nse.pid='%s' and nse.eid='%s'",
1, reqp->nickname, reqp->pid, reqp->eid);
"where nse.pid='%s' and nse.eid='%s' "
"and nse.vname='%s'",
1, reqp->pid, reqp->eid, reqp->nickname);
if (!res) {
error("NSECONFIGS: %s: DB Error getting nseconfigs\n",
......@@ -5024,6 +5041,168 @@ COMMAND_PROTOTYPE(doeventkey)
return 0;
}
/*
* Return routing stuff for all vnodes mapped to the requesting physnode
*/
COMMAND_PROTOTYPE(doroutelist)
{
MYSQL_RES *res;
MYSQL_ROW row;
char buf[MYBUFSIZE];
int n, nrows;
/*
* Now check reserved table
*/
if (!reqp->allocated) {
error("ROUTES: %s: Node is free\n", reqp->nodeid);
return 1;
}
/*
* Get the routing type from the nodes table.
*/
res = mydb_query("select routertype from nodes where node_id='%s'",
1, reqp->nodeid);
if (!res) {
error("ROUTES: %s: DB Error getting router type!\n",
reqp->nodeid);
return 1;
}
if ((int)mysql_num_rows(res) == 0) {
mysql_free_result(res);
return 0;
}
/*
* Return type. At some point we might have to return a list of
* routes too, if we support static routes specified by the user
* in the NS file.
*/
row = mysql_fetch_row(res);
if (! row[0] || !row[0][0]) {
mysql_free_result(res);
return 0;
}
sprintf(buf, "ROUTERTYPE=%s\n", row[0]);
mysql_free_result(res);
client_writeback(sock, buf, strlen(buf), tcp);
if (verbose)
info("ROUTES: %s", buf);
/*
* Get the routing type from the nodes table.
*/
res = mydb_query("select vr.vname,src,dst,dst_type,dst_mask,nexthop,cost "
"from virt_routes as vr "
"left join v2pmap as v2p "
"using (pid,eid,vname) "
"where vr.pid='%s' and "
" vr.eid='%s' and v2p.node_id='%s'",
7, reqp->pid, reqp->eid, reqp->nodeid);
if (!res) {
error("ROUTELIST: %s: DB Error getting manual routes!\n",
reqp->nodeid);
return 1;
}
if ((nrows = (int)mysql_num_rows(res)) == 0) {
mysql_free_result(res);
return 0;
}
n = nrows;
while (n) {
char dstip[32];
row = mysql_fetch_row(res);
/*
* OMG, the Linux route command is too stupid to accept a
* host-on-a-subnet as the subnet address, so we gotta mask
* off the bits manually for network routes.
*
* Eventually we'll perform this operation in the NS parser
* so it appears in the DB correctly.
*/
if (strcmp(row[3], "net") == 0) {
struct in_addr tip, tmask;
inet_aton(row[2], &tip);
inet_aton(row[4], &tmask);
tip.s_addr &= tmask.s_addr;
strncpy(dstip, inet_ntoa(tip), sizeof(dstip));
} else
strncpy(dstip, row[2], sizeof(dstip));
sprintf(buf, "ROUTE NODE=%s SRC=%s DEST=%s DESTTYPE=%s DESTMASK=%s "
"NEXTHOP=%s COST=%s\n",
row[0], row[1], dstip, row[3], row[4], row[5], row[6]);
client_writeback(sock, buf, strlen(buf), tcp);
n--;
}
mysql_free_result(res);
if (verbose)
info("ROUTES: %d routes in list\n", nrows);
return 0;
}
/*
* Return routing stuff for all vnodes mapped to the requesting physnode
*/
COMMAND_PROTOTYPE(dorole)
{
MYSQL_RES *res;
MYSQL_ROW row;
char buf[MYBUFSIZE];
/*
* Now check reserved table
*/
if (!reqp->allocated) {
error("ROLE: %s: Node is free\n", reqp->nodeid);
return 1;
}
/*
* Get the erole from the reserved table
*/
res = mydb_query("select erole from reserved where node_id='%s'",
1, reqp->nodeid);
if (!res) {
error("ROLE: %s: DB Error getting the role of this node!\n",
reqp->nodeid);
return 1;
}
if ((int)mysql_num_rows(res) == 0) {
mysql_free_result(res);
return 0;
}
row = mysql_fetch_row(res);
if (! row[0] || !row[0][0]) {
mysql_free_result(res);
return 0;
}
sprintf(buf, "%s\n", row[0]);
mysql_free_result(res);
client_writeback(sock, buf, strlen(buf), tcp);
if (verbose)
info("ROLE: %s", buf);
return 0;
}
/*
* Return entire config.
*/
......
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