listcomponents.py 1.88 KB
Newer Older
1 2
#! /usr/bin/env python
#
3
# GENIPUBLIC-COPYRIGHT
4
# Copyright (c) 2008-2010 University of Utah and the Flux Group.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
# All rights reserved.
# 
# Permission to use, copy, modify and distribute this software is hereby
# granted provided that (1) source code retains these copyright, permission,
# and disclaimer notices, and (2) redistributions including binaries
# reproduce the notices in supporting documentation.
#
# THE UNIVERSITY OF UTAH ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
# CONDITION.  THE UNIVERSITY OF UTAH DISCLAIMS ANY LIABILITY OF ANY KIND
# FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
#

#
#
import sys
import pwd
import getopt
import os
import re
import xmlrpclib
25
from M2Crypto import X509
26
import zlib
27

28
execfile( "test-common.py" )
29 30 31 32

#
# Get a credential for myself, that allows me to do things at the SA.
#
33
mycredential = get_self_credential()
34 35

#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
36
# Ask the clearinghouse for a list of component managers. 
37 38 39
#
params = {}
params["credential"] = mycredential
40
rval,response = do_method("ch", "ListComponents", params)
41
if rval:
Leigh B. Stoller's avatar
Leigh B. Stoller committed
42
    Fatal("Could not get a list of components from the ClearingHouse")
43
    pass
44
if debug: print str(response["value"])
45 46 47 48 49

#
# Ask each manager for its list.
#
for manager in response["value"]:
50
    print manager[ "urn" ] + ": " + manager["url"]
51

52 53 54
    # Skip the discover resources. Too much.
    continue
    
55 56 57 58 59
    #
    # manager for resource list.
    #
    params = {}
    params["credential"] = mycredential
60
    params["available"] = True
61
    params["compress"] = True
62 63 64 65
    rval,response = do_method(None,
                              "DiscoverResources", params, manager["url"])
    if rval:
        print "Could not get a list of resources"
66 67 68 69 70 71
    else:
        if isinstance( response[ "value" ], xmlrpclib.Binary ):
            response[ "value" ] = zlib.decompress( str( response[ "value" ] ) )

        if debug:
            print response[ "value" ]