Commit 6a0a1eb7 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Commit the current archive support. Currently exposed to only

studly users in the testbed project on the mainsite.
parent 17ef9b1b
......@@ -3135,7 +3135,7 @@ sub TBExptDestroy($$)
unlink($eidlink)
if (-l $eidlink);
}
#libArchive::TBDeleteExperimentArchive($pid, $eid);
libArchive::TBDeleteExperimentArchive($pid, $eid);
#
# Remove all trace from the DB.
......
......@@ -55,8 +55,8 @@ LIB_STUFF = libtbsetup.pm exitonwarn.pm libtestbed.pm snmpit_intel.pm \
snmpit_foundry.pm snmpit_stack.pm snmpit_remote.pm \
snmpit_nortel.pm \
libaudit.pm libreboot.pm libosload.pm libtestbed.py \
libadminmfs.pm libtblog.pm \
power_mail.pm power_whol.pm
libadminmfs.pm libtblog.pm libArchive.pm \
power_mail.pm power_whol.pm
#
# Force dependencies on the scripts so that they will be rerun through
......
......@@ -85,6 +85,7 @@ use lib "@prefix@/lib";
use libdb;
use libtestbed;
use libtblog;
use libArchive;
my $parser = "$TB/libexec/parse-ns";
my $mkexpdir = "$TB/libexec/mkexpdir";
......@@ -386,6 +387,10 @@ if (system("$mkexpdir $pid $gid $eid") != 0) {
fatal("$mkexpdir failed");
}
if (libArchive::TBCreateExperimentArchive($pid, $eid) < 0) {
fatal("Could not create experiment archive!");
}
#
# Grab the working directory path, and thats where we work.
# The user's experiment directory is off in /proj space.
......@@ -571,6 +576,19 @@ if (system("$tbbindir/tbprerun $zeeopt $pid $eid $nsfile") != 0) {
SetExpState($pid, $eid, EXPTSTATE_SWAPPED)
or fatal("Failed to set experiment state to " . EXPTSTATE_SWAPPED());
#
# Lets get the NS file into the archive now, since we want to quit before
# going further if it fails. Note that any NS files the experiment sourced
# were added by the parse wrapper.
#
system("cp -p $workdir/$nsfile $userdir/$nsfile");
if ($? != 0 ||
(libArchive::TBExperimentArchiveAddFile($pid, $eid,
"$userdir/$nsfile") < 0)) {
fatal("Failed to add $userdir/$nsfile to the archive!");
}
#
# If not in frontend mode (preload only) continue to swapping exp in.
#
......@@ -625,6 +643,13 @@ TBSaveExpLogFiles($pid, $eid);
#
system("cp -Rfp $workdir/ $userdir/tbdata");
#
# Do a SavePoint on the experiment files.
#
if (libArchive::TBExperimentArchiveSavePoint($pid, $eid, "startexp") < 0) {
fatal("Failed to do a savepoint on the experiment archive!");
}
#
# Gather statistics.
#
......@@ -742,6 +767,9 @@ sub cleanup()
#
TBExptDestroy($pid, $eid);
# Completely remove all trace of the archive.
libArchive::TBDestroyExperimentArchive($pid, $eid);
#
# Now we can clean up the stats records.
#
......
......@@ -78,6 +78,7 @@ my $TBLOGS = "@TBLOGSEMAIL@";
use lib "@prefix@/lib";
use libdb;
use libtestbed;
use libArchive;
# Be careful not to exit on transient error; 0 means infinite retry.
$libdb::DBQUERY_MAXTRIES = 0;
......@@ -447,13 +448,24 @@ if ($estate eq EXPTSTATE_ACTIVE) {
}
SetExpState($pid, $eid, EXPTSTATE_TERMINATING);
$estate = EXPTSTATE_SWAPPED;
#
# Gather statistics for the swapout.
#
GatherSwapStats($pid, $eid, $dbuid, TBDB_STATS_SWAPOUT, 0);
# Do a SavePoint on the experiment files.
print "Doing a savepoint to the experiment archive ...\n";
if (libArchive::TBExperimentArchiveSavePoint($pid, $eid, "swapout") < 0) {
fatal("Failed to do a savepoint on the experiment archive!");
}
}
# Commit the archive after swapout.
print "Doing a final commit on the experiment archive ...\n";
libArchive::TBCommitExperimentArchive($pid, $eid, "endexp") == 0 or
fatal("Could not commit experiment archive!");
if ($estate eq EXPTSTATE_SWAPPED ||
$estate eq EXPTSTATE_QUEUED) {
GatherSwapStats($pid, $eid, $dbuid, TBDB_STATS_TERMINATE, 0,
......@@ -483,6 +495,14 @@ if ($estate ne EXPTSTATE_TERMINATED) {
#
TBSaveExpLogFiles($pid, $eid);
# Copy out the archive and then delete it.
print "Archiving and clearing the experiment archive ...\n";
libArchive::TBArchiveExperimentArchive($pid, $eid) == 0 or
fatal("Could not archive experiment archive!");
libArchive::TBDeleteExperimentArchive($pid, $eid) == 0 or
fatal("Could not delete experiment archive!");
# Terminate the log so the web page stops spewing.
TBExptClearLogFile($pid, $eid);
......
......@@ -60,6 +60,7 @@ use libreboot;
use libosload;
use libtestbed;
use libtblog;
use libArchive;
TBDebugTimeStampsOn();
......@@ -307,6 +308,8 @@ while (my %row = $db_result->fetchhash()) {
if (! -f $rpm) {
die_noretry("*** RPM $rpm for node $node does not exist!");
}
libArchive::TBExperimentArchiveAddFile($pid, $eid, $rpm) == 0 or
die_noretry("*** Failed to add RPM $rpm to the archive!");
}
#
......@@ -318,6 +321,8 @@ while (my %row = $db_result->fetchhash()) {
if (! -f $tar) {
die_noretry("*** Tarfile $tar for node $node does not exist!");
}
libArchive::TBExperimentArchiveAddFile($pid, $eid, $tar) == 0 or
die_noretry("*** Failed to add Tarfile $tar to the archive!");
}
#
......
......@@ -79,6 +79,7 @@ use lib "@prefix@/lib";
use libdb;
use libtestbed;
use libtblog;
use libArchive;
# Be careful not to exit on transient error; 0 means infinite retry.
$libdb::DBQUERY_MAXTRIES = 0;
......@@ -111,6 +112,7 @@ my $user_email;
my @allnodes;
my @row;
my $action;
my $tag;
my $nextswapstate;
my $termswapstate;
my $isadmin = 0;
......@@ -690,15 +692,18 @@ DBQueryFatal("unlock tables");
if ($inout eq "in") {
$action = "swapped in";
$tag = "swapin";
}
if ($inout eq "out") {
$action = "swapped out";
$tag = "swapout";
}
if ($inout eq "restart") {
$action = "restarted";
}
if ($inout eq "modify") {
$action = "modified";
$tag = "swapmod";
}
#
......@@ -867,6 +872,13 @@ elsif ($inout eq "in") {
elsif ($inout eq "modify") {
my $modifyError;
#
# Prepare the Archive for the swapmod, in case we have to "roll back".
#
if (libArchive::TBExperimentArchivePreSwapMod($pid, $eid) < 0) {
fatal("Failed to do a preswapmod on the experiment archive!");
}
GatherSwapStats($pid, $eid, $dbuid,
TBDB_STATS_SWAPMODIFY, 0, TBDB_STATS_FLAGS_PREMODIFY);
......@@ -1038,6 +1050,39 @@ TBSaveExpLogFiles($pid, $eid);
#
system("cp -Rfp $workdir/ $userdir/tbdata/");
#
# The archive gets different treatment when doing a swapmod.
#
if ($inout eq "modify") {
# Get the new NS file into the new swapdir.
if (defined($nsfile)) {
system("cp -p $workdir/$nsfile $userdir/$nsfile");
if (libArchive::TBExperimentArchiveAddFile($pid, $eid,
"$userdir/$nsfile") < 0) {
fatal("Failed to add $userdir/$nsfile to the archive!");
}
}
print "Doing a commit on the previous experiment archive ...\n";
libArchive::TBExperimentArchiveSwapModCommit($pid, $eid) == 0 or
fatal("Failed to commit experiment archive!");
}
#
# Do a SavePoint on the experiment files.
#
if (libArchive::TBExperimentArchiveSavePoint($pid, $eid, $tag) < 0) {
fatal("Failed to do a savepoint on the experiment archive!");
}
# Commit the archive after swapout
if ($inout eq "out") {
print "Doing a commit on the experiment archive ...\n";
libArchive::TBCommitExperimentArchive($pid, $eid, $tag) == 0 or
fatal("Failed to commit experiment archive!");
}
#
# Gather stats.
#
......@@ -1167,6 +1212,11 @@ sub cleanup()
# Clear backup state since not needed anymore; experiment is toast.
#
TBExptClearBackupState($pid, $eid);
#
# Rollback the archive.
#
libArchive::TBExperimentArchiveRollBack($pid, $eid);
}
#
......
......@@ -23,7 +23,7 @@ SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \
spewconlog
LIBEXEC_SCRIPTS = webcreateimage newnode webdeletenode spewleds webcopy \
websetdest spewsource weblinkmon_ctl webcvsweb \
webspewconlog xlogin
webspewconlog xlogin webviewvc
#
# Force dependencies on the scripts so that they will be rerun through
......
#!/usr/local/bin/python
# -*-python-*-
#
# Copyright (C) 1999-2002 The ViewCVS Group. All Rights Reserved.
#
# By using this file, you agree to the terms and conditions set forth in
# the LICENSE.html file which can be found at the top level of the ViewCVS
# distribution or at http://viewcvs.sourceforge.net/license-1.html.
#
# Contact information:
# Greg Stein, PO Box 760, Palo Alto, CA, 94302
# gstein@lyra.org, http://viewcvs.sourceforge.net/
#
LIBRARY_DIR = r"/usr/testbed/viewcvs-1.0/lib"
CONF_PATHNAME = r"/usr/testbed/viewcvs-1.0/viewcvs.conf"
#########################################################################
#
# Adjust sys.path to include our library directory
#
import sys
import os
import re
sys.path.insert(0, LIBRARY_DIR)
#
# We must get a -repo argument.
#
if len(sys.argv) != 3:
sys.exit(1)
pass
if sys.argv[1] != "-repo":
sys.exit(1)
pass
repodir = sys.argv[2]
# go do the work
import sapi
import viewcvs
viewcvs._legal_params['exptidx'] = viewcvs._re_validate_number
viewcvs._sticky_vars.append('exptidx')
viewcvs._legal_params['eid'] = re.compile('^[-_a-zA-Z0-9]+$')
viewcvs._sticky_vars.append('eid')
viewcvs._legal_params['pid'] = viewcvs._re_validate_number
viewcvs._sticky_vars.append('pid')
server = sapi.CgiServer()
cfg = viewcvs.load_config(CONF_PATHNAME, server)
cfg.general.default_root = 'svn'
cfg.general.svn_roots = {'svn' : repodir}
cfg.options.docroot = "/cvsweb/viewvc"
viewcvs.main(server, cfg)
......@@ -119,7 +119,7 @@ DOWNLOADFILES += $(wildcard $(SRCDIR)/downloads/*.exe)
#
# This stuff only gets installed on the main site
#
ifeq ($(OURDOMAIN),$(MAINSITE))
ifeq ($(CVSSUPPORT),1)
CVSWEBFILES = $(wildcard $(SRCDIR)/cvsweb/*.php3)
CVSWEBFILES += $(wildcard $(SRCDIR)/cvsweb/*.php)
CVSWEBFILES += $(wildcard $(SRCDIR)/cvsweb/*.conf)
......
......@@ -21,6 +21,9 @@ unset($repodir);
# Tell system we do not want any headers drawn on errors.
$noheaders = 1;
# Use cvsweb or viewvc.
$use_viewvc = 0;
#
# Verify form arguments.
#
......@@ -73,6 +76,7 @@ if (isset($pid) && $pid != "") {
}
$repoidx = $row[0];
$repodir = "/usr/testbed/exparchive/$repoidx/repo/";
$use_viewvc = 1;
}
else {
#
......@@ -136,6 +140,7 @@ elseif (isset($exptidx) && $exptidx != "") {
}
$repodir = "$TBDIR/expinfo/${pid}-${eid}.${exptidx}/Archive";
}
$use_viewvc = 1;
}
else {
LOGGEDINORDIE($uid);
......@@ -194,9 +199,11 @@ $shellcmd = "env PATH=./cvsweb/ QUERY_STRING=$query PATH_INFO=$path " .
"HTTP_ACCEPT_ENCODING=$encoding ";
if (isset($repodir)) {
$prog = ($use_viewvc ? webviewvc : webcvsweb);
# I know, I added an argument to a script that is not supposed to
# take any. So be it; it was easy.
$shellcmd .= "$TBSUEXEC_PATH $uid $pid webcvsweb -repo $repodir";
$shellcmd .= "$TBSUEXEC_PATH $uid $pid $prog -repo $repodir";
}
else {
$shellcmd .= "$script";
......
......@@ -32,6 +32,7 @@ $OPSCVSURL = "http://${USERNODE}/cvsweb/cvsweb.cgi";
$OPSJETIURL = "http://${USERNODE}/jabber/jeti.php";
$EXPOSELINKTEST = 0;
$EXPOSESTATESAVE= 0;
$EXPOSEARCHIVE = 0;
$TBMAILADDR_OPS = "@TBOPSEMAIL_NOSLASH@";
$TBMAILADDR_WWW = "@TBWWWEMAIL_NOSLASH@";
......
......@@ -240,6 +240,11 @@ if ($wireless) {
WRITESUBMENUBUTTON("Show History",
"showstats.php3?showby=expt&which=$expindex");
if ($EXPOSEARCHIVE) {
WRITESUBMENUBUTTON("Experiment File Archive",
"cvsweb/cvswebwrap.php3?exptidx=$expindex");
}
if ($types['garcia'] || $types['static-mica2'] || $types['robot']) {
SUBMENUSECTION("Robot/Mote Options");
WRITESUBMENUBUTTON("Robot/Mote Map",
......
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -164,7 +164,8 @@ else {
$query_result =
DBQueryFatal("select t.exptidx,s.pid,s.eid,t.action,t.exitcode,t.uid, ".
" r.pnodes,t.idx as statno,t.start_time,t.end_time ".
" r.pnodes,t.idx as statno,t.start_time,t.end_time, ".
" s.archive_idx,r.archive_tag ".
" from testbed_stats as t ".
"left join experiment_stats as s on s.exptidx=t.exptidx ".
"left join experiment_resources as r on r.idx=t.rsrcidx ".
......@@ -174,7 +175,6 @@ $query_result =
if (mysql_num_rows($query_result) == 0) {
USERERROR("No testbed stats records in the system!", 1);
}
echo "<table align=center border=1>
<tr>
<th>#</th>
......@@ -185,8 +185,11 @@ echo "<table align=center border=1>
<th>Start</th>
<th>End</th>
<th>Action (Nodes)</th>
<th>ECode</th>
</tr>\n";
<th>ECode</th>";
if ($EXPOSEARCHIVE) {
echo "<th>Archive</th>";
}
echo " </tr>\n";
while ($row = mysql_fetch_assoc($query_result)) {
$idx = $row[statno];
......@@ -199,6 +202,8 @@ while ($row = mysql_fetch_assoc($query_result)) {
$action = $row[action];
$ecode = $row[exitcode];
$pnodes = $row[pnodes];
$archive_idx = $row[archive_idx];
$archive_tag = $row[archive_tag];
if (!isset($end))
$end = "&nbsp";
......@@ -218,8 +223,21 @@ while ($row = mysql_fetch_assoc($query_result)) {
else {
echo "<td>$action</td>\n";
}
echo " <td>$ecode</td>
</tr>\n";
echo " <td>$ecode</td>\n";
if ($EXPOSEARCHIVE) {
if ($archive_idx && $archive_tag &&
(strcmp($action, "swapout") == 0 ||
strcmp($action, "swapmod") == 0)) {
echo "<td>".
"<a href='cvsweb/cvswebwrap.php3/$exptidx/history/".
"$archive_tag/?exptidx=$exptidx'>$archive_tag</a>".
"</td>\n";
}
else {
echo "<td>&nbsp</td>\n";
}
}
echo "</tr>\n";
}
echo "</table>\n";
......
......@@ -130,6 +130,7 @@ function CHECKLOGIN($uid) {
global $TBAUTHCOOKIE, $TBLOGINCOOKIE, $HTTP_COOKIE_VARS, $TBAUTHTIMEOUT;
global $CHECKLOGIN_STATUS, $CHECKLOGIN_UID, $CHECKLOGIN_NODETYPES;
global $CHECKLOGIN_WIKINAME, $TBOPSPID;
global $EXPOSEARCHIVE;
global $nocookieauth;
#
# If we already figured this out, do not duplicate work!
......@@ -331,7 +332,10 @@ function CHECKLOGIN($uid) {
if ($admin && !$adminoff) {
putenv("HTTP_WITH_TB_ADMIN_PRIVS=1");
}
# XXX Temporary.
if ($stud) {
$EXPOSEARCHIVE = 1;
}
return $CHECKLOGIN_STATUS;
}
......
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