X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmethods%2Fget_aggregates.py;h=59d6001a47d70831172df1e775862785645aff49;hb=bfcea75fd4f7d91b186f4f0e479db0e6f0a231ae;hp=c057fa02a40950d95bffaebb7988d56e7c4249de;hpb=659c7d28a74bc258eab939928b43c05df46960fb;p=sfa.git diff --git a/sfa/methods/get_aggregates.py b/sfa/methods/get_aggregates.py index c057fa02..59d6001a 100644 --- a/sfa/methods/get_aggregates.py +++ b/sfa/methods/get_aggregates.py @@ -1,8 +1,6 @@ -### $Id: get_slices.py 14387 2009-07-08 18:19:11Z faiyaza $ -### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/get_aggregates.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 @@ -13,7 +11,7 @@ class get_aggregates(Method): Get a list of connection information for all known aggregates. @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 hrns or None @return list of dictionaries with aggregate information. """ @@ -21,15 +19,16 @@ class get_aggregates(Method): accepts = [ Parameter(str, "Credential string"), - Mixed([Parameter(str, "Human readable name (hrn)")], - Parameter(str, "Human readable name (hrn)"), - Parameter(None, "hrn not specified")) + Mixed(Parameter(str, "Human readable name (hrn or urn)"), + Parameter(None, "hrn not specified")) ] returns = [Parameter(dict, "Aggregate interface information")] - def call(self, cred, hrn = None): - + def call(self, cred, xrn = None): + hrn, type = urn_to_hrn(xrn) self.api.auth.check(cred, 'list') - aggregates = Aggregates(self.api) - return aggregates.interfaces + aggregates = Aggregates(self.api).interfaces.values() + if hrn: + aggregates = [agg for agg in aggregates if agg['hrn'] == hrn] + return aggregates