Commit 9fb9ef8f authored by Leigh Stoller's avatar Leigh Stoller

Quickie change to experiment with client side caching; Added a new

"fullconfig" command to cycle through the list of existing commands
and spit out a section for each. Not all of them of course; just a
subset that makes sense. I did not that mounts are a bit of a problem
cause of the USESFS argument. Not sure what to do yet.
parent 1b9ad406
...@@ -199,54 +199,57 @@ COMMAND_PROTOTYPE(doslothdparams); ...@@ -199,54 +199,57 @@ COMMAND_PROTOTYPE(doslothdparams);
COMMAND_PROTOTYPE(doprogagents); COMMAND_PROTOTYPE(doprogagents);
COMMAND_PROTOTYPE(dosyncserver); COMMAND_PROTOTYPE(dosyncserver);
COMMAND_PROTOTYPE(dokeyhash); COMMAND_PROTOTYPE(dokeyhash);
COMMAND_PROTOTYPE(dofullconfig);
struct command { struct command {
char *cmdname; char *cmdname;
int full;
int (*func)(int, tmcdreq_t *, char *, int, int); int (*func)(int, tmcdreq_t *, char *, int, int);
} command_array[] = { } command_array[] = {
{ "reboot", doreboot }, { "reboot", 0, doreboot },
{ "nodeid", donodeid }, { "nodeid", 1, donodeid },
{ "status", dostatus }, { "status", 0, dostatus },
{ "ifconfig", doifconfig }, { "ifconfig", 1, doifconfig },
{ "accounts", doaccounts }, { "accounts", 1, doaccounts },
{ "delay", dodelay }, { "delay", 1, dodelay },
{ "linkdelay", dolinkdelay }, { "linkdelay", 1, dolinkdelay },
{ "hostnamesV2",dohostsV2 }, /* This will go away */ { "hostnamesV2", 0, dohostsV2 }, /* This will go away */
{ "hostnames", dohosts }, { "hostnames", 1, dohosts },
{ "rpms", dorpms }, { "rpms", 1, dorpms },
{ "deltas", dodeltas }, { "deltas", 0, dodeltas },
{ "tarballs", dotarballs }, { "tarballs", 1, dotarballs },
{ "startupcmd", dostartcmd }, { "startupcmd", 1, dostartcmd },
{ "startstatus",dostartstat }, /* Leave this before "startstat" */ { "startstatus", 0, dostartstat }, /* Leave this before "startstat" */
{ "startstat", dostartstat }, { "startstat", 0, dostartstat },
{ "readycount", doreadycount }, { "readycount", 0, doreadycount },
{ "ready", doready }, { "ready", 0, doready },
{ "log", dolog }, { "log", 0, dolog },
{ "mounts", domounts }, { "mounts", 0, domounts },
{ "sfshostid", dosfshostid }, { "sfshostid", 0, dosfshostid },
{ "loadinfo", doloadinfo}, { "loadinfo", 0, doloadinfo},
{ "reset", doreset}, { "reset", 0, doreset},
{ "routing", dorouting}, { "routing", 1, dorouting},
{ "trafgens", dotrafgens}, { "trafgens", 1, dotrafgens},
{ "nseconfigs", donseconfigs}, { "nseconfigs", 1, donseconfigs},
{ "creator", docreator}, { "creator", 1, docreator},
{ "state", dostate}, { "state", 0, dostate},
{ "tunnels", dotunnels}, { "tunnels", 1, dotunnels},
{ "vnodelist", dovnodelist}, { "vnodelist", 1, dovnodelist},
{ "subnodelist",dosubnodelist}, { "subnodelist", 1, dosubnodelist},
{ "isalive", doisalive}, { "isalive", 0, doisalive},
{ "ipodinfo", doipodinfo}, { "ipodinfo", 0, doipodinfo},
{ "ntpinfo", dontpinfo}, { "ntpinfo", 1, dontpinfo},
{ "ntpdrift", dontpdrift}, { "ntpdrift", 0, dontpdrift},
{ "tarball", doatarball}, { "tarball", 0, doatarball},
{ "rpm", doanrpm}, { "rpm", 0, doanrpm},
{ "jailconfig", dojailconfig}, { "jailconfig", 0, dojailconfig},
{ "plabconfig", doplabconfig}, { "plabconfig", 0, doplabconfig},
{ "subconfig", dosubconfig}, { "subconfig", 0, dosubconfig},
{ "sdparams", doslothdparams}, { "sdparams", 1, doslothdparams},
{ "programs", doprogagents}, { "programs", 1, doprogagents},
{ "syncserver", dosyncserver}, { "syncserver", 1, dosyncserver},
{ "keyhash", dokeyhash}, { "keyhash", 1, dokeyhash},
{ "fullconfig", 0, dofullconfig},
}; };
static int numcommands = sizeof(command_array)/sizeof(struct command); static int numcommands = sizeof(command_array)/sizeof(struct command);
...@@ -4748,8 +4751,8 @@ COMMAND_PROTOTYPE(doixpconfig) ...@@ -4748,8 +4751,8 @@ COMMAND_PROTOTYPE(doixpconfig)
MYSQL_RES *res; MYSQL_RES *res;
MYSQL_ROW row; MYSQL_ROW row;
char buf[MYBUFSIZE]; char buf[MYBUFSIZE];
struct in_addr mask_addr, bcast_addr, gw_addr; struct in_addr mask_addr, bcast_addr;
char bcast_ip[16], gw_ip[16]; char bcast_ip[16];
/* /*
* Get the "control" net address for the IXP from the interfaces * Get the "control" net address for the IXP from the interfaces
...@@ -4810,12 +4813,14 @@ COMMAND_PROTOTYPE(doixpconfig) ...@@ -4810,12 +4813,14 @@ COMMAND_PROTOTYPE(doixpconfig)
return 0; return 0;
} }
/* return slothd params - just compiled in for now. */ /*
* return slothd params - just compiled in for now.
*/
COMMAND_PROTOTYPE(doslothdparams) COMMAND_PROTOTYPE(doslothdparams)
{ {
char buf[MYBUFSIZE]; char buf[MYBUFSIZE];
sprintf(buf, "%s", SDPARAMS); sprintf(buf, "%s\n", SDPARAMS);
client_writeback(sock, buf, strlen(buf), tcp); client_writeback(sock, buf, strlen(buf), tcp);
return 0; return 0;
} }
...@@ -4931,3 +4936,30 @@ COMMAND_PROTOTYPE(dokeyhash) ...@@ -4931,3 +4936,30 @@ COMMAND_PROTOTYPE(dokeyhash)
return 0; return 0;
} }
/*
* Return entire config.
*/
COMMAND_PROTOTYPE(dofullconfig)
{
char buf[MYBUFSIZE];
int i;
/*
* Now check reserved table
*/
if (!reqp->allocated) {
error("FULLCONFIG: %s: Node is free\n", reqp->nodeid);
return 1;
}
for (i = 0; i < numcommands; i++) {
if (command_array[i].full) {
sprintf(buf, "*** %s\n", command_array[i].cmdname);
client_writeback(sock, buf, strlen(buf), tcp);
command_array[i].func(sock, reqp, rdata, tcp, vers);
}
}
return 0;
}
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