Commit bf2f0d84 authored by Leigh Stoller's avatar Leigh Stoller

Continuing work on the creation of experiment runs. Web interface in

now in place (create and display), and the backend part that deals with
setting up the DB records. Nothing actually happens on the nodes yet.
parent 9d2a4a5d
...@@ -22,7 +22,8 @@ BIN_STUFF = power snmpit tbend tbprerun tbreport \ ...@@ -22,7 +22,8 @@ BIN_STUFF = power snmpit tbend tbprerun tbreport \
portstats checkports eventsys_control os_select tbrestart \ portstats checkports eventsys_control os_select tbrestart \
tbswap nseswap tarfiles_setup node_history tbrsync \ tbswap nseswap tarfiles_setup node_history tbrsync \
node_attributes archive_control template_create \ node_attributes archive_control template_create \
template_swapin template_swapout template_graph template_swapin template_swapout template_graph \
template_exprun
SBIN_STUFF = resetvlans console_setup.proxy sched_reload named_setup \ SBIN_STUFF = resetvlans console_setup.proxy sched_reload named_setup \
batch_daemon exports_setup reload_daemon sched_reserve \ batch_daemon exports_setup reload_daemon sched_reserve \
...@@ -51,7 +52,7 @@ LIBEXEC_STUFF = rmproj wanlinksolve wanlinkinfo \ ...@@ -51,7 +52,7 @@ LIBEXEC_STUFF = rmproj wanlinksolve wanlinkinfo \
webnodereboot webrmuser webidleswap switchmac \ webnodereboot webrmuser webidleswap switchmac \
spewrpmtar webtarfiles_setup webfrisbeekiller gentopofile \ spewrpmtar webtarfiles_setup webfrisbeekiller gentopofile \
webnodeattributes webarchive_control webtemplate_create \ webnodeattributes webarchive_control webtemplate_create \
webtemplate_swapin webtemplate_swapout webtemplate_swapin webtemplate_swapout webtemplate_exprun
LIB_STUFF = libtbsetup.pm exitonwarn.pm libtestbed.pm snmpit_intel.pm \ LIB_STUFF = libtbsetup.pm exitonwarn.pm libtestbed.pm snmpit_intel.pm \
snmpit_cisco.pm snmpit_lib.pm snmpit_apc.pm power_rpc27.pm \ snmpit_cisco.pm snmpit_lib.pm snmpit_apc.pm power_rpc27.pm \
......
...@@ -237,22 +237,45 @@ sub FinalizeTemplateInstanceRecord($$$;$) ...@@ -237,22 +237,45 @@ sub FinalizeTemplateInstanceRecord($$$;$)
return 0; return 0;
} }
#
# Update an instance record.
#
sub UpdateTemplateInstanceRecord($$$$)
{
my ($guid, $vers, $exptidx, $args) = @_;
my $query = "update experiment_template_instances ";
if (defined($args) && scalar(keys%{$args})) {
$query .= ",";
$query .= join(",", map("$_='" . $args->{$_} . "'", keys(%{$args})));
}
$query .= " where parent_guid='$guid' and parent_vers='$vers' and ".
" exptidx='$exptidx'";
return -1
if (! DBQueryWarn($query));
return 0;
}
# #
# Get info about a template run. # Get info about a template run.
# #
sub TemplateInstanceInfo($$) sub TemplateInstanceInfo($$;$)
{ {
my ($exptidx, $prunidx) = @_; my ($exptidx, $prunidx, $peid) = @_;
my $query_result = my $query_result =
DBQueryWarn("select runidx from experiment_template_instances ". DBQueryWarn("select eid,runidx from experiment_template_instances ".
"where exptidx='$exptidx'"); "where exptidx='$exptidx'");
return -1 return -1
if (! $query_result); if (! $query_result);
my ($runidx) = $query_result->fetchrow_array(); my ($eid,$runidx) = $query_result->fetchrow_array();
$$prunidx = $runidx; $$prunidx = $runidx;
$$peid = $eid
if (defined($peid));
return 0; return 0;
} }
......
...@@ -237,22 +237,45 @@ sub FinalizeTemplateInstanceRecord($$$;$) ...@@ -237,22 +237,45 @@ sub FinalizeTemplateInstanceRecord($$$;$)
return 0; return 0;
} }
#
# Update an instance record.
#
sub UpdateTemplateInstanceRecord($$$$)
{
my ($guid, $vers, $exptidx, $args) = @_;
my $query = "update experiment_template_instances ";
if (defined($args) && scalar(keys%{$args})) {
$query .= ",";
$query .= join(",", map("$_='" . $args->{$_} . "'", keys(%{$args})));
}
$query .= " where parent_guid='$guid' and parent_vers='$vers' and ".
" exptidx='$exptidx'";
return -1
if (! DBQueryWarn($query));
return 0;
}
# #
# Get info about a template run. # Get info about a template run.
# #
sub TemplateInstanceInfo($$) sub TemplateInstanceInfo($$;$)
{ {
my ($exptidx, $prunidx) = @_; my ($exptidx, $prunidx, $peid) = @_;
my $query_result = my $query_result =
DBQueryWarn("select runidx from experiment_template_instances ". DBQueryWarn("select eid,runidx from experiment_template_instances ".
"where exptidx='$exptidx'"); "where exptidx='$exptidx'");
return -1 return -1
if (! $query_result); if (! $query_result);
my ($runidx) = $query_result->fetchrow_array(); my ($eid,$runidx) = $query_result->fetchrow_array();
$$prunidx = $runidx; $$prunidx = $runidx;
$$peid = $eid
if (defined($peid));
return 0; return 0;
} }
......
...@@ -188,7 +188,7 @@ if ($expstate) { ...@@ -188,7 +188,7 @@ if ($expstate) {
if ($isinstance && $expstate == $TB_EXPTSTATE_ACTIVE) { if ($isinstance && $expstate == $TB_EXPTSTATE_ACTIVE) {
WRITESUBMENUBUTTON("Start Experiment Run", WRITESUBMENUBUTTON("Start Experiment Run",
"template_exprun.php?action=start&guid=$guid". "template_exprun.php?action=start&guid=$guid".
"&version=$version&exptidx=$expindex"); "&version=$version&eid=$exp_eid");
} }
if ($expstate == $TB_EXPTSTATE_ACTIVE) { if ($expstate == $TB_EXPTSTATE_ACTIVE) {
......
...@@ -18,6 +18,9 @@ $uid = GETLOGIN(); ...@@ -18,6 +18,9 @@ $uid = GETLOGIN();
LOGGEDINORDIE($uid); LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid); $isadmin = ISADMIN($uid);
# This will not return if its a sajax request.
include("showlogfile_sup.php3");
# Used below # Used below
unset($parameter_xmlfile); unset($parameter_xmlfile);
$deletexmlfile = 0; $deletexmlfile = 0;
...@@ -28,7 +31,7 @@ $deletexmlfile = 0; ...@@ -28,7 +31,7 @@ $deletexmlfile = 0;
function SPITFORM($formfields, $parameters, $errors) function SPITFORM($formfields, $parameters, $errors)
{ {
global $TBDB_EIDLEN; global $TBDB_EIDLEN;
global $guid, $version, $exptidx; global $guid, $version, $eid;
PAGEHEADER("Start an Experiment Run"); PAGEHEADER("Start an Experiment Run");
...@@ -60,7 +63,7 @@ function SPITFORM($formfields, $parameters, $errors) ...@@ -60,7 +63,7 @@ function SPITFORM($formfields, $parameters, $errors)
} }
echo "<form action=template_exprun.php". echo "<form action=template_exprun.php".
"?action=start&guid=$guid&version=$version&exptidx=$exptidx ". "?action=start&guid=$guid&version=$version&eid=$eid ".
" method=post>\n"; " method=post>\n";
echo "<table align=center border=1>\n"; echo "<table align=center border=1>\n";
...@@ -153,8 +156,8 @@ if (!isset($version) || ...@@ -153,8 +156,8 @@ if (!isset($version) ||
strcmp($version, "") == 0) { strcmp($version, "") == 0) {
USERERROR("You must provide a template version number", 1); USERERROR("You must provide a template version number", 1);
} }
if (!isset($exptidx) || if (!isset($eid) ||
strcmp($exptidx, "") == 0) { strcmp($eid, "") == 0) {
USERERROR("You must provide a template instance ID", 1); USERERROR("You must provide a template instance ID", 1);
} }
if (!TBvalid_guid($guid)) { if (!TBvalid_guid($guid)) {
...@@ -163,7 +166,7 @@ if (!TBvalid_guid($guid)) { ...@@ -163,7 +166,7 @@ if (!TBvalid_guid($guid)) {
if (!TBvalid_integer($version)) { if (!TBvalid_integer($version)) {
PAGEARGERROR("Invalid characters in version!"); PAGEARGERROR("Invalid characters in version!");
} }
if (!TBvalid_integer($exptidx)) { if (!TBvalid_eid($eid)) {
PAGEARGERROR("Invalid characters in instance ID!"); PAGEARGERROR("Invalid characters in instance ID!");
} }
...@@ -175,6 +178,14 @@ if (! TBValidExperimentTemplate($guid, $version)) { ...@@ -175,6 +178,14 @@ if (! TBValidExperimentTemplate($guid, $version)) {
"experiment template!", 1); "experiment template!", 1);
} }
# Need this below.
if (! TBGuid2PidGid($guid, $pid, $gid)) {
TBERROR("Could not get template pid,gid for template $guid", 1);
}
if (($exptidx = TBExptIndex($pid, $eid)) < 0) {
TBERROR("Could not instance IDX for template instance $guid/$eid", 1);
}
# #
# Check to make sure and a valid instance that is actually swapped in. # Check to make sure and a valid instance that is actually swapped in.
# #
...@@ -183,6 +194,8 @@ if (! TBValidExperimentTemplateInstance($guid, $version, $exptidx)) { ...@@ -183,6 +194,8 @@ if (! TBValidExperimentTemplateInstance($guid, $version, $exptidx)) {
"a valid experiment template instance!", 1); "a valid experiment template instance!", 1);
} }
# We need the eid for passing to the shell.
# #
# Verify Permission. # Verify Permission.
# #
...@@ -233,7 +246,9 @@ if (! TBGuid2PidGid($guid, $pid, $gid)) { ...@@ -233,7 +246,9 @@ if (! TBGuid2PidGid($guid, $pid, $gid)) {
# Okay, validate form arguments. # Okay, validate form arguments.
# #
$errors = array(); $errors = array();
$runid = "";
# Set up command options
$command_options = " -a start -e $eid ";
# #
# RunID: # RunID:
...@@ -248,12 +263,9 @@ elseif (TBValidExperiment($pid, $formfields[runid])) { ...@@ -248,12 +263,9 @@ elseif (TBValidExperiment($pid, $formfields[runid])) {
$errors["ID"] = "Already in use"; $errors["ID"] = "Already in use";
} }
else { else {
$runid = $formfields[runid]; $command_options .= " -r " . escapeshellarg($formfields[runid]);
} }
# Set up command options
$command_options = " -a start ";
# #
# Description: # Description:
# #
...@@ -360,7 +372,7 @@ flush(); ...@@ -360,7 +372,7 @@ flush();
# Run the backend script. # Run the backend script.
# #
$retval = SUEXEC($uid, "$pid,$unix_gid", $retval = SUEXEC($uid, "$pid,$unix_gid",
"webtemplate_exprun $command_options $guid/$version $exptidx", "webtemplate_exprun $command_options $guid/$version",
SUEXEC_ACTION_IGNORE); SUEXEC_ACTION_IGNORE);
if ($deletexmlfile) { if ($deletexmlfile) {
...@@ -381,6 +393,8 @@ if ($retval) { ...@@ -381,6 +393,8 @@ if ($retval) {
return; return;
} }
STARTLOG($pid, $eid);
# #
# Standard Testbed Footer # Standard Testbed Footer
# #
......
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