Commit 055b8769 authored by Leigh Stoller's avatar Leigh Stoller

Generate a info.xml file in the records/run directory that describes

the run. Includes the bindings for the run and the metadata name/value
pairs. This is the same data that is dumped by template export, so
at this point template_export has been completely superceded by the
CVS repo.
parent 3bbd843b
......@@ -1953,6 +1953,7 @@ sub vers($) { return field($_[0], 'parent_vers');}
sub pid($) { return field($_[0], 'pid'); }
sub eid($) { return field($_[0], 'eid'); }
sub uid($) { return field($_[0], 'uid'); }
sub uid_idx($) { return field($_[0], 'uid_idx'); }
sub runidx($) { return field($_[0], 'runidx'); }
sub start_time($) { return field($_[0], 'start_time'); }
sub stop_time($) { return field($_[0], 'stop_time'); }
......@@ -2242,6 +2243,7 @@ sub Experiment($)
return Experiment->LookupByIndex($self->exptidx());
}
sub GetExperiment($) { return $_[0]->Experiment(); }
sub GetTemplate($) { return $_[0]->template(); }
#
# Delete a template instance record.
......
......@@ -107,6 +107,7 @@ sub sighandler($);
sub SignalProgAgents($);
sub SendCompletionEvent();
sub CheckForDeadNodes($);
sub GenXML($$);
#
# Testbed Support libraries
......@@ -521,14 +522,20 @@ if (defined($instance->runidx())) {
my $tmpdir = "$projroot/$pid/templates/$guid/cvstmp.$$";
my $tag = "R${exptidx}-${runidx}_import";
my $instance_tag = "I${exptidx}";
my $xmlfile = "$instance_dir/info.xml";
fatal(-1, "Could not generate XML description for $oldrun")
if (GenXML($instance, $xmlfile) != 0);
# This imports the experiment directory into the records subdir.
System("cd $instance_dir; ".
"$CVSBIN -d $cvsdir import -I 'datastore/*' ".
"$CVSBIN -d $cvsdir import -I 'datastore' ".
" -m 'Import record for run $this_runid' ".
" $guid/records/$exptidx,$runidx ${tag}_branch $tag")
== 0 or fatal(-1, "Could not import new record into $cvsdir");
unlink($xmlfile);
# Now tag it with the same tag that was applied for the instance.
# Apply to the branch tag directly instead of symbolically since that
# does not work properly for some reason.
......@@ -1075,6 +1082,92 @@ sub CheckForDeadNodes($)
}
}
#
# Generate an XML file describing the just finished run.
#
sub GenXML($$)
{
my ($instance, $outputfile) = @_;
my $root = {};
my $template = $instance->GetTemplate();
my $run = $instance->CurrentRun();
my %bindings;
my %mlist;
$root->{"infoversion"}= "1.0";
$root->{"guid"} = $instance->guid() . "/" . $instance->vers();
$root->{"pid"} = $template->pid();
$root->{"pid_idx"} = $template->pid_idx();
$root->{"eid"} = $instance->eid();
$root->{"exptidx"} = $instance->exptidx();
$root->{"uid"} = $instance->uid();
$root->{"uid_idx"} = $instance->uid_idx();
$root->{"runid"} = $run->runid();
$root->{"run_idx"} = $run->idx();
$root->{"start_time"} = $run->start_time();
$root->{"stop_time"} = $run->stop_time();
# Fill in the bindings
$run->BindingList(\%bindings) == 0
or fatal(-1, "Could not get bindings for $run");
if (keys(%bindings)) {
$root->{"bindings"} = {};
foreach my $name (keys(%bindings)) {
my $value = $bindings{$name};
my $description;
$template->FormalParameterDescription($name, \$description);
$root->{"bindings"}->{$name} = {'value' => $value,
'description' => $description};
}
}
# Fill in the metadata
$template->MetadataList(\%mlist) == 0
or fatal(-1, "Could not get Metadata list for $instance");
if (keys(%mlist)) {
$root->{"metadata"} = {};
foreach my $name (keys(%mlist)) {
my $value = $mlist{$name};
$root->{"metadata"}->{$name} = $value;
}
}
if ($debug) {
print Dumper($root);
print "\n";
}
my %xmloptions = ('RootName' => 'run',
'XMLDecl' => 1,
'SuppressEmpty' => undef,
'NoAttr' => 1);
my $xml = XMLout($root, %xmloptions);
if ($debug) {
print "$xml\n";
$root = XMLin($xml, KeyAttr => "name",
"ForceArray" => ["metadata", "runs", "bindings"]);
print Dumper($root);
print "\n";
}
unlink($outputfile)
if (-e $outputfile);
if (open(DUMP, ">$outputfile")) {
print DUMP "$xml\n";
close(DUMP);
}
else {
print STDERR "*** Could not open $outputfile for writing";
return -1;
}
return 0;
}
END {
# Normal exit, nothing to do.
return
......
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