taking out debug statement from the previous commit
[sfa.git] / sfa / methods / get_aggregates.py
index c057fa0..703bd5c 100644 (file)
@@ -1,6 +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.method import Method
@@ -21,15 +21,29 @@ 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)"),
+              Parameter(None, "hrn not specified")),
+        Mixed(Parameter(str, "Request hash"),
+              Parameter(None, "Request hash not specified"))
         ]
 
     returns = [Parameter(dict, "Aggregate interface information")]
     
-    def call(self, cred, hrn = None):
-       
+    def call(self, cred, hrn = None, request_hash=None):
+        self.api.auth.authenticateCred(cred, [cred, hrn], request_hash) 
         self.api.auth.check(cred, 'list')
         aggregates = Aggregates(self.api)
-        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