Commit a73c3f16 authored by Chad Barb's avatar Chad Barb

added -e <pid/eid> switch

(results in a given experiment's hardware being returned as if it were free.)
parent 7d0295e5
......@@ -11,10 +11,12 @@ use Getopt::Std;
sub usage()
{
print STDOUT "Usage: ptopgen [-s switch]\n";
print STDOUT "Usage: ptopgen [-s switch] [-e pid/eid] \n" .
" -e include given experiment's resources\n" .
" in the ptopfile (as if they were free)\n";
exit(-1);
}
my $optlist = "s:";
my $optlist = "s:e:";
# Settings - Change these to your particular network.
......@@ -58,6 +60,9 @@ my $switchtouse;
my $DEADPID = NODEDEAD_PID();
my $DEADEID = NODEDEAD_EID();
my $exempt_pid;
my $exempt_eid;
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
......@@ -73,6 +78,11 @@ if (defined($options{"s"})) {
$switchtouse = $options{"s"};
}
if (defined($options{"e"})) {
($exempt_pid, $exempt_eid) = split( /\//, $options{"e"} );
if (!defined($exempt_eid)) { usage(); }
}
# Read class/type maps
my $result = DBQueryFatal("select class,type,delay_capacity from node_types");
while (($class,$type,$delaycapacity) = $result->fetchrow_array) {
......@@ -113,12 +123,22 @@ my $pc601hack_only = "a.type='pc601' and";
my $pc601hack_none = "a.type!='pc601' and";
my $pcvmhack = "(a.type!='pcvm600' and a.type!='pcvm850') and ";
# the ordinary free condition for a node
my $free_condition = "(b.node_id is null)";
# if the user has specified an exempt pid/eid,
# then view any node which is reserved to that experiment as available.
if (defined($exempt_eid)) {
$free_condition = "($free_condition or (b.pid='$exempt_pid' and b.eid='$exempt_eid'))";
}
$result =
DBQueryFatal("select a.node_id,a.type from nodes as a ".
"left join reserved as b on a.node_id=b.node_id ".
"left join reserved as m on a.phys_nodeid=m.node_id ".
"left join nodes as n on a.phys_nodeid=n.node_id ".
"where b.node_id is null and $pcvmhack ".
# "where b.node_id is null and $pcvmhack ".
"where $free_condition and $pcvmhack ".
" $pc601hack_none ".
" (a.role='testnode' or ".
" (a.role='virtnode' and n.status='up' and ".
......
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