Commit 2bb2ce22 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

A script to resolve things at the Clearinghouse.

parent cce6b970
#!/usr/bin/perl -w
#
# GENIPUBLIC-COPYRIGHT
# Copyright (c) 2008-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
use English;
use Getopt::Std;
use Data::Dumper;
#
# Resolve a uuid or hrn at the clearinghouse or an SA.
#
sub usage()
{
print "Usage: resolvenode urn\n";
exit(1);
}
my $optlist = "";
my $uuid;
my $hrn;
#
# Configure variables
#
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
my $TBLOGS = "@TBLOGSEMAIL@";
my $PGENIDOMAIN = "@PROTOGENI_DOMAIN@";
my $PGENISUPPORT = @PROTOGENI_SUPPORT@;
my $CMCERT = "$TB/etc/genicm.pem";
# un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/usr/site/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
# Protos
sub fatal($);
#
# Turn off line buffering on output
#
$| = 1;
# Now we can load the libraries after setting the proper DB.
use lib '@prefix@/lib';
use GeniDB;
use GeniCertificate;
use GeniAuthority;
use GeniComponent;
use Genixmlrpc;
use Carp;
$Carp::Verbose = 1;
#
# Check args.
#
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
}
usage()
if (@ARGV != 1);
my $token = $ARGV[0];
#
# Load the CM cert to act as caller context.
#
my $certificate = GeniCertificate->LoadFromFile($CMCERT);
if (!defined($certificate)) {
fatal("Could not load certificate from $CMCERT\n");
}
Genixmlrpc->SetContext(Genixmlrpc->Context($certificate));
my $clearinghouse = GeniRegistry::ClearingHouse->Create();
if (!defined($clearinghouse)) {
fatal("Could not create a clearinghouse client object");
}
my $result;
if ($clearinghouse->Resolve($token, "", \$result) != 0) {
fatal("Could not resolve $token\n");
}
print Dumper($result);
exit(0);
sub fatal($)
{
my ($msg) = @_;
print STDERR "*** $0:\n".
" $msg\n";
# exit value important.
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