Commit 84ba8e75 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Now allowed to specify nodes, so that we can use this from the

Geni path instead of hand rolled monitor code.
parent 8bf338c5
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
# Copyright (c) 2000-2017 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -41,12 +41,13 @@ use Data::Dumper;
sub usage()
{
print STDERR "Usage: os_setup [-d] <pid> <eid>\n";
print STDERR "Usage: os_setup [-d] <pid> <eid> [node, node, ...]\n";
exit(-1);
}
my $optlist = "id";
my $debug = 1;
my $impotent = 0;
my @nodelist = ();
#
# Configure variables
......@@ -94,7 +95,7 @@ TBDebugTimeStampsOn();
if (! getopts($optlist, \%options)) {
usage();
}
if (@ARGV != 2) {
if (@ARGV < 2) {
usage();
}
if (defined($options{"d"})) {
......@@ -119,25 +120,46 @@ my $user_email_to = "$user_name <$user_email>";
#
# Check permission.
#
my $experiment = Experiment->Lookup($ARGV[0], $ARGV[1]);
my $pid = shift(@ARGV);
my $eid = shift(@ARGV);
my $experiment = Experiment->Lookup($pid, $eid);
if (!defined($experiment)) {
die_noretry("Could not find experiment object");
}
if (!$experiment->AccessCheck($this_user, TB_EXPT_MODIFY)) {
die_noretry("You do not have permission to swap this experiment!");
}
my $pid = $experiment->pid();
my $eid = $experiment->eid();
# Avoid taint.
$pid = $experiment->pid();
$eid = $experiment->eid();
TBDebugTimeStamp("os_setup started");
#
# List of all nodes in the experiment.
# List of all nodes in the experiment if not specified.
#
my @nodelist = $experiment->NodeList(0, 1);
if (! @nodelist) {
tbinfo("No nodes in experiment. Exiting ...\n");
exit(0);
if (@ARGV) {
foreach my $n (@ARGV) {
my $node = Node->Lookup($n);
if (!defined($node)) {
die_noretry("No such node $n!");
}
my $reservation = $node->Reservation();
if (!defined($reservation)) {
die_noretry("$node is not reserved!");
}
if (!$reservation->SameExperiment($experiment)) {
die_noretry("$node is not reserved to $experiment");
}
push(@nodelist, $node);
}
}
else {
@nodelist = $experiment->NodeList(0, 1);
if (! @nodelist) {
tbinfo("No nodes in experiment. Exiting ...\n");
exit(0);
}
}
#
......
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