Commit ace8ba31 authored by Jonathon Duerig's avatar Jonathon Duerig

Added a randomize order option (-z) for nodes.

parent 8d2af253
......@@ -9,6 +9,7 @@
use English;
use Getopt::Std;
use Math::BigInt;
use List::Util 'shuffle';
use lib "@prefix@/lib";
use libdb qw(TBGetSiteVar);
......@@ -34,7 +35,7 @@ sub usage()
{
print("Usage: ptopgen [-v] [-s switch] [-p pid [-e eid]] [-m factor] " .
"[-n c/e] [-x] [-g (0.1 | 2)] [-c component-name]".
"[-l type-limit-file]\n" .
"[-l type-limit-file] [-z]\n" .
" -p include nodes the project has permission to use\n".
" -e include given experiments resources\n" .
" in the ptopfile (as if they were free)\n" .
......@@ -50,11 +51,12 @@ sub usage()
" -x Output into the new xml ptop format\n".
" -g version With -x, geni version. Must be '0', '0.1' or '2'\n".
" -l specifies the location of the type limit file\n" .
" -1 Print an rspec containing only the node component-name");
" -1 Print an rspec containing only the node component-name" .
" -z Randomize node output order");
exit(-1);
}
my $optlist = "s:e:m:vp:rSan:c:uxg:h1:l:";
my $optlist = "s:e:m:vp:rSan:c:uxg:h1:l:z";
my $mfactor;
my $virtstuff = 0;
my $widearea = 0;
......@@ -67,6 +69,7 @@ my $do_xml = 0;
my $genimode = $NO_GENI;
my $useshared = 0;
my $component_name = undef;
my $randomize = 0;
my $OURDOMAIN = "@OURDOMAIN@";
my $MAINSITE = @TBMAINSITE@;
......@@ -217,6 +220,9 @@ if (defined($options{"l"})) {
if (defined($options{"1"})) {
$component_name = $options{"1"};
}
if (defined($options{"z"})) {
$randomize = 1;
}
usage()
if ($prune && !defined($exempt_eid)
......@@ -726,10 +732,16 @@ while (my ($node_id1, $node_id2) = $result->fetchrow()) {
}
}
@nodenames = keys(%nodes);
if ($randomize)
{
@nodenames = shuffle(@nodenames);
}
#
# Loop through and print out all nodes
#
foreach $node (keys(%nodes)) {
foreach $node (@nodenames) {
my $current = $top->nodes()->{$node};
# Wide area nodes are handled below
......
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