- value returned is now xml-rpc safe
authorTony Mack <tmack@cs.princeton.edu>
Tue, 19 Sep 2006 19:36:29 +0000 (19:36 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Tue, 19 Sep 2006 19:36:29 +0000 (19:36 +0000)
PLC/Methods/AdmGetNodeGroups.py

index 6ceaba8..e6a81be 100644 (file)
@@ -34,7 +34,7 @@ class AdmGetNodeGroups(Method):
         assert self.caller is not None
 
         # Get nodes in this nodegroup
-       nodegroups = NodeGroups(self.api, nodegroup_id_or_name_list)    
+       nodegroups = NodeGroups(self.api, nodegroup_id_or_name_list).values()   
 
        # make sure sites are found
        if not nodegroups:
@@ -44,4 +44,11 @@ class AdmGetNodeGroups(Method):
        elif not len(nodegroups) == len(nodegroup_id_or_name_list):
                raise PLCInvalidArgument, "at least one node group id is invalid"
        
-        return nodegroups.values()
+       # Filter out undesired or None fields (XML-RPC cannot marshal
+        # None) and turn each node into a real dict.
+        valid_return_fields_only = lambda (key, value): \
+                                   key in NodeGroup.all_fields and value is not None
+        nodegroups = [dict(filter(valid_return_fields_only, nodegroup.items())) \
+                 for nodegroup in nodegroups]
+
+        return nodegroups