source: fedd/fedd_new.py @ 549830d

axis_examplecompt_changesinfo-ops
Last change on this file since 549830d was 835cf55, checked in by Ted Faber <faber@…>, 14 years ago

Debugging removal

  • Property mode set to 100755
File size: 2.3 KB
RevLine 
[d743d60]1#!/usr/local/bin/python
2
3import sys
4
[7206e5a]5from federation.fedid import fedid, generate_fedid
[d743d60]6from federation.remote_service import service_caller
7from federation.client_lib import client_opts, exit_with_fault, RPCException, \
[7206e5a]8        wrangle_standard_options, do_rpc, get_experiment_names, \
9        save_certfile, get_abac_certs
[d743d60]10
11
12class new_opts(client_opts):
13    def __init__(self):
14        client_opts.__init__(self)
15        self.add_option("--experiment_cert", dest="out_certfile",
16                type="string", help="output certificate file")
17        self.add_option("--experiment_name", dest="exp_name",
18                type="string", help="Suggested experiment name")
[7206e5a]19        self.add_option('--gen-cert', action='store_true', dest='gen_cert',
20                default=False,
21                help='generate a cert to which to delegate rights')
[d743d60]22
23parser = new_opts()
24(opts, args) = parser.parse_args()
25
[5d854e1]26cert, fid, url = wrangle_standard_options(opts)
[7206e5a]27try:
28    acerts = get_abac_certs(opts.abac_dir)
29except EnvironmentError, e:
30    sys.exit('%s: %s' % (e.filename, e.strerror))
[d743d60]31
32out_certfile = opts.out_certfile
33
34msg = { }
35
[7206e5a]36if opts.gen_cert:
37    expid, expcert = generate_fedid(opts.exp_name or 'dummy')
38    msg['experimentAccess'] = { 'X509': expcert }
39else:
40    expcert = None
41
[d743d60]42if opts.exp_name:
43    msg['experimentID'] = { 'localname': opts.exp_name }
44
[7206e5a]45if acerts:
46    msg['credential'] = acerts
47
[d743d60]48if opts.debug > 1: print >>sys.stderr, msg
49
50try:
51    resp_dict = do_rpc(msg, 
[5d854e1]52            url, opts.transport, cert, opts.trusted, 
[d743d60]53            serialize_only=opts.serialize_only,
54            tracefile=opts.tracefile, 
55            caller=service_caller("New"), responseBody='NewResponseBody')
56except RPCException, e:
57    exit_with_fault(e)
58except RuntimeError, e:
59    sys.exit("Error processing RPC: %s" % e)
60
61if opts.debug > 1: print >>sys.stderr, resp_dict
62
63try:
[7206e5a]64    save_certfile(opts.out_certfile, resp_dict.get('experimentAccess', None), 
65            expcert)
66except EnvironmentError, e:
67    sys.exit('Could not write to %s:' %  (e.strerror, e.filename))
68except CertificateMismatchError:
69    printf >>sys.stderr, "Fedid of created experiment does not match generated"
70
[d743d60]71
72e_fedid, e_local = get_experiment_names(resp_dict.get('experimentID', None))
73st = resp_dict.get('experimentStatus', None)
74
75if e_local: print "localname: %s" % e_local
76if e_fedid: print "fedid: %s" % e_fedid
77if st: print "status: %s" % st
Note: See TracBrowser for help on using the repository browser.