Commit 028493a2 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add -x and -m options to turn on the prepass (-x), and to set the

multiplex factor (-m). Overrides the setting in the experiments table.
parent 5c7d039d
......@@ -44,18 +44,23 @@ sub usage ()
print STDERR " -f - Fix current resources during update mode\n";
print STDERR " -n - Run assign, but do not reserve/modify resources.\n";
print STDERR " -r - Regression mode.\n";
print STDERR " -x - Turn on the prepass\n";
print STDERR " -m - Set the multiplex factor; overrides experiment.\n";
print STDERR " -p - Do a precheck for mapability on an empty testbed - ".
"implies -n\n";
exit($WRAPPER_FAILED);
}
my $optlist = "dvunfprqc";
my $optlist = "dvunfprqczxm:";
my $verbose = 0;
my $debug = 0;
my $fixmode = 0;
my $updating = 0;
my $impotent = 0;
my $precheck = 0;
my $prepass = 0;
my $mfactor;
my $regression = 0;
my $noassign = 0; # Only with regression mode, use previous solution.
my $quiet = 0;
my $clear = 0;
my $warnings = 0;
......@@ -137,6 +142,12 @@ if (defined($options{"f"})) {
if (defined($options{"p"})) {
$precheck = 1;
}
if (defined($options{"x"})) {
$prepass = 1;
}
if (defined($options{"m"})) {
$mfactor = $options{"m"};
}
if (defined($options{"r"})) {
if ($DBNAME eq "tbdb") {
fatal("Cannot use regression mode on main DB");
......@@ -144,6 +155,8 @@ if (defined($options{"r"})) {
$regression = 1;
$clear = 1;
TBDebugTimeStampsOn();
$noassign = 1
if (defined($options{"z"}));
}
if (defined($options{"q"})) {
$quiet = 1;
......@@ -205,19 +218,25 @@ if ($updating) {
TBDebugTimeStamp("LoadCurrentResources ended");
}
if (!$impotent && ($updating || $clear)) {
if ($regression) {
if ($regression || $clear) {
chat("Freeing reserved nodes in regression mode\n");
system("export NORELOAD=1; $NFREE -x -a $pid $eid") == 0
or fatal("Could not release nodes in regression mode");
}
chat("Clearing physical state before updating.\n");
$experiment->RemovePhysicalState();
exit(0)
if ($clear && !$regression);
}
TBDebugTimeStamp("vtopgen started");
$vtop->CreateVtop() == 0
or fatal("Could not create vtop for $experiment");
TBDebugTimeStamp("vtopgen finished");
# multiplex_factor default.
$mfactor = $experiment->multiplex_factor()
if (!defined($mfactor) && defined($experiment->multiplex_factor()));
#
# The assign loop.
#
......@@ -324,6 +343,16 @@ sub RunAssign($$)
my $vtopfile = $prefix . ".vtop";
my $assignexitcode = 0;
# Debugging hack for regression mode. Avoid really long assign runs.
if ($regression && $noassign) {
if (! -e "assign.log") {
chat("No existing assign results file!\n");
return -1;
}
chat("Using existing assign results file\n");
goto skiprun;
}
#
# Do admission control test, and gather the info.
#
......@@ -346,14 +375,16 @@ sub RunAssign($$)
if ($updating);
$ptopargs .= "-u "
if ($updating && $experiment->elabinelab());
$ptopargs .= "-m " . $experiment->multiplex_factor() . " "
if (defined($experiment->multiplex_factor()));
$ptopargs .= "-m $mfactor "
if (defined($mfactor));
$ptopargs .= "-v "
if ($vtop->virtnodecount());
$ptopargs .= "-r "
if ($vtop->remotenodecount());
$ptopargs .= "-S "
if ($vtop->simnodecount());
$ptopargs .= "-h "
if ($vtop->sharednodecount());
$ptopargs .= "-a "
if ($precheck);
$ptopargs .= "-c " . $experiment->delay_capacity() . " "
......@@ -405,6 +436,8 @@ sub RunAssign($$)
}
# Run assign
# my $cmd = "assign-dev";
# my $args = "-P -x $ptopfile -y $vtopfile";
my $cmd = "assign";
my $args = "-P $ptopfile $vtopfile";
$args = "-uod -c .75 $args"
......@@ -413,6 +446,13 @@ sub RunAssign($$)
if ($precheck);
$args = "-s 123456 $args"
if ($regression);
# The prepass speeds up assign on big tops with virtual nodes.
if ($prepass) {
$cmd = "assign_prepass";
$args = "-m $mfactor $args"
if (defined($mfactor));
}
chat("assign command: '$cmd $args'\n");
#
......@@ -450,7 +490,7 @@ sub RunAssign($$)
# the parent.
#
POSIX::setsid();
exec("nice $WRAPPER2 $cmd $args > assign.log");
exec("nice $WRAPPER2 $cmd $args > assign.log 2>&1");
die("Could not start assign!\n");
}
TBDebugTimeStamp("assign finished");
......@@ -493,7 +533,7 @@ sub RunAssign($$)
chat("Precheck succeeded.\n");
return 0;
}
skiprun:
chat("Reading assign results.\n");
if (!open(ASSIGNFP, "assign.log")) {
print("Could not open assign logfile! $!\n");
......
......@@ -69,8 +69,8 @@ my $tempmode = 0; # apply change to temp_boot_osid.
my $clear = 0; # Clear the selected boot (def,temp,next).
my $default = 0; # Reset back to default osid.
my @nodes = ();
my $osid = "";
my $opmode;
my $osid;
my $osinfo;
# Set up syslog
openlog("osselect", "pid", $TBLOG);
......@@ -132,125 +132,29 @@ if ($UID && !TBAdmin($UID) &&
# Grab the info for the OSID.
#
if (! ($clear || $default)) {
my $osinfo = OSinfo->Lookup($osid);
$osinfo = OSinfo->Lookup($osid);
fatal("Improper DB entry for OSID: $osid")
if (!defined($osinfo));
$opmode = $osinfo->op_mode();
}
foreach my $node (@nodes) {
my $curmode = node_opmode($node);
if ($default) {
my $nodeobject = Node->Lookup($node);
fatal("Could not map $node to its object")
if (!defined($nodeobject));
my $osinfo = OSinfo->Lookup($nodeobject->default_osid());
fatal("Could not map default_osid to its object for $node")
if (!defined($osinfo));
my $nextosinfo = $osinfo->ResolveNextOSID();
fatal("Could not resolve nextosid for $osinfo")
if (!defined($nextosinfo));
$osid = $nextosinfo->osid();
$opmode = $nextosinfo->op_mode();
}
# Why? When will this happen?
next
if (!$curmode);
debug("Current opmode for $node is $curmode.\n");
# Set/Clear the osid.
set_boot_osid($node);
#
# Determine what osid the node will now boot. We need to know this so we
# can set the next opmode. This call has to return *something* or we are
# screwed since we will not be able to figure out the opmode.
#
my ($bootosid, $bootopmode) = TBBootWhat($node, $debug);
fatal("Bootwhat query failed for $node!")
if (!$bootosid);
debug("Bootwhat says: $node => $bootosid\n");
#
# If its different then what the node is currently booting, then
# set up a transition in stated. If no change, be sure to clear
# is since stated does not like a transition to be specified when
# none is actually going to be made.
#
if ($curmode ne $bootopmode) {
set_nextmode($node, $bootopmode);
}
else {
# Must clear it.
set_nextmode($node, "");
}
elsif ($default) {
$osinfo = "<DEFAULT>";
}
exit(0);
#
# Subroutines
#
# Set the next_op_mode field for a node.
sub set_nextmode($;$)
{
my ($node, $opmode) = @_;
if ($opmode eq "") {
debug("Clearing next_op_mode for $node.\n");
}
else {
debug("Setting next_op_mode for $node to $opmode.\n");
}
DBQueryFatal("update nodes set next_op_mode='$opmode' ".
"where node_id='$node'");
return 0;
}
foreach my $node (@nodes) {
my $nodeobject = Node->Lookup($node);
# Set (or clear) the boot osid.
sub set_boot_osid($) {
my ($node) = @_;
# The field to change in the DB.
my $field = "def_boot_osid";
my $value;
$field = "next_boot_osid"
if ($oneshot);
$field = "temp_boot_osid"
if ($tempmode);
if ($clear) {
debug("Clearing $field for $node.\n");
$value = "NULL";
}
else {
debug("Setting $field for $node to $osid.\n");
$value = "'$osid'";
}
DBQueryFatal("update nodes set ${field}=${value} where node_id='$node'");
}
# Return current opmode that a node is set to.
sub node_opmode($)
{
my ($node) = @_;
my $opmode;
if (! TBGetNodeOpMode($node, \$opmode)) {
fatal("Could not get opmode for node $node!");
if ($nodeobject->OSSelect($osinfo, $field, $debug) != 0) {
fatal("OSSelect(): " . ($osinfo ? "$osinfo " : "") ."failed on $node");
}
if (!defined($opmode) || $opmode eq "" ||
$opmode eq TBDB_NODEOPMODE_UNKNOWN) {
warning("Invalid opmode $opmode for $node.\n");
return 0;
}
return $opmode;
}
exit(0);
sub debug($;$)
{
......
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