git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added support for urn name format. urn is the default name format used over the wire
[sfa.git]
/
sfa
/
methods
/
get_aggregates.py
diff --git
a/sfa/methods/get_aggregates.py
b/sfa/methods/get_aggregates.py
index
4e45969
..
da9859a
100644
(file)
--- a/
sfa/methods/get_aggregates.py
+++ b/
sfa/methods/get_aggregates.py
@@
-1,8
+1,8
@@
### $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 $
### $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.faults import *
-from sfa.util.
misc
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.util.method import Method
from sfa.util.parameter import Parameter, Mixed
from sfa.trust.auth import Auth
@@
-13,7
+13,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
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.
"""
@return list of dictionaries with aggregate information.
"""
@@
-21,17
+21,26
@@
class get_aggregates(Method):
accepts = [
Parameter(str, "Credential string"),
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")]
]
returns = [Parameter(dict, "Aggregate interface information")]
- def call(self, cred,
h
rn = None):
-
+ def call(self, cred,
x
rn = None):
+ hrn, type = urn_to_hrn(xrn)
self.api.auth.check(cred, 'list')
aggregates = Aggregates(self.api)
self.api.auth.check(cred, 'list')
aggregates = Aggregates(self.api)
- print "SHIT"
- print aggregates.interfaces
- return aggregates.interfaces
+ hrn_list = []
+ if hrn:
+ if isinstance(hrn, StringTypes):
+ hrn_list = [hrn]
+ elif isinstance(hrn, list):
+ hrn_list = hrn
+
+ if not hrn_list:
+ interfaces = aggregates.interfaces
+ else:
+ interfaces = [interface for interface in aggregates.interfaces if interface['hrn'] in hrn_list]
+
+ return interfaces