Commit 2c78e572 authored by Gary Wong's avatar Gary Wong

Add utility to send nag e-mail about upcoming reservations.

parent d6bd629c
......@@ -1378,7 +1378,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
utils/mkblob utils/rmblob utils/ctrladdr utils/tcppd \
utils/mktestbedtest utils/pxelinux_makeconf \
utils/addvpubaddr utils/attend utils/atten utils/addrfdevice \
utils/addrfpath utils/reserve \
utils/addrfpath utils/reserve utils/predict utils/notify-reservations \
www/GNUmakefile www/defs.php3 www/dbdefs.php3 www/xmlrpc.php3 \
www/xmlrpcpipe.php3 \
www/swish.conf www/websearch \
......
......@@ -57,7 +57,7 @@ SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \
node_exclude managetaint shutdown-shared imagerelease \
runsonxen pxelinux_makeconf attend atten \
addrfdevice addrfpath reserve announce createimagealias \
predict test-reserve prunelogfiles
predict test-reserve prunelogfiles notify-reservations
WEB_SBIN_SCRIPTS= webnewnode webdeletenode webspewconlog webarchive_list \
webwanodecheckin webspewimage webdumpdescriptor webemulabfeature \
......
#!/usr/bin/perl -w
#
# Copyright (c) 2017 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
use strict;
use English;
use Getopt::Std;
#
# Send e-mail about upcoming reservations.
#
sub usage()
{
print STDERR "Usage: notify-reservations [-d] [-n]\n";
exit( 1 );
}
my $optlist = "dn";
my $debug = 0;
my $impotent = 0;
#
# Configure variables
#
my $SITE = "@THISHOMEBASE@";
my $TBOPS = "@TBOPSEMAIL@";
#
# Testbed Support libraries
#
use lib "@prefix@/lib";
use emdb;
use libtestbed;
use emutil;
#
# Turn off line buffering on output
#
$| = 1;
#
# Untaint the path
#
$ENV{'PATH'} = "/bin:/sbin:/usr/bin:";
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{"d"})) {
$debug = 1;
}
if (defined($options{"n"})) {
$impotent = 1;
}
usage()
if (@ARGV);
my $query_result = DBQueryFatal( "SELECT r.idx, r.pid, r.nodes, r.type, " .
"r.start, r.end, u.usr_email FROM " .
"future_reservations AS r, users AS u " .
"WHERE r.uid_idx=u.uid_idx AND " .
"r.notified IS NULL AND " .
"r.start <= ADDDATE( NOW(), 1 )" );
while( my ($idx, $pid, $count, $type, $start, $end, $email) =
$query_result->fetchrow_array() ) {
print STDERR "Reservation $idx for project $pid, $count x $type from " .
"$start-$end <$email>\n" if( $debug );
next if( $impotent );
SENDMAIL( $email, "Upcoming $SITE reservation",
"You have a reservation scheduled at $SITE, with project\n" .
"$pid. $count $type nodes will be set aside for your\n" .
"project, starting at $start and ending at\n" .
"$end.\n" .
"\n" .
"If you do not intend to use these resources, please\n" .
"cancel this reservation as soon as possible, since\n" .
"the nodes will be unavailable to other users for\n" .
"the duration of your reservation.\n" .
"\n" .
"Please note that we make no guarantees about the\n" .
"availability or suitability of these nodes for your\n" .
"experiment(s).\n" .
"\n" .
"PLEASE NOTE: Reservations are an experimental\n" .
"testbed feature under active development. Until\n" .
"further notice, you should expect reservation\n" .
"system failures. Please send reports about the\n" .
"reservation system to $TBOPS.\n" .
"Thank you for your assistance in debugging this\n" .
"feature!\n" );
DBQueryFatal( "UPDATE future_reservations SET notified=NOW() WHERE idx=$idx" );
}
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