namespace module is gone, plxrn provides PL-specific translations
[sfa.git] / sfa / methods / get_aggregates.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.aggregate import Aggregates
8
9 class get_aggregates(Method):
10     """
11     Get a list of connection information for all known aggregates.      
12
13     @param cred credential string specifying the rights of the caller
14     @param a Human readable name (hrn or urn), or list of hrns 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, "Aggregate 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         aggregates = Aggregates(self.api).interfaces.values()
32         if hrn:
33             aggregates = [agg for agg in aggregates if agg['hrn'] == hrn]
34         return aggregates