Commit e4b4aef4 authored by Mike Hibler's avatar Mike Hibler

Changes to create and return a physical node "map" for linktest

parent 9d25ac3e
......@@ -25,6 +25,7 @@ my $optlist = "n";
my $impotent = 0;
my $toponame = "topomap";
my $ltname = "ltmap";
my $ltpname = "ltpmap";
#
# Configure variables
......@@ -325,12 +326,60 @@ foreach my $lan (sort keys(%lans)) {
print $OUT "$lan,$mask,$cost\n";
}
#
# Finally generate a "physical resource" map for linktest if the
# experiment is swapped in. This could be part of the ltmap, but
# for maximum compatibility (and to keep the ltmap "virtual") we
# put the info in a separate file. Format:
#
# m vname pcvm290-1 pc290 pc3000 OS OS-version
# ...
#
#
# Note the regular joins here, not left joins, so that we do not
# get lines for delay nodes and virtnode hosts that are in reserved
# but not in virt_nodes.
#
my $havepmap = 0;
$query_result =
DBQueryFatal("select v.vname,n.node_id,n.phys_nodeid,n.type,".
" o.OS,o.version".
" from virt_nodes as v,reserved as r,nodes as n,os_info as o".
" where v.pid=r.pid and v.eid=r.eid and v.vname=r.vname".
" and r.node_id=n.node_id and n.def_boot_osid=o.osid and".
" v.pid='$pid' and v.eid='$eid'");
if ($query_result->numrows) {
$havepmap = 1;
if ($impotent) {
$LTPOUT = *STDERR;
} else {
unlink("${ltpname}.new")
if (-e "${ltpname}.new");
open(LTPMAP, "> ${ltpname}.new") or
die("Could not create ${ltpname}.new: $!\n");
$LTPOUT = *LTPMAP;
}
while (my ($vname,$node,$pnode,$ptype,$os,$osvers) =
$query_result->fetchrow_array) {
$os = "UNKNOWN" if (!$os);
$osvers = "0" if (!$osvers);
print $LTPOUT "m $vname $node $pnode $ptype $os $osvers\n";
}
close(LTPMAP)
if (!$impotent);
}
if (! $impotent) {
close(MAP);
close(LTMAP);
system("mv -f ${toponame}.new $toponame");
system("mv -f ${ltname}.new $ltname");
system("mv -f ${ltpname}.new $ltpname")
if ($havepmap);
#
# Create a compressed copy of the file. The experiment nodes will look
......@@ -338,6 +387,8 @@ if (! $impotent) {
#
system("rm -f ${toponame}.gz ; cat $toponame | gzip > ${toponame}.gz");
system("rm -f ${ltname}.gz ; cat $ltname | gzip > ${ltname}.gz");
system("rm -f ${ltpname}.gz ; cat $ltpname | gzip > ${ltpname}.gz")
if ($havepmap);
#
# Now copy over to the user exp directory since in a normal create/modify
......@@ -349,5 +400,7 @@ if (! $impotent) {
system("cp -fp $toponame ${toponame}.gz $userdir/tbdata");
system("cp -fp $ltname ${ltname}.gz $userdir/tbdata");
system("cp -fp $ltpname ${ltpname}.gz $userdir/tbdata")
if ($havepmap);
}
exit(0);
......@@ -242,6 +242,7 @@ COMMAND_PROTOTYPE(dotiptunnels);
COMMAND_PROTOTYPE(dorelayconfig);
COMMAND_PROTOTYPE(dotraceconfig);
COMMAND_PROTOTYPE(doltmap);
COMMAND_PROTOTYPE(doltpmap);
COMMAND_PROTOTYPE(doelvindport);
COMMAND_PROTOTYPE(doplabeventkeys);
COMMAND_PROTOTYPE(dointfcmap);
......@@ -331,6 +332,7 @@ struct command {
{ "tiptunnels", FULLCONFIG_ALL, F_ALLOCATED, dotiptunnels},
{ "traceinfo", FULLCONFIG_ALL, F_ALLOCATED, dotraceconfig },
{ "ltmap", FULLCONFIG_NONE, F_MINLOG|F_ALLOCATED, doltmap},
{ "ltpmap", FULLCONFIG_NONE, F_MINLOG|F_ALLOCATED, doltpmap},
{ "elvindport", FULLCONFIG_NONE, 0, doelvindport},
{ "plabeventkeys",FULLCONFIG_NONE, 0, doplabeventkeys},
{ "intfcmap", FULLCONFIG_NONE, 0, dointfcmap},
......@@ -6087,6 +6089,41 @@ COMMAND_PROTOTYPE(doltmap)
return 0;
}
/*
* Spit back the ltpmap. This is a backup for when NFS fails.
* We send back the gzipped version. Note that it is ok if this
* file does not exist.
*/
COMMAND_PROTOTYPE(doltpmap)
{
FILE *fp;
char buf[MYBUFSIZE];
int cc;
/*
* Open up the file on boss and spit it back.
*/
sprintf(buf, "%s/expwork/%s/%s/ltpmap.gz", TBROOT,
reqp->pid, reqp->eid);
if ((fp = fopen(buf, "r")) == NULL)
return 0;
while (1) {
cc = fread(buf, sizeof(char), sizeof(buf), fp);
if (cc == 0) {
if (ferror(fp)) {
fclose(fp);
return 1;
}
break;
}
client_writeback(sock, buf, cc, tcp);
}
fclose(fp);
return 0;
}
/*
* Return user environment.
*/
......
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