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

index a1fd3a8..48f2cb7 100644 (file)
@@ -22,7 +22,7 @@ class AdmGetAllNodeNetworks(Method):
                Node.fields['hostname'])
         ]
 
-    returns = [NodeNetwork.all_fields]
+    #returns = [NodeNetwork.all_fields]
 
     def call(self, auth, node_id_or_hostname):
         # Authenticated function
@@ -40,4 +40,12 @@ class AdmGetAllNodeNetworks(Method):
                raise PLCInvalidArgument, "Node has no node networks"
        nodenetworks = NodeNetworks(self.api, nodenetwork_ids).values()            
 
-        return nodenetworks
+       # 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 NodeNetwork.all_fields and value is not None
+        nodenetworks = [dict(filter(valid_return_fields_only, nodenetwork.items())) \
+                 for nodenetwork in nodenetworks]      
+
+               
+       return nodenetworks