Commit 50d8b5e8 authored by Leigh Stoller's avatar Leigh Stoller

Copy parameters and bindings to the virt_user_environment table so that

they are available to the program agent when it starts. I copy the values
at swapin and at each experiment run start. However, the program agent
does not currently have a way to reload the environment while an experiment
is swapped in, short of restarting the agent. Need to figure that out
next, so at present, you only then the initial values at swapin.
parent 7e0cfdd4
......@@ -797,7 +797,7 @@ sub ModifyMetadata($$$$)
}
#
# Add a metadata record.
# Add a formal parameter to a template.
#
sub NewFormalParameter($$$)
{
......@@ -829,6 +829,36 @@ sub NewFormalParameter($$$)
return 0;
}
#
# Get list of template formal parameters.
#
sub FormalParameterList($$)
{
my ($self, $prval) = @_;
# Must be a real reference.
return -1
if (! ref($self));
my %results = ();
my $template_guid = $self->guid();
my $template_vers = $self->vers();
my $query_result =
DBQueryWarn("select name,value from experiment_template_parameters ".
"where parent_guid='$template_guid' and ".
" parent_vers='$template_vers'");
return -1
if (!$query_result);
while (my ($name,$value) = $query_result->fetchrow_array()) {
$results{$name} = $value;
}
%$prval = %results;
return 0;
}
#
# Delete (all) template metadata
#
......@@ -1429,6 +1459,39 @@ sub NewBinding($$)
return 0;
}
#
# Get list of bindings for the instance (the values at swapin time).
#
sub BindingList($$)
{
my ($self, $prval) = @_;
# Must be a real reference.
return -1
if (! ref($self));
my %results = ();
my $guid = $self->guid();
my $vers = $self->vers();
my $idx = $self->idx();
my $query_result =
DBQueryWarn("select name,value ".
" from experiment_template_instance_bindings ".
"where instance_idx='$idx' and ".
" parent_guid='$guid' and ".
" parent_vers='$vers'");
return -1
if (!$query_result);
while (my ($name,$value) = $query_result->fetchrow_array()) {
$results{$name} = $value;
}
%$prval = %results;
return 0;
}
sub DeleteBindings($)
{
my ($self) = @_;
......@@ -1603,6 +1666,8 @@ sub NewRunBinding($$$)
# We provide this stuff now.
my $exptidx = $self->exptidx();
my $runidx = $self->runidx();
my $pid = $self->pid();
my $eid = $self->eid();
if (defined($value)) {
$value = DBQuoteSpecial($value);
......@@ -1615,6 +1680,10 @@ sub NewRunBinding($$$)
" exptidx='$exptidx', runidx='$runidx', ".
" name='$name', value=$value")
or return -1;
DBQueryFatal("replace into virt_user_environment set ".
" name='$name', value=$value, ".
" pid='$pid', eid='$eid'");
return 0;
}
......
......@@ -193,11 +193,15 @@ if (ExpState($pid, $eid) ne EXPTSTATE_ACTIVE()) {
#
# If we have a parameter file, we need to copyin the values and store
# them in the DB for this experiment.
# them in the DB for this experiment. Note that these override existing
# values, so we start with those first.
#
# XXX Do we keep these values in the DB forever? Or just keep the XML file
# around and archived?
#
$instance->BindingList(\%parameters) == 0
or tbdie("Could not get binding list for $instance");
if (defined($paramfile)) {
my $donebad = 0;
......
......@@ -185,11 +185,15 @@ if (! TBProjAccessCheck($dbuid,
#
# If we have a parameter file, we need to copyin the values and store
# them in the DB for this experiment.
# them in the DB for this experiment. Note that these override existing
# values, so we start with those first.
#
# XXX Do we keep these values in the DB forever? Or just keep the XML file
# around and archived?
#
$template->FormalParameterList(\%parameters) == 0
or tbdie("Could not get formal parameter list for $template");
if (defined($paramfile)) {
my $donebad = 0;
......@@ -400,6 +404,27 @@ if ($waitmode) {
POSIX::setsid();
}
#
# Hmm. Before we actually swapin, copy the parameters to the environment
# table so that they are available to the program agent when it starts up
# on the nodes. Note that we destructively modify a virt_ table, but thats
# okay for now. Of course, it has to be done *before* the swapin so that
# the values are in place when the nodes boot!
#
foreach my $name (keys(%parameters)) {
my $value = $parameters{$name};
if (defined($value)) {
$value = DBQuoteSpecial($value);
}
else {
$value = "''";
}
DBQueryFatal("replace into virt_user_environment set ".
" name='$name', value=$value, ".
" pid='$pid', eid='$eid'");
}
#
# Now do the swapin (or it gets queued if a batch experiment).
#
......
......@@ -185,11 +185,15 @@ if (! TBProjAccessCheck($dbuid,
#
# If we have a parameter file, we need to copyin the values and store
# them in the DB for this experiment.
# them in the DB for this experiment. Note that these override existing
# values, so we start with those first.
#
# XXX Do we keep these values in the DB forever? Or just keep the XML file
# around and archived?
#
$template->FormalParameterList(\%parameters) == 0
or tbdie("Could not get formal parameter list for $template");
if (defined($paramfile)) {
my $donebad = 0;
......@@ -400,6 +404,27 @@ if ($waitmode) {
POSIX::setsid();
}
#
# Hmm. Before we actually swapin, copy the parameters to the environment
# table so that they are available to the program agent when it starts up
# on the nodes. Note that we destructively modify a virt_ table, but thats
# okay for now. Of course, it has to be done *before* the swapin so that
# the values are in place when the nodes boot!
#
foreach my $name (keys(%parameters)) {
my $value = $parameters{$name};
if (defined($value)) {
$value = DBQuoteSpecial($value);
}
else {
$value = "''";
}
DBQueryFatal("replace into virt_user_environment set ".
" name='$name', value=$value, ".
" pid='$pid', eid='$eid'");
}
#
# Now do the swapin (or it gets queued if a batch experiment).
#
......
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