filter results if hrn argument is specified
authorTony Mack <tmack@cs.princeton.edu>
Tue, 18 Aug 2009 22:44:13 +0000 (22:44 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Tue, 18 Aug 2009 22:44:13 +0000 (22:44 +0000)
sfa/methods/get_aggregates.py
sfa/methods/get_registries.py

index c057fa0..6f5bc7f 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
@@ -32,4 +32,16 @@ class get_aggregates(Method):
        
         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
index ed46b5a..69b0751 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_registries.py $
-
+from types import StringTypes
 from sfa.util.faults import *
 from sfa.util.misc import *
 from sfa.util.method import Method
@@ -32,4 +32,17 @@ class get_registries(Method):
        
         self.api.auth.check(cred, 'list')
         registries = Registries(self.api)
+        hrn_list = []
+        if hrn:
+            if isinstance(hrn, StringTypes):
+                hrn_list = [hrn]
+            elif isinstance(hrn, list):
+                hrn_list = hrn
+
+        if not hrn_list:
+            interfaces = registries.interfaces
+        else:
+            interfaces = [interface for interface in registries.interfaces if interface['hrn'] in hrn_list]
+
+        return interfaces
         return registries.interfaces