b404bb97abe7818bf5e2f175d6e001973bf7d546
[sfa.git] / sfa / methods / get_registries.py
1 from types import StringTypes
2 from sfa.util.faults import *
3 from sfa.util.xrn import urn_to_hrn
4 from sfa.util.method import Method
5 from sfa.util.parameter import Parameter, Mixed
6 from sfa.trust.auth import Auth
7 from sfa.server.registry import Registries
8
9 class get_registries(Method):
10     """
11     Get a list of connection information for all known registries.      
12
13     @param cred credential string specifying the rights of the caller
14     @param a Human readable name (hrn or urn), or list of names or None
15     @return list of dictionaries with aggregate information.  
16     """
17
18     interfaces = ['registry', 'aggregate', 'slicemgr']
19     
20     accepts = [
21         Parameter(str, "Credential string"),
22         Mixed(Parameter(str, "Human readable name (hrn or urn)"),
23               Parameter(None, "hrn not specified"))
24         ]
25
26     returns = [Parameter(dict, "Registry interface information")]
27     
28     def call(self, cred, xrn = None):
29         hrn, type = urn_to_hrn(xrn)
30         self.api.auth.check(cred, 'list')
31         registries = Registries(self.api).interfaces.values()
32         if hrn:
33             registries = [reg for reg in registries if reg['hrn'] == hrn] 
34         return registries