From d9749c3d9c35be54af7e5e8a24f72aa7ef1df2c4 Mon Sep 17 00:00:00 2001 From: Josh Karlin Date: Wed, 21 Apr 2010 18:46:12 +0000 Subject: [PATCH] Adding get_geni_aggregates. --- sfa/methods/get_geni_aggregates.py | 50 ++++++++++++++++++++++++++++++ sfa/methods/get_trusted_certs.py | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 sfa/methods/get_geni_aggregates.py diff --git a/sfa/methods/get_geni_aggregates.py b/sfa/methods/get_geni_aggregates.py new file mode 100644 index 00000000..edbb73b3 --- /dev/null +++ b/sfa/methods/get_geni_aggregates.py @@ -0,0 +1,50 @@ +### $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.namespace import * +from sfa.util.method import Method +from sfa.util.parameter import Parameter, Mixed +from sfa.trust.auth import Auth +from sfa.server.aggregate import Aggregates + +class get_geni_aggregates(Method): + """ + Get a list of connection information for all known GENI aggregates. + + @param cred credential string specifying the rights of the caller + @param a Human readable name (hrn or urn), or list of hrns or None + @return list of dictionaries with aggregate information. + """ + + interfaces = ['registry', 'aggregate', 'slicemgr'] + + accepts = [ + Parameter(str, "Credential string"), + Mixed(Parameter(str, "Human readable name (hrn or urn)"), + Parameter(None, "hrn not specified")) + ] + + + returns = [Parameter(dict, "Aggregate interface information")] + + def call(self, cred, xrn = None): + hrn, type = urn_to_hrn(xrn) + self.api.auth.check(cred, 'list') + geni_aggs = Aggregates(self.api, '/etc/sfa/geni_aggregates.xml') + hrn_list = [] + if hrn: + if isinstance(hrn, StringTypes): + hrn_list = [hrn] + elif isinstance(hrn, list): + hrn_list = hrn + + if not hrn_list: + interfaces = geni_aggs.interfaces + else: + interfaces = [interface for interface in geni_aggs.interfaces if interface['hrn'] in hrn_list] + + # Remove empty interfaces + interfaces = [interface for interface in interfaces if interface['hrn'] != ''] + + return interfaces diff --git a/sfa/methods/get_trusted_certs.py b/sfa/methods/get_trusted_certs.py index 334734b2..6ae4d50e 100644 --- a/sfa/methods/get_trusted_certs.py +++ b/sfa/methods/get_trusted_certs.py @@ -20,7 +20,7 @@ class get_trusted_certs(Method): Parameter(None, "Credential not specified")) ] - returns = Parameter([str], "List of GID strings") + returns = Parameter(type([str]), "List of GID strings") def call(self, cred = None): # If cred is not specified just return the gid for this interface. -- 2.47.0