Commit 8d591424 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Little script to cleanup a ticket from the command line.

parent a67d2e0f
#!/usr/bin/perl -w
#
# GENIPUBLIC-COPYRIGHT
# Copyright (c) 2008-2009 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
use English;
use Getopt::Std;
#
# Cleanup a ticket on the CM
#
sub usage()
{
print "Usage: cleanupslice idx | uuid\n";
exit(1);
}
sub fatal($);
my $optlist = "";
#
# Configure variables
#
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
my $TBLOGS = "@TBLOGSEMAIL@";
# un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/usr/site/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
#
# Turn off line buffering on output
#
$| = 1;
# Load the Testbed support stuff.
use lib "@prefix@/lib";
use GeniDB;
use GeniTicket;
use GeniUtil;
use GeniCM;
use Genixmlrpc;
use GeniCertificate;
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
}
usage()
if (@ARGV != 1);
my $token = $ARGV[0];
# Map invoking user to object.
my $this_user = User->ThisUser();
if (! defined($this_user)) {
fatal("You ($UID) do not exist!");
}
if (!$this_user->IsAdmin()) {
fatal("You must be a testbed administrator to do this");
}
# Connect to the proper DB.
DBConnect(GENICM_DBNAME());
my $ticket = GeniTicket->Lookup($token);
if (!defined($ticket)) {
fatal("No such ticket for $token");
}
GeniUtil::FlipToGeniUser();
if ($ticket->Lock() != 0) {
fatal("Could not lock $ticket");
}
if ($ticket->Release(TICKET_PURGED)) {
fatal("Could not release $ticket");
}
exit(0);
sub fatal($) {
my ($msg) = @_;
print STDERR "$msg\n";
exit(1);
}
Supports Markdown
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