Commit 30ce772a authored by Leigh Stoller's avatar Leigh Stoller

Add initial emulabconfig call for returning info during inner elab

initial configuration (for turning an experimental node into a boss or
ops node).
parent 53d89e86
...@@ -142,6 +142,7 @@ typedef struct { ...@@ -142,6 +142,7 @@ typedef struct {
int iscontrol; int iscontrol;
int isplabdslice; int isplabdslice;
int isplabsvc; int isplabsvc;
int elab_in_elab;
int update_accounts; int update_accounts;
char nodeid[TBDB_FLEN_NODEID]; char nodeid[TBDB_FLEN_NODEID];
char vnodeid[TBDB_FLEN_NODEID]; char vnodeid[TBDB_FLEN_NODEID];
...@@ -227,6 +228,7 @@ COMMAND_PROTOTYPE(dohostkeys); ...@@ -227,6 +228,7 @@ COMMAND_PROTOTYPE(dohostkeys);
COMMAND_PROTOTYPE(dotmcctest); COMMAND_PROTOTYPE(dotmcctest);
COMMAND_PROTOTYPE(dofwinfo); COMMAND_PROTOTYPE(dofwinfo);
COMMAND_PROTOTYPE(dohostinfo); COMMAND_PROTOTYPE(dohostinfo);
COMMAND_PROTOTYPE(doemulabconfig);
/* /*
* The fullconfig slot determines what routines get called when pushing * The fullconfig slot determines what routines get called when pushing
...@@ -302,6 +304,7 @@ struct command { ...@@ -302,6 +304,7 @@ struct command {
{ "tmcctest", FULLCONFIG_NONE, F_MINLOG, dotmcctest}, { "tmcctest", FULLCONFIG_NONE, F_MINLOG, dotmcctest},
{ "firewallinfo", FULLCONFIG_ALL, 0, dofwinfo}, { "firewallinfo", FULLCONFIG_ALL, 0, dofwinfo},
{ "hostinfo", FULLCONFIG_NONE, 0, dohostinfo}, { "hostinfo", FULLCONFIG_NONE, 0, dohostinfo},
{ "emulabconfig", FULLCONFIG_NONE, F_ALLOCATED, doemulabconfig},
}; };
static int numcommands = sizeof(command_array)/sizeof(struct command); static int numcommands = sizeof(command_array)/sizeof(struct command);
...@@ -3749,7 +3752,8 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp) ...@@ -3749,7 +3752,8 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
" e.sync_server,pt.class,pt.type, " " e.sync_server,pt.class,pt.type, "
" pt.isremotenode,vt.issubnode,e.keyhash, " " pt.isremotenode,vt.issubnode,e.keyhash, "
" nk.sfshostid,e.eventkey,vt.isplabdslice, " " nk.sfshostid,e.eventkey,vt.isplabdslice, "
" e.veth_encapsulate,ps.admin " " e.veth_encapsulate,ps.admin, "
" e.elab_in_elab "
"from nodes as nv " "from nodes as nv "
"left join interfaces as i on " "left join interfaces as i on "
" i.node_id=nv.phys_nodeid " " i.node_id=nv.phys_nodeid "
...@@ -3769,7 +3773,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp) ...@@ -3769,7 +3773,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
"left join node_hostkeys as nk on " "left join node_hostkeys as nk on "
" nk.node_id=nv.node_id " " nk.node_id=nv.node_id "
"where nv.node_id='%s' and i.IP='%s'", "where nv.node_id='%s' and i.IP='%s'",
24, reqp->vnodeid, inet_ntoa(ipaddr)); 25, reqp->vnodeid, inet_ntoa(ipaddr));
} }
else { else {
res = mydb_query("select t.class,t.type,n.node_id,n.jailflag," res = mydb_query("select t.class,t.type,n.node_id,n.jailflag,"
...@@ -3779,7 +3783,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp) ...@@ -3779,7 +3783,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
" e.sync_server,t.class,t.type, " " e.sync_server,t.class,t.type, "
" t.isremotenode,t.issubnode,e.keyhash, " " t.isremotenode,t.issubnode,e.keyhash, "
" nk.sfshostid,e.eventkey,0, " " nk.sfshostid,e.eventkey,0, "
" e.veth_encapsulate,0 " " e.veth_encapsulate,0,e.elab_in_elab "
"from interfaces as i " "from interfaces as i "
"left join nodes as n on n.node_id=i.node_id " "left join nodes as n on n.node_id=i.node_id "
"left join reserved as r on " "left join reserved as r on "
...@@ -3791,7 +3795,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp) ...@@ -3791,7 +3795,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
"left join node_hostkeys as nk on " "left join node_hostkeys as nk on "
" nk.node_id=n.node_id " " nk.node_id=n.node_id "
"where i.IP='%s'", "where i.IP='%s'",
24, inet_ntoa(ipaddr)); 25, inet_ntoa(ipaddr));
} }
if (!res) { if (!res) {
...@@ -3822,6 +3826,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp) ...@@ -3822,6 +3826,7 @@ iptonodeid(struct in_addr ipaddr, tmcdreq_t *reqp)
reqp->issubnode = (! strcasecmp(row[17], "0") ? 0 : 1); reqp->issubnode = (! strcasecmp(row[17], "0") ? 0 : 1);
reqp->isplabdslice = (! strcasecmp(row[21], "0") ? 0 : 1); reqp->isplabdslice = (! strcasecmp(row[21], "0") ? 0 : 1);
reqp->isplabsvc = (row[23] && strcasecmp(row[23], "0")) ? 1 : 0; reqp->isplabsvc = (row[23] && strcasecmp(row[23], "0")) ? 1 : 0;
reqp->elab_in_elab = (row[24] && strcasecmp(row[24], "0")) ? 1 : 0;
if (row[8]) if (row[8])
strncpy(reqp->testdb, row[8], sizeof(reqp->testdb)); strncpy(reqp->testdb, row[8], sizeof(reqp->testdb));
...@@ -5281,6 +5286,92 @@ COMMAND_PROTOTYPE(dofwinfo) ...@@ -5281,6 +5286,92 @@ COMMAND_PROTOTYPE(dofwinfo)
return 0; return 0;
} }
/*
* Return the config for an inner emulab
*/
COMMAND_PROTOTYPE(doemulabconfig)
{
MYSQL_RES *res;
MYSQL_ROW row;
char buf[MYBUFSIZE];
char *bufp = buf, *ebufp = &buf[sizeof(buf)];
int nrows;
/*
* Must be an elab_in_elab experiment.
*/
if (!reqp->elab_in_elab) {
/* Silent error is fine */
return 0;
}
/*
* Get the control network IPs. At the moment, it is assumed that
* that all the nodes are on a single lan. If we get fancier about
* that, we will have to figure out how to label the specific lans
* se we know which is which.
*/
res = mydb_query("select r.node_id,vn.inner_elab_role,vl.ip,r.vname "
" from reserved as r "
"left join virt_nodes as vn on "
" vn.vname=r.vname and vn.pid=r.pid and "
" vn.eid=r.eid "
"left join virt_lans as vl on vl.vnode=r.vname and "
" vl.pid=r.pid and vl.eid=r.eid "
"where r.pid='%s' and r.eid='%s'",
4, reqp->pid, reqp->eid);
if (!res) {
error("EMULABCONFIG: %s: DB Error getting elab_in_elab\n",
reqp->nodeid);
return 1;
}
if (! mysql_num_rows(res)) {
mysql_free_result(res);
return 0;
}
nrows = (int)mysql_num_rows(res);
/*
* Lets find the role for the current node and spit that out first.
*/
bzero(buf, sizeof(buf));
while (nrows--) {
row = mysql_fetch_row(res);
if (!strcmp(row[0], reqp->nodeid)) {
bufp += OUTPUT(bufp, ebufp - bufp, "ROLE=%s\n", row[1]);
break;
}
}
/*
* Spit the names of the boss and ops nodes for everyones benefit.
*/
mysql_data_seek(res, 0);
nrows = (int)mysql_num_rows(res);
while (nrows--) {
row = mysql_fetch_row(res);
if (!strcmp(row[1], "boss")) {
bufp += OUTPUT(bufp, ebufp - bufp, "BOSSNODE=%s\n",
row[3]);
bufp += OUTPUT(bufp, ebufp - bufp, "BOSSIP=%s\n",
row[2]);
}
else if (!strcmp(row[1], "ops")) {
bufp += OUTPUT(bufp, ebufp - bufp, "OPSNODE=%s\n",
row[3]);
bufp += OUTPUT(bufp, ebufp - bufp, "OPSIP=%s\n",
row[2]);
}
}
mysql_free_result(res);
client_writeback(sock, buf, strlen(buf), tcp);
return 0;
}
/* /*
* Hack to test timeouts and other anomolous situations for tmcc * Hack to test timeouts and other anomolous situations for tmcc
*/ */
......
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