Commit cfbcf2c4 authored by Leigh B Stoller's avatar Leigh B Stoller

Add a couple of changes for the GPO.

1. Change default slice expiration to a new site variable called
   protogeni/default_slice_lifetime, defaults to six hours.

2. Add a site variable (protogeni/warn_short_slices) to tell the
   sa_daemon if it should send email to war about short lived slices
   expiring, defaults to off.
parent 6bd40baf
#!/usr/bin/perl -wT
#
# GENIPUBLIC-COPYRIGHT
# Copyright (c) 2008-2011 University of Utah and the Flux Group.
# Copyright (c) 2008-2012 University of Utah and the Flux Group.
# All rights reserved.
#
package GeniSlice;
......@@ -20,6 +20,7 @@ use GeniCertificate;
use GeniUser;
use GeniHRN;
use English;
use libEmulab;
use emutil qw(TBGetUniqueIndex);
use Date::Parse;
use Data::Dumper;
......@@ -153,6 +154,13 @@ sub Create($$$$;$$)
{
my ($class, $certificate, $creator, $authority, $exptidx, $lock) = @_;
my @insert_data = ();
# This is in hours.
my $default_slice_lifetime;
if (!libEmulab::GetSiteVar('protogeni/default_slice_lifetime',
\$default_slice_lifetime)) {
# Cannot get the value, default it to 6 hours
$default_slice_lifetime = 6;
}
# Every slice gets a new unique index.
my $idx = TBGetUniqueIndex('next_exptidx', 1);
......@@ -165,7 +173,8 @@ sub Create($$$$;$$)
# Now tack on other stuff we need.
push(@insert_data, "created=now()");
push(@insert_data, "expires=DATE_ADD(now(), INTERVAL 6 HOUR)");
push(@insert_data, "expires=DATE_ADD(now(), ".
"INTERVAL $default_slice_lifetime HOUR)");
push(@insert_data, "sa_uuid='$sa_uuid'");
push(@insert_data, "exptidx=$exptidx")
if (defined($exptidx));
......
#!/usr/bin/perl -w
#
# GENIPUBLIC-COPYRIGHT
# Copyright (c) 2008-2011 University of Utah and the Flux Group.
# Copyright (c) 2008-2012 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
......@@ -21,6 +21,7 @@ my $optlist = "dn";
my $debug = 0;
my $impotent = 0;
#
# Configure variables
#
......@@ -154,6 +155,16 @@ my $grace = $hours * 3600;
#
sub WarnSlices()
{
#
# Override the short slice warning.
#
my $warn_short_slices;
if (!libEmulab::GetSiteVar('protogeni/warn_short_slices',
\$warn_short_slices)) {
# Cannot get the value, default it to off.
$warn_short_slices = 0;
}
#
# This query purposely skips slices that are attached to cooked
# mode experiments; those that have a non-null exptidx of a local
......@@ -247,7 +258,7 @@ sub WarnSlices()
# email. Assume negative reenforcement will teach users what
# to do.
#
if ($stamp - $created < $grace) {
if ($stamp - $created < $grace && !$warn_short_slices) {
print STDERR
"Short lived slice is going to expire: ".
"$geniuser,$idx,$hrn,$diff $unit\n";
......
......@@ -84,7 +84,9 @@ INSERT INTO sitevariables VALUES ('protogeni/max_externalnodes',NULL,'1024','Whe
INSERT INTO sitevariables VALUES ('protogeni/cm_uuid','28a10955-aa00-11dd-ad1f-001143e453fe','','The UUID of the local Component Manager.',0);
INSERT INTO sitevariables VALUES ('protogeni/max_sliver_lifetime','90','90','The maximum sliver lifetime. When set limits the lifetime of a sliver on your CM. Also see protogeni/max_slice_lifetime.',0);
INSERT INTO sitevariables VALUES ('protogeni/max_slice_lifetime','90','90','The maximum slice credential lifetime. When set limits the lifetime of a slice credential. Also see protogeni/max_sliver_lifetime.',0);
INSERT INTO sitevariables VALUES ('protogeni/default_slice_lifetime','6','6','The default slice credential lifetime. In hours. Also see protogeni/max_slice_lifetime.',0);
INSERT INTO sitevariables VALUES ('protogeni/max_components','-1','-1','Maximum number of components that can be allocated. -1 indicates any number of components can be allocated.',0);
INSERT INTO sitevariables VALUES ('protogeni/warn_short_slices','0','0','When set, warn users about shortlived slices (see the sa_daemon).',0);
INSERT INTO sitevariables VALUES ('general/minpoolsize','3','1','The Minimum size of the shared pool',0);
INSERT INTO sitevariables VALUES ('general/maxpoolsize','5','1','The maximum size of the shared pool',0);
INSERT INTO sitevariables VALUES ('protogeni/sa_uuid','2b437faa-aa00-11dd-ad1f-001143e453fe','','The UUID of the local Slice Authority.',0);
......
#
# Add initial_passphrase slot to users table.
#
use strict;
use libdb;
my $impotent = 0;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
DBQueryFatal("INSERT INTO sitevariables VALUES ".
"('protogeni/default_slice_lifetime','6','6', ".
" 'The default slice credential lifetime. In hours. ".
"Also see protogeni/max_slice_lifetime.', 0)")
if (!TBSiteVarExists("protogeni/default_slice_lifetime"));
DBQueryFatal("INSERT INTO sitevariables VALUES ".
"('protogeni/warn_short_slices','0','0', ".
" 'When set, warn users about shortlived slices ".
"(see the sa_daemon).',0)")
if (!TBSiteVarExists("protogeni/warn_short_slices"));
return 0;
}
# Local Variables:
# mode:perl
# End:
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