LAMP/Tutorial: lamp-getcertificate.py

File lamp-getcertificate.py, 2.0 KB (added by fernande@cis.udel.edu, 9 years ago)

Script that allows users to get a certificate for their LAMP services.

Line 
1#! /usr/bin/env python
2#
3# GENIPUBLIC-COPYRIGHT
4# Copyright (c) 2008-2010 University of Utah and the Flux Group.
5# All rights reserved.
6#
7# Permission to use, copy, modify and distribute this software is hereby
8# granted provided that (1) source code retains these copyright, permission,
9# and disclaimer notices, and (2) redistributions including binaries
10# reproduce the notices in supporting documentation.
11#
12# THE UNIVERSITY OF UTAH ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13# CONDITION.  THE UNIVERSITY OF UTAH DISCLAIMS ANY LIABILITY OF ANY KIND
14# FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15#
16
17#
18#
19import sys
20import pwd
21import getopt
22import os
23import time
24import re
25import xmlrpclib
26from M2Crypto import X509
27
28ACCEPTSLICENAME=1
29
30execfile( os.path.dirname(os.path.abspath(__file__)) + os.sep + "test-common.py" )
31
32if len(REQARGS) > 0:
33    Usage()
34    sys.exit( 1 )
35
36#
37# Get a credential for myself, that allows me to do things at the SA.
38#
39mycredential = get_self_credential()
40print "Got my SA credential, looking up " + SLICENAME
41
42#
43# Lookup slice.
44#
45params = {}
46params["credential"] = mycredential
47params["type"]       = "Slice"
48params["hrn"]        = SLICENAME
49rval,response = do_method("sa", "Resolve", params)
50if rval:
51    #
52    # Exit
53    #
54    Fatal("Error resolving slice: " + response);
55    pass
56else:
57    #
58    # Get the slice credential.
59    #
60    print "Asking for slice credential for " + SLICENAME
61    myslice = get_slice_credential( response[ "value" ], mycredential )
62    print "Got the slice credential"
63    pass
64
65
66print "Asking for my lamp certificate"
67
68lampca = "https://blackseal.damsl.cis.udel.edu/protogeni/xmlrpc/lampca"
69
70params = {}
71params["credential"] = (myslice,)
72rval,response = do_method("lamp", "GetLAMPSliceCertificate", params, URI=lampca)
73if rval:
74    Fatal("Could not get ticket: " + response)
75    pass
76
77print "Paste the following certificate *as is* into a file called lampcert.pem"
78print "Upload the certificate to all LAMP enabled nodes at /usr/local/etc/protogeni/ssl/lampcert.pem"
79print response["value"]
80