Commit 544db994 authored by Leigh Stoller's avatar Leigh Stoller

More archive support cleanup. Been messing with the NFS tracing code

but that stuff is still not totally hooked in yet.
parent e8683096
......@@ -72,7 +72,7 @@ if (@ARGV < 3) {
usage();
}
if (defined($options{"d"})) {
$debug = 1;
$debug = 2;
}
if (defined($options{"f"})) {
$force = 1;
......@@ -115,17 +115,8 @@ if (! TBExptAccessCheck($UID, $pid, $eid, TB_EXPT_UPDATE)) {
fatal("You do not have permission to control the archive for $pid/$eid!");
}
#
# Do not allow an archive system to be controlled if the experiment is not
# active or swapped. Will probably be changed later.
#
if ($expstate ne EXPTSTATE_ACTIVE &&
$expstate ne EXPTSTATE_SWAPPED) {
fatal("Experiment $pid/$eid must be active or swapped!");
}
# Temporary
libArchive::setdebug(2);
libArchive::setdebug($debug);
# Do not audit this operation.
if ($action eq "checktag") {
......@@ -146,6 +137,15 @@ if ($action eq "checktag") {
exit(($unique ? 0 : 1));
}
#
# Do not allow an archive system to be controlled if the experiment is not
# active or swapped. Will probably be changed later.
#
if ($expstate ne EXPTSTATE_ACTIVE &&
$expstate ne EXPTSTATE_SWAPPED) {
fatal("Experiment $pid/$eid must be active or swapped!");
}
#
# Allow the user to force a commit of the archive.
#
......@@ -187,7 +187,7 @@ if ($action eq "commit") {
}
}
if ($NFSTRACESUPPORT) {
if (0 && $NFSTRACESUPPORT) {
#
# This program asks the nodes for the trace results.
#
......@@ -357,6 +357,8 @@ elsif ($action eq "list" ||
"LEFT JOIN accessed_files as af on af.idx=fr.fileidx ".
"WHERE fr.rsrcidx=$rsrcidx and fr.type!='l'");
while (my ($fn) = $query_result->fetchrow_array()) {
#print "Accessed: $fn\n";
if ($fn =~ /^\/share/ ||
$fn =~ /\/tbdata\// ||
$fn =~ /^<u:/) {
......
......@@ -995,10 +995,10 @@ sub ArchiveCheckout($$;$$$)
# I intend this to be run only when an experiment is terminated.
# No need to have two copies.
#
sub ArchiveArchive($$)
sub ArchiveArchive($)
{
my ($archive_idx, $dirpath) = @_;
my $target = "$dirpath/Archive";
my ($archive_idx) = @_;
my $target = "$ARCHIVEDIR/Archive/$archive_idx";
#
# See if the archive exists and if it does, get the pathname to it.
......@@ -1052,7 +1052,6 @@ sub ArchiveArchive($$)
return -1;
}
}
#
# Tar up the whole thing and move it across.
#
......@@ -1978,7 +1977,7 @@ sub TBArchiveExperimentArchive($$)
return -1
if ($rval < 0);
return ArchiveArchive($archive_idx, TBExptLogDir($pid, $eid));
return ArchiveArchive($archive_idx);
}
#
......@@ -2097,9 +2096,11 @@ sub TBIsTaqUnique($$$$)
#
sub TBListExperimentArchive($$$;$$)
{
my ($pid, $eid, $prval, $tag, $subdir) = @_;
my ($pid, $eid, $prval, $tag, $root, $subdir) = @_;
my ($archive_idx, $view);
my @filelist = ();
my $sourcepoint = "";
my $expstate = ExpState($pid, $eid);
@$prval = @filelist;
return 0
......@@ -2111,7 +2112,16 @@ sub TBListExperimentArchive($$$;$$)
return -1
if ($rval < 0);
my $sourcepoint = (defined($tag) ? "tags/$tag" : "trunk");
# If the experiment is active, use the savepoint.
if (defined($tag)) {
$sourcepoint = "tags/$tag";
}
elsif ($expstate && $expstate eq EXPTSTATE_ACTIVE()) {
$sourcepoint = "savepoint";
}
else {
$sourcepoint = "trunk";
}
$sourcepoint = "$sourcepoint/$subdir"
if (defined($subdir));
......
......@@ -16,34 +16,32 @@ $isadmin = ISADMIN($uid);
#
# Verify page arguments.
#
if (!isset($pid) ||
strcmp($pid, "") == 0) {
USERERROR("You must provide a Project ID.", 1);
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
USERERROR("You must provide an Experiment ID.", 1);
}
if (!TBvalid_pid($pid)) {
PAGEARGERROR("Invalid project ID.");
#
# An experiment idx.
if (! isset($exptidx) || $exptidx == "") {
USERERROR("Must supply an experiment index!", 1);
}
if (!TBvalid_eid($eid)) {
PAGEARGERROR("Invalid experiment ID.");
if (!TBvalid_integer($exptidx)) {
USERERROR("Invalid characters in $exptidx!", 1);
}
$exptidx = TBExptIndex($pid, $eid);
if ($exptidx < 0) {
TBERROR("Could not map $pid/$eid to ID!", 1);
#
# We get an index. Must map that to a pid/gid to do a group level permission
# check, since it might not be an current experiment.
#
unset($pid);
unset($eid);
unset($gid);
if (TBExptidx2PidEid($exptidx, $pid, $eid, $gid) < 0) {
USERERROR("No such experiment index $exptidx!", 1);
}
if (!TBExptGroup($pid, $eid, $gid)) {
TBERROR("Could not get experiment gid for $pid/$eid!", 1);
if (!TBCurrentExperiment($exptidx)) {
USERERROR("Experiment index $exptidx is not a current experiment!", 1);
}
if (!$isadmin) {
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to view missing files for ".
"experiment $pid/$eid!", 1);
}
if (!$isadmin &&
!TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_READINFO)) {
USERERROR("You do not have permission to view missing files for ".
"archive in $pid/$gid ($exptidx)!", 1);
}
#
......@@ -65,7 +63,7 @@ if (isset($movesome)) {
"webarchive_control addtoarchive $pid $eid $fileargs",
SUEXEC_ACTION_DUPDIE);
header("Location: archive_missing.php3?pid=$pid&eid=$eid");
header("Location: archive_missing.php3?exptidx=$exptidx");
return;
}
......@@ -131,7 +129,7 @@ if (count($suexec_output_array)) {
echo "</b><br><br>";
echo "<table border=1>\n";
echo "<form action='archive_missing.php3?pid=$pid&eid=$eid'
echo "<form action='archive_missing.php3?exptidx=$exptidx'
onsubmit=\"return false;\"
name=form1 method=post>\n";
echo "<input type=hidden name=movesome value=Submit>\n";
......
......@@ -16,30 +16,42 @@ $isadmin = ISADMIN($uid);
#
# Verify page arguments.
#
if (!isset($pid) ||
strcmp($pid, "") == 0) {
USERERROR("You must provide a Project ID.", 1);
#
if (! isset($exptidx) || $exptidx == "") {
USERERROR("Must supply an experiment to view!", 1);
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
USERERROR("You must provide an Experiment ID.", 1);
if (!TBvalid_integer($exptidx)) {
USERERROR("Invalid characters in $exptidx!", 1);
}
if (!TBvalid_pid($pid)) {
PAGEARGERROR("Invalid project ID.");
#
# We get an index. Must map that to a pid/gid to do a group level permission
# check, since it might not be an current experiment.
#
unset($pid);
unset($eid);
unset($gid);
if (TBExptidx2PidEid($exptidx, $pid, $eid, $gid) < 0) {
USERERROR("No such experiment index $exptidx!", 1);
}
if (!TBvalid_eid($eid)) {
PAGEARGERROR("Invalid experiment ID.");
if (!$isadmin &&
!TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_READINFO)) {
USERERROR("You do not have permission to view tags for ".
"archive in $pid/$gid ($exptidx)!", 1);
}
if (!TBCurrentExperiment($exptidx)) {
USERERROR("Experiment index $exptidx is not a current experiment!", 1);
}
function SPITFORM($formfields, $errors)
{
global $isadmin, $pid, $eid, $TBDB_ARCHIVE_TAGLEN;
global $isadmin, $exptidx, $TBDB_ARCHIVE_TAGLEN;
#
# Standard Testbed Header
#
PAGEHEADER("Commit/Tag archive for experiment $pid/$eid");
PAGEHEADER("Commit/Tag archive for experiment $exptidx");
echo "<center>
Commit/Tag Archive
......@@ -68,7 +80,7 @@ function SPITFORM($formfields, $errors)
}
echo "<table align=center border=1>
<form action=archive_tag.php3?pid=$pid&eid=$eid method=post>\n";
<form action=archive_tag.php3?exptidx=$exptidx method=post>\n";
echo "<tr>
<td align=center>
......@@ -196,10 +208,6 @@ if (count($errors)) {
return;
}
if (!TBExptGroup($pid, $eid, $gid)) {
TBERROR("Could not get experiment gid for $pid/$eid!", 1);
}
#
# First lets make sure the tag is unique.
#
......@@ -226,5 +234,5 @@ SUEXEC($uid, "$pid,$gid",
"webarchive_control $tagarg $message commit $pid $eid",
SUEXEC_ACTION_DIE);
header("Location: archive_view.php3?pid=$pid&eid=$eid");
header("Location: archive_view.php3/$exptidx/?exptidx=$exptidx");
?>
......@@ -24,53 +24,58 @@ if (!isset($records) || !strcmp($records, "")) {
$records = 100;
}
if (! isset($which) || $which == "") {
USERERROR("Must supply an experiment to view!", 1);
# An experiment idx.
if (! isset($exptidx) || $exptidx == "") {
USERERROR("Must supply an experiment index!", 1);
}
if (!TBvalid_integer($which)) {
USERERROR("Invalid characters in $which!", 1);
if (!TBvalid_integer($exptidx)) {
USERERROR("Invalid characters in $exptidx!", 1);
}
#
# We get an index. Must map that to a pid/eid to do the permission
# check, and note that it might not be an current experiment. Not
# sure I like this so I am not going to permit it for mere users
# just yet.
# We get an index. Must map that to a pid/gid to do a group level permission
# check, since it might not be an current experiment.
#
$query_result =
DBQueryFatal("select pid,eid from experiments where idx='$which'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("No such experiment index $which!", 1);
unset($pid);
unset($eid);
unset($gid);
if (TBExptidx2PidEid($exptidx, $pid, $eid, $gid) < 0) {
USERERROR("No such experiment index $exptidx!", 1);
}
$row = mysql_fetch_array($query_result);
$pid = $row["pid"];
$eid = $row["eid"];
if (!$isadmin) {
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to view tags for ".
"experiment $pid/$eid ($which)!", 1);
}
if (!$isadmin &&
!TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_READINFO)) {
USERERROR("You do not have permission to view tags for ".
"archive in $pid/$gid ($exptidx)!", 1);
}
if (TBCurrentExperiment($exptidx)) {
echo "<center><font size=+1>".
"Experiment <b>".
"<a href='showproject.php3?pid=$pid'>$pid</a>/".
"<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a> ".
"(<a href='showstats.php3?showby=expt&exptidx=$exptidx'>$exptidx</a>) ".
"</b></font>\n";
"</center><br>";
}
else {
echo "<center><font size=+1>".
"Experiment ".
"<a href='showstats.php3?showby=expt&exptidx=$exptidx'>$exptidx</a> ".
"</b></font>\n";
"</center><br>";
}
echo "<center><font size=+1>".
"Experiment <b>".
"<a href='showproject.php3?pid=$pid'>$pid</a>/".
"<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a> ".
"(<a href='showstats.php3?showby=expt&which=$which'>$which</a>) ".
"</b></font>\n";
"</center><br>";
echo "<br>\n";
#
# We need the archive index so we can find its view.
#
$query_result =
DBQueryFatal("select s.archive_idx from experiments as e ".
"left join experiment_stats as s on s.exptidx=e.idx ".
"where e.pid='$pid' and e.eid='$eid'");
DBQueryFatal("select s.archive_idx from experiment_stats as s ".
"where s.exptidx='$exptidx'");
if (mysql_num_rows($query_result) == 0) {
TBERROR("Could not get archive index for experiment $pid/$eid", 1);
TBERROR("Could not get archive index for experiment $exptidx", 1);
}
$row = mysql_fetch_array($query_result);
$archive_idx = $row["archive_idx"];
......@@ -79,9 +84,11 @@ $archive_idx = $row["archive_idx"];
# Grab all the (commit/user) tags.
#
$query_result =
DBQueryFatal("select * from archive_tags ".
"where archive_idx='$archive_idx' and view='$which' and ".
" (tagtype='user' or tagtype='commit')");
DBQueryFatal("select *,FROM_UNIXTIME(date_created) as date_created ".
" from archive_tags ".
"where archive_idx='$archive_idx' and view='$exptidx' and ".
" (tagtype='user' or tagtype='commit') ".
"order by date_created desc");
if (mysql_num_rows($query_result) == 0) {
USERERROR("No tags for experiment $pid/$eid", 1);
......@@ -90,7 +97,7 @@ if (mysql_num_rows($query_result) == 0) {
echo "<table align=center border=1>
<tr>";
echo " <th>Run</th>";
echo " <th>Tag</th>";
echo " <th>Tag (Click to visit archive)</th>";
echo " <th>Date</th>";
echo " <th>Description</th>";
echo "</tr>\n";
......@@ -102,11 +109,11 @@ while ($row = mysql_fetch_assoc($query_result)) {
echo "<tr>";
echo " <td align=center>
<a href=beginexp_html.php3?copyid=$which:$archive_tag>
<a href=beginexp_html.php3?copyid=$exptidx:$archive_tag>
<img border=0 alt=Run src=greenball.gif></a></td>";
echo " <td>".
"<a href='cvsweb/cvswebwrap.php3/$which/history/".
"$archive_tag/?exptidx=$which'>$archive_tag</a>".
"<a href='archive_view.php3/$exptidx/history/".
"$archive_tag/?exptidx=$exptidx'>$archive_tag</a>".
" </td>";
echo " <td>$date_tagged</td>";
......
......@@ -15,81 +15,72 @@ LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# Verify page arguments.
# Standard Testbed Header.
#
if (isset($exptidx) && $exptidx != "") {
if (!TBvalid_integer($exptidx)) {
PAGEARGERROR("Invalid experiment index.");
}
PAGEHEADER("Experiment Archive ($exptidx)");
PAGEHEADER("Experiment Archive ($exptidx)");
unset($pid);
unset($eid);
unset($gid);
TBExptidx2PidEid($exptidx, $pid, $eid, $gid);
#
# Verify page arguments.
#
if (! isset($exptidx) || $exptidx == "") {
USERERROR("Must supply an experiment to view!", 1);
}
if (!TBvalid_integer($exptidx)) {
USERERROR("Invalid characters in $exptidx!", 1);
}
$url = preg_replace("/archive_view/", "cvsweb/cvsweb",
$_SERVER['REQUEST_URI']);
#
# We get an index. Must map that to a pid/gid to do a group level permission
# check, since it might not be an current experiment.
#
unset($pid);
unset($eid);
unset($gid);
if (TBExptidx2PidEid($exptidx, $pid, $eid, $gid) < 0) {
USERERROR("No such experiment index $exptidx!", 1);
}
else {
if (!isset($pid) ||
strcmp($pid, "") == 0) {
USERERROR("You must provide a Project ID.", 1);
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
USERERROR("You must provide an Experiment ID.", 1);
}
if (!TBvalid_pid($pid)) {
PAGEARGERROR("Invalid project ID.");
}
if (!TBvalid_eid($eid)) {
PAGEARGERROR("Invalid experiment ID.");
}
#
# Check to make sure this is a valid PID/EID tuple.
#
if (! TBValidExperiment($pid, $eid)) {
USERERROR("The experiment $eid is not a valid experiment ".
"in project $pid.", 1);
}
$exptidx = TBExptIndex($pid, $eid);
if ($exptidx < 0) {
TBERROR("Could not get experiment index for $pid/$eid!", 1);
}
PAGEHEADER("Experiment Archive ($pid/$eid)");
$url = "cvsweb/cvsweb.php3/${exptidx}?exptidx=$exptidx";
if (!$isadmin &&
!TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_READINFO)) {
USERERROR("You do not have permission to view tags for ".
"archive in $pid/$gid ($exptidx)!", 1);
}
$current = TBCurrentExperiment($exptidx);
$url = preg_replace("/archive_view/", "cvsweb/cvsweb",
$_SERVER['REQUEST_URI']);
# This is how you get forms to align side by side across the page.
$style = 'style="float:left; width:33%;"';
if ($current) {
$style = 'style="float:left; width:33%;"';
}
else {
$style = "";
}
echo "<center>\n";
echo "<font size=+1>
This is the Subversion archive for your experiment.<br></font>";
if (isset($pid)) {
This is the Subversion archive for experiment $exptidx.<br></font>";
if ($current) {
echo "<form action='${TBBASE}/archive_tag.php3' $style method=get>\n";
echo "<b><input type=submit name=tag value='Tag Archive'></b>";
echo "<input type=hidden name=pid value='$pid'>";
echo "<input type=hidden name=eid value='$eid'>";
echo "<input type=hidden name=exptidx value='$exptidx'>";
echo "</form>";
}
echo "<form action='${TBBASE}/archive_tags.php3' $style method=get>";
echo "<b><input type=submit name=tag value='Show Tags'></b>";
echo "<input type=hidden name=which value='$exptidx'>";
echo "<input type=hidden name=exptidx value='$exptidx'>";
echo "</form>";
if (isset($pid)) {
echo "<form action='${TBBASE}/archive_missing.php3' $style method=get>";
echo "<b><input type=submit name=missing value='Show Missing Files'></b>";
echo "<input type=hidden name=pid value='$pid'>";
echo "<input type=hidden name=eid value='$eid'>";
echo "</form>";
if ($current) {
echo "<form action='${TBBASE}/archive_missing.php3' $style method=get>";
echo "<b><input type=submit name=missing value='Show Missing Files'></b>";
echo "<input type=hidden name=exptidx value='$exptidx'>";
echo "</form>";
}
echo "</center>\n";
echo "</center><br>\n";
echo "<iframe width=100% height=800 scrolling=yes src='$url' border=2>".
"</iframe>\n";
......
......@@ -141,7 +141,7 @@ elseif (isset($exptidx) && $exptidx != "") {
if (! ISADMIN($uid)) {
USERERROR("Must be administrator to view historical archives!", 1);
}
$repodir = "$TBDIR/expinfo/${pid}-${eid}.${exptidx}/Archive/repo";
$repodir = "/usr/testbed/exparchive/Archive/$repoidx/repo/";
}
$use_viewvc = 1;
}
......
......@@ -1140,6 +1140,19 @@ function TBValidExperiment($pid, $eid)
return 1;
}
function TBCurrentExperiment($exptidx)
{
$exptidx = addslashes($exptidx);
$query_result =
DBQueryFatal("select eid from experiments where idx='$exptidx'");
if (mysql_num_rows($query_result) == 0) {
return 0;
}
return 1;
}
#
# Confirm a valid node name.
#
......@@ -1365,8 +1378,8 @@ function TBExptIndex($pid, $eid)
function TBExptidx2PidEid($exptidx, &$pid, &$eid, &$gid)
{
$query_result =
DBQueryFatal("select pid,eid,gid from experiments ".
"where idx='$exptidx'");
DBQueryFatal("select pid,eid,gid from experiment_stats ".
"where exptidx='$exptidx'");
if (mysql_num_rows($query_result) == 0) {
return -1;
......
......@@ -304,7 +304,7 @@ if (!$instance && STUDLY()) {
if ($EXPOSEARCHIVE) {
WRITESUBMENUBUTTON("Experiment File Archive",
"archive_view.php3?pid=$exp_pid&eid=$exp_eid");
"archive_view.php3?exptidx=$expindex");
}
if ($types['garcia'] || $types['static-mica2'] || $types['robot']) {
......
......@@ -19,6 +19,7 @@ $pid = "";
$eid = "";
$gid = "";
$template = NULL;
$exptidx = 0;
function CheckArguments($guid, $version) {
global $TB_EXPT_READINFO;
......@@ -53,7 +54,8 @@ function CheckArguments($guid, $version) {
$pid = $template->pid();
$gid = $template->gid();
$eid = $template->eid();
$exptidx = TBExptIndex($pid, $eid);
#
# Verify Permission.
#
......@@ -131,7 +133,7 @@ WRITESUBMENUBUTTON("Add Metadata",
"guid=$guid&version=$version");
WRITESUBMENUBUTTON("Template Archive",
"archive_view.php3?pid=$pid&eid=$eid");
"archive_view.php3?exptidx=$exptidx");
WRITESUBMENUBUTTON("Template History",
"template_history.php?guid=$guid&version=$version");
......
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