source: fedd/fedd_ftopo.py @ cd5b279

compt_changes
Last change on this file since cd5b279 was 6bedbdba, checked in by Ted Faber <faber@…>, 13 years ago

Split topdl and fedid out to different packages. Add differential
installs

  • Property mode set to 100755
File size: 2.3 KB
RevLine 
[2e46f35]1#!/usr/bin/env python
[d743d60]2
3import sys
4
[6bedbdba]5from deter import topdl
6from deter import fedid
7
[e83f2f2]8from federation.proof import proof
[d743d60]9from federation.remote_service import service_caller
10from federation.client_lib import client_opts, exit_with_fault, RPCException,\
[e83f2f2]11        wrangle_standard_options, do_rpc, get_experiment_names, info_format, \
12        log_authentication
[d743d60]13
14class ftopo_opts(client_opts):
15    def __init__(self):
16        client_opts.__init__(self)
17        self.add_option("--experiment_cert", dest="exp_certfile",
[62f3dd9]18                action='callback', callback=self.expand_file, type='str',
19                help="experiment certificate file")
[d743d60]20        self.add_option("--experiment_name", dest="exp_name",
21                type="string", help="human readable experiment name")
[6e33086]22        self.add_option("--fresh", dest="fresh", action="store_true",
23                default=False, help="Force controller to gather fresh status")
[d743d60]24
25parser = ftopo_opts()
26(opts, args) = parser.parse_args()
27try:
[5d854e1]28    cert, fid, url = wrangle_standard_options(opts)
[d743d60]29except RuntimeError, e:
30    sys.exit("%s" % e)
31
32if opts.exp_name and opts.exp_certfile:
33    sys.exit("Only one of --experiment_cert and --experiment_name permitted")
34elif opts.exp_certfile:
35    exp_id = { 'fedid': fedid(file=opts.exp_certfile) }
36elif opts.exp_name:
37    exp_id = { 'localname' : opts.exp_name }
38else:
39    sys.exit("specify one of --experiment_cert and --experiment_name")
40
[6e33086]41req = { 'experiment': exp_id, 'fresh': opts.fresh }
[d743d60]42
43try:
44    resp_dict = do_rpc(req,
[5d854e1]45            url, opts.transport, cert, opts.trusted, 
[d743d60]46            serialize_only=opts.serialize_only,
47            tracefile=opts.tracefile,
48            caller=service_caller('Info'), responseBody='InfoResponseBody')
49except RPCException, e:
[e83f2f2]50    exit_with_fault(e, 'Ftopo', opts)
[d743d60]51except RuntimeError, e:
52    sys.exit("Error processing RPC: %s" % e)
53
54if 'experimentdescription' in resp_dict and \
55        'topdldescription' in resp_dict['experimentdescription']:
[ce81d09]56    top = topdl.Topology(
57            **resp_dict['experimentdescription']['topdldescription'])
58    for e in top.elements:
[29d5f7c]59        if isinstance(e, topdl.Computer):
60            print ":".join((e.name, ",".join(e.localname), e.status,
61                ",".join(e.operation), e.get_attribute('testbed') or ""))
[d743d60]62else:
[ce81d09]63    sys.exit("Badly formatted response (no experiment descrption)!?")
[e83f2f2]64proof = proof.from_dict(resp_dict.get('proof', {}))
65if proof and opts.auth_log:
66    log_authentication(opts.auth_log, 'Ftopo', 'succeeded', proof)
Note: See TracBrowser for help on using the repository browser.