Commit 82321694 authored by Mike Hibler's avatar Mike Hibler

Add hostinfo command for host to return..um, info. Right now returns

CDVERSION= for CD-booted machines.
parent 934eb81e
......@@ -28,7 +28,7 @@ use Exporter;
TMCCCMD_NTPINFO TMCCCMD_NTPDRIFT TMCCCMD_EVENTKEY TMCCCMD_ROUTELIST
TMCCCMD_ROLE TMCCCMD_RUSAGE TMCCCMD_WATCHDOGINFO TMCCCMD_HOSTKEYS
TMCCCMD_FIREWALLINFO TMCCCMD_EMULABCONFIG
TMCCCMD_CREATOR
TMCCCMD_CREATOR TMCCCMD_HOSTINFO
);
# Must come after package declaration!
......@@ -158,6 +158,7 @@ my %commandset =
"firewallinfo" => {TAG => "firewallinfo"},
"emulabconfig" => {TAG => "emulabconfig"},
"creator" => {TAG => "creator"},
"hostinfo" => {TAG => "hostinfo"},
);
#
......@@ -204,6 +205,7 @@ sub TMCCCMD_HOSTKEYS() { $commandset{"hostkeys"}->{TAG}; }
sub TMCCCMD_FIREWALLINFO(){ $commandset{"firewallinfo"}->{TAG}; }
sub TMCCCMD_EMULABCONFIG(){ $commandset{"emulabconfig"}->{TAG}; }
sub TMCCCMD_CREATOR (){ $commandset{"creator"}->{TAG}; }
sub TMCCCMD_HOSTINFO (){ $commandset{"hostinfo"}->{TAG}; }
#
# Caller uses this routine to set configuration of this library
......
......@@ -136,6 +136,16 @@ sub doboot()
$bootdev = WhichRawDisk();
print("Using $bootdev for config sector ...\n");
#
# Report back the CD version
# XXX may want to consider not doing then on every boot
#
if (-e "$ETCDIR/emuboot-volid") {
my $cdversion = `cat $ETCDIR/emuboot-volid`;
chomp($cdversion);
tmcc(TMCCCMD_HOSTINFO, "CDVERSION=$cdversion");
}
bootinfo:
#
# If this is first install on this disk, or if the disk has just been
......
......@@ -226,6 +226,7 @@ COMMAND_PROTOTYPE(dodoginfo);
COMMAND_PROTOTYPE(dohostkeys);
COMMAND_PROTOTYPE(dotmcctest);
COMMAND_PROTOTYPE(dofwinfo);
COMMAND_PROTOTYPE(dohostinfo);
/*
* The fullconfig slot determines what routines get called when pushing
......@@ -300,6 +301,7 @@ struct command {
{ "hostkeys", FULLCONFIG_NONE, 0, dohostkeys},
{ "tmcctest", FULLCONFIG_NONE, F_MINLOG, dotmcctest},
{ "firewallinfo", FULLCONFIG_ALL, 0, dofwinfo},
{ "hostinfo", FULLCONFIG_NONE, 0, dohostinfo},
};
static int numcommands = sizeof(command_array)/sizeof(struct command);
......@@ -5027,6 +5029,28 @@ COMMAND_PROTOTYPE(dodoginfo)
return 0;
}
/*
* Stash info returned by the host into the DB
* Right now we only recognize CDVERSION=<str> for CD booted systems.
*/
COMMAND_PROTOTYPE(dohostinfo)
{
char *bp, buf[MYBUFSIZE];
bp = rdata;
if (sscanf(bp, "CDVERSION=%31[a-zA-Z0-9-]", buf) == 1) {
if (verbose)
info("HOSTINFO CDVERSION=%s\n", buf);
if (mydb_update("update nodes set cd_version='%s' "
"where node_id='%s'",
buf, reqp->nodeid)) {
error("HOSTINFO: %s: DB update failed\n", reqp->nodeid);
return 1;
}
}
return 0;
}
/*
* XXX Stash ssh host keys into the DB.
*/
......
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