### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/get_registries.py $
from types import StringTypes
from sfa.util.faults import *
-from sfa.util.misc import *
+from sfa.util.xrn import urn_to_hrn
from sfa.util.method import Method
from sfa.util.parameter import Parameter, Mixed
from sfa.trust.auth import Auth
Get a list of connection information for all known registries.
@param cred credential string specifying the rights of the caller
- @param a Human readable name (hrn), or list of hrns or None
+ @param a Human readable name (hrn or urn), or list of names or None
@return list of dictionaries with aggregate information.
"""
accepts = [
Parameter(str, "Credential string"),
-
- Mixed(Parameter(str, "Human readable name (hrn)"),
- Parameter(None, "hrn not specified")),
- Parameter(str, "Request hash")
+ Mixed(Parameter(str, "Human readable name (hrn or urn)"),
+ Parameter(None, "hrn not specified"))
]
returns = [Parameter(dict, "Registry interface information")]
- def call(self, cred, hrn = None, request_hash=None):
- self.api.auth.authenticateCred(cred, [cred, hrn], request_hash)
+ def call(self, cred, xrn = None):
+ hrn, type = urn_to_hrn(xrn)
self.api.auth.check(cred, 'list')
- registries = Registries(self.api)
- hrn_list = []
+ registries = Registries(self.api).interfaces.values()
if hrn:
- if isinstance(hrn, StringTypes):
- hrn_list = [hrn]
- elif isinstance(hrn, list):
- hrn_list = hrn
-
- if not hrn_list:
- interfaces = registries.interfaces
- else:
- interfaces = [interface for interface in registries.interfaces if interface['hrn'] in hrn_list]
-
- return interfaces
- return registries.interfaces
+ registries = [reg for reg in registries if reg['hrn'] == hrn]
+ return registries