Commit 8a1e04fb authored by Mike Hibler's avatar Mike Hibler

Add -D option to showlease to describe sitevars controlling leases.

parent 6498e1ef
......@@ -38,24 +38,27 @@ sub usage()
print STDERR " -a Show all leases (admin only)\n";
print STDERR " -g Show only leases in the 'grace' state\n";
print STDERR " -L Show lock holders (admin only)\n";
print STDERR " -D Describe the system-wide limits on leases\n";
print STDERR " -p pid Show all leases for project <pid>\n";
print STDERR " -u uid Show all leases owned by user <uid>\n";
print STDERR " lid ... Show named leases (name is <pid>/<id>)\n";
exit(-1);
}
my $optlist = "dhaLp:u:g";
my $optlist = "dhaLDp:u:g";
my $debug = 0;
my $pid;
my $uid;
my $showall;
my $showgrace;
my $showlockers;
my $showsitevars;
my @lids = ();
my %sitevars = ();
# Protos
sub fatal($);
sub datestr($);
sub showsitevars();
#
# Configure variables
......@@ -105,6 +108,9 @@ if (defined($options{g})) {
if (defined($options{L})) {
$showlockers = 1;
}
if (defined($options{D})) {
$showsitevars = 1;
}
if (defined($options{p})) {
$pid = $options{p};
}
......@@ -137,6 +143,11 @@ if (! defined($this_user)) {
fatal("You ($UID) do not exist!");
}
if ($showsitevars) {
showsitevars();
exit(0);
}
if ($showall) {
# Admin can see all leases, others not so much
foreach my $lid (Lease->AllLeases()) {
......@@ -300,6 +311,127 @@ if (@lids > 0) {
exit(0);
#
# Per-type Lease sitevars:
#
# maxsize Max size (MiB) of a dataset
# (0 == unlimited)
# maxlease Max time (days) from creation before lease is marked expired
# (0 == unlimited)
# maxidle Max time (days) from last use before lease is marked expired
# (0 == unlimited)
# graceperiod Time (days) before an expired dataset will be destroyed
# (0 == no grace period, unlimited makes no sense here)
# autodestroy If non-zero, destroy expired datasets after grace period
# otherwise lock them
# usequotas If non-zero, enforce per-project dataset quotas
# maxextend Number of times a user can extend the lease
# (0 == unlimited)
# extendperiod Length (days) of each user-requested extention
# (0 == do not allow extensions)
#
sub showsitevars()
{
my %vars = ();
foreach my $ltype ("stdataset", "ltdataset") {
$vars{$ltype} = Lease->SiteVars($ltype);
my $maxsize = $vars{$ltype}->{'maxsize'};
my $maxlease = $vars{$ltype}->{'maxlease'} / (24 * 60 * 60);
my $maxidle = $vars{$ltype}->{'maxidle'} / (24 * 60 * 60);
my $grace = $vars{$ltype}->{'graceperiod'} / (24 * 60 * 60);
my $autod = $vars{$ltype}->{'autodestroy'};
my $quotas = $vars{$ltype}->{'usequotas'};
my $maxext = $vars{$ltype}->{'maxextend'};
my $extend = $vars{$ltype}->{'extendperiod'} / (24 * 60 * 60);
my $v;
print "$ltype:\n";
print " Maximum size:";
if ($quotas != 0) {
print " determined by project quota";
} elsif ($maxsize == 0) {
print " unlimited";
} else {
if ($maxsize < 1024) {
$v = sprintf("%.2f", $maxsize);
print " $v MiB";
} elsif ($maxsize < (1024 * 1024)) {
$v = sprintf("%.2f", $maxsize / 1024);
print " $v GiB";
} else {
$v = sprintf("%.2f", $maxsize / (1024 * 1024));
print " $v TiB";
}
$v = $maxsize * 1024 * 1024;
print " ($v bytes)";
}
print ".\n";
print " Expiration:";
if ($maxidle == 0 && $maxlease == 0) {
print " never";
} else {
print " after";
if ($maxidle != 0) {
if ($maxidle < 1) {
$v = sprintf("%.1f", $maxidle * 24);
print " $v hours";
} else {
$v = sprintf("%.1f", $maxidle);
print " $v days";
}
print " idle";
}
if ($maxlease != 0) {
if ($maxidle != 0) {
print " or after";
}
print " a lease-specific time period (maximum of";
if ($maxlease < 1) {
$v = sprintf("%.1f", $maxlease * 24);
print " $v hours";
} else {
$v = sprintf("%.1f", $maxlease);
print " $v days";
}
print " from creation)";
}
}
print ".\n";
print " Disposition:";
if ($maxidle == 0 && $maxlease == 0) {
print " N/A";
} else {
if ($autod) {
print " destroyed";
} else {
print " locked-down";
}
print " after expiration";
if ($extend != 0) {
print " plus";
if ($maxext == 0) {
print " an unlimited number of";
} else {
print " up to $maxext";
}
if ($extend < 1) {
$v = sprintf("%.1f", $extend * 24);
print " $v hour";
} else {
$v = sprintf("%.1f", $extend);
print " $v day";
}
print " extentions";
}
}
print ".\n";
}
}
sub datestr($)
{
my ($date) = @_;
......
......@@ -5996,7 +5996,12 @@ class dataset:
#
argstr = ""
for opt, val in argdict.items():
if opt == "all":
if opt == "limits":
if xbool(val):
argstr += " -D "
pass
pass
elif opt == "all":
if xbool(val):
argstr += " -a "
pass
......
......@@ -2871,7 +2871,7 @@ class showdataset:
def apply(self):
try:
opts, req_args = getopt.getopt(self.argv, "au:p:h", [ "help" ]);
opts, req_args = getopt.getopt(self.argv, "Dau:p:h", [ "help" ]);
pass
except getopt.error, e:
print e.args[0]
......@@ -2883,6 +2883,9 @@ class showdataset:
if opt in ("-h", "--help"):
self.usage()
return 0
elif opt == "-D":
params["limits"] = "yes";
pass
elif opt == "-a":
params["all"] = "yes";
pass
......@@ -2901,12 +2904,16 @@ class showdataset:
return rval;
def usage(self):
print "showdataset [-ha] [-p pid] [-u uid] dataset_id...";
print "showdataset [-hDa] [-p pid] [-u uid] dataset_id...";
print "where:";
print " -D - Describe the site-specific limits of datasets";
print " -a - Show all datasets";
print " -p pid - Show all datasets for given project";
print " -u uid - Show all datasets for given user";
print "";
print "Describe the site-specific limits on the size/duration";
print "of the different dataset types (-D), or";
print "";
print "Show all (-a) datasets or those associated with a particular";
print "project (-p), user (-u), or those listed.";
print "Only one of -a, -p, -u or an explicit list should be specified.";
......
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