Commit 2e2bfc84 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Fix up how globbing was done; use internal globbing instead of shell

globbing since that was not working properly (not sure why, but this
is more efficient anyway.

Add backup routine to back up failed template swapins to .$eid-failed.
parent c00784eb
......@@ -20,6 +20,7 @@ use libtestbed;
use libtblog;
use English;
use Data::Dumper;
use File::Basename;
use overload ('""' => 'Stringify');
# Configure variables
......@@ -971,9 +972,9 @@ sub SaveLogFiles($)
# What the hell is this file! Very annoying.
if (-e "$workdir/.rnd") {
system("/bin/rm -f $workdir/.rnd");
mysystem("/bin/rm -f $workdir/.rnd");
}
system("/bin/cp -Rpf $workdir/ $logdir");
mysystem("/bin/cp -Rpf $workdir/ $logdir");
return 0;
}
......@@ -989,15 +990,21 @@ sub CleanLogFiles($)
if (! ref($self));
my $workdir = $self->WorkDir();
my $files = "";
foreach my $ext ("log", "ptop", "top", "assign") {
$files = "$files $workdir/*.${ext}";
}
foreach my $prefix ("swap", "start", "cancel", "newrun") {
$files = "$files $workdir/${prefix}*.*";
opendir(DIR, $workdir) or
return -1;
my @files = readdir(DIR);
my @delete = ();
closedir(DIR);
foreach my $file (@files) {
push(@delete, "${workdir}/$1")
if ($file =~ /^(.*\.(log|ptop|top|assign))$/);
push(@delete, "${workdir}/$1")
if ($file =~ /^((swap|start|cancel|newrun).*\..*)$/);
}
system("/bin/rm -f $files") == 0
mysystem("/bin/rm -f @delete") == 0
or return -1;
return 0;
......@@ -1019,7 +1026,41 @@ sub CopyLogFiles($)
my $workdir = $self->WorkDir();
my $userdir = $self->UserDir();
system("/bin/cp -Rfp $workdir/*.{log,ns,report,png} $userdir/tbdata");
opendir(DIR, $workdir) or
return -1;
my @files = readdir(DIR);
closedir(DIR);
my @copy = ();
foreach my $file (@files) {
push(@copy, "${workdir}/$1")
if ($file =~ /^(.*\.(log|report|ns|png))$/);
}
mysystem("/bin/cp -fp @copy $userdir/tbdata");
return 0;
}
#
# Backup the user directory for debugging.
#
sub BackupUserData($)
{
my ($self) = @_;
# Must be a real reference.
return -1
if (! ref($self));
my $userdir = $self->UserDir();
my $path = dirname($userdir);
my $dir = basename($userdir);
my $backup = "${path}/.${dir}-failed";
if (-e $backup) {
mysystem("/bin/rm -rf $backup");
}
mysystem("/bin/mv $userdir $backup");
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