- fix comments
authorMark Huang <mlhuang@cs.princeton.edu>
Wed, 20 Sep 2006 14:41:48 +0000 (14:41 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Wed, 20 Sep 2006 14:41:48 +0000 (14:41 +0000)
- remove unnecessary imports and assertions
- naming nits

PLC/Methods/AdmGetNodeGroupNodes.py

index b641662..a82ed56 100644 (file)
@@ -1,16 +1,12 @@
-import os
-
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
-from PLC.Sites import Site, Sites
-from PLC.Nodes import Node, Nodes
 from PLC.Auth import PasswordAuth
 from PLC.NodeGroups import NodeGroup, NodeGroups
+
 class AdmGetNodeGroupNodes(Method):
     """
-    Return a list of node_ids for the node group specified.
-
+    Returns a list of node_ids for the node group specified.
     """
 
     roles = ['admin', 'pi', 'user', 'tech']
@@ -21,24 +17,16 @@ class AdmGetNodeGroupNodes(Method):
              NodeGroup.fields['name'])
         ]
 
-    returns = [NodeGroup.join_fields['node_ids']]
-
+    returns = NodeGroup.join_fields['node_ids']
 
     def call(self, auth, nodegroup_id_or_name):
-        # Authenticated function
-        assert self.caller is not None
-
         # Get nodes in this nodegroup
-       nodegroup = NodeGroups(self.api, [nodegroup_id_or_name])        
+       nodegroups = NodeGroups(self.api, [nodegroup_id_or_name])
+       if not nodegroups:
+            raise PLCInvalidArgument, "No such node group"
 
-       # make sure nodegroup is found
-       if not nodegroup:
-               raise PLCInvalidArgument, "No such nodegroup"
-       
-       #get the info for the node group specified
-       nodegroup_values = nodegroup.values()[0]
+       # Get the info for the node group specified
+       nodegroup = nodegroups.values()[0]
 
-       #grab the list of node ides fromt the disctioary
-       node_ids = nodegroup_values['node_ids']
-       
-        return node_ids
+       # Return the list of node_ids
+        return nodegroup['node_ids']