rename flush() to sync(), removed {default,all,join}_fields
authorMark Huang <mlhuang@cs.princeton.edu>
Mon, 25 Sep 2006 15:23:36 +0000 (15:23 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Mon, 25 Sep 2006 15:23:36 +0000 (15:23 +0000)
16 files changed:
PLC/Methods/AdmAddNodeGroup.py
PLC/Methods/AdmAddNodeNetwork.py
PLC/Methods/AdmAddPerson.py
PLC/Methods/AdmAddSite.py
PLC/Methods/AdmGetAllNodeNetworks.py
PLC/Methods/AdmGetNodeGroupNodes.py
PLC/Methods/AdmGetNodeGroups.py
PLC/Methods/AdmGetPersons.py
PLC/Methods/AdmGetSitePersons.py
PLC/Methods/AdmGetSites.py
PLC/Methods/AdmSetPersonEnabled.py
PLC/Methods/AdmUpdateNode.py
PLC/Methods/AdmUpdateNodeGroup.py
PLC/Methods/AdmUpdateNodeNetwork.py
PLC/Methods/AdmUpdatePerson.py
PLC/Methods/AdmUpdateSite.py

index 88efa7a..328bb43 100644 (file)
@@ -25,6 +25,6 @@ class AdmAddNodeGroup(Method):
     def call(self, auth, name, description):
        # Create node group
         nodegroup = NodeGroup(self.api, {'name': name, 'description': description})
-        nodegroup.flush()
+        nodegroup.sync()
 
         return nodegroup['nodegroup_id']
index f46ebef..d43d54b 100644 (file)
@@ -26,7 +26,7 @@ class AdmAddNodeNetwork(Method):
     can_update = lambda (field, value): field in \
                  ['ip', 'mac', 'gateway', 'network', 'broadcast', 'netmask',
                   'dns1', 'dns2', 'hostname', 'bwlimit', 'is_primary']
-    update_fields = dict(filter(can_update, NodeNetwork.all_fields.items()))
+    update_fields = dict(filter(can_update, NodeNetwork.fields.items()))
 
     accepts = [
         PasswordAuth(),
@@ -61,7 +61,7 @@ class AdmAddNodeNetwork(Method):
        nodenetwork = NodeNetwork(self.api, optional_vals)
        nodenetwork['method'] = method
         nodenetwork['type'] = type
-        nodenetwork.flush(commit = False)
+        nodenetwork.sync(commit = False)
 
         # Associate node network with node
         node.add_node_network(nodenetwork, commit = False)
index 574f050..7fd5db2 100644 (file)
@@ -38,6 +38,6 @@ class AdmAddPerson(Method):
         person['first_name'] = first_name
         person['last_name'] = last_name
         person['enabled'] = False
-        person.flush()
+        person.sync()
 
         return person['person_id']
index d43d357..e8c7dbc 100644 (file)
@@ -38,6 +38,6 @@ class AdmAddSite(Method):
         site['name'] = name
         site['abbreviated_name'] = abbreviated_name
         site['login_base'] = login_base
-        site.flush()
+        site.sync()
 
         return site['site_id']
index bcd2ac4..18e8131 100644 (file)
@@ -16,10 +16,10 @@ class AdmGetAllNodeNetworks(Method):
     accepts = [
         PasswordAuth(),
         Mixed(Node.fields['node_id'],
-               Node.fields['hostname'])
+              Node.fields['hostname'])
         ]
 
-    returns = [NodeNetwork.all_fields]
+    returns = [NodeNetwork.fields]
 
     def call(self, auth, node_id_or_hostname):
         # Authenticated function
index a82ed56..ab9aaf2 100644 (file)
@@ -17,7 +17,7 @@ class AdmGetNodeGroupNodes(Method):
              NodeGroup.fields['name'])
         ]
 
-    returns = NodeGroup.join_fields['node_ids']
+    returns = NodeGroup.fields['node_ids']
 
     def call(self, auth, nodegroup_id_or_name):
         # Get nodes in this nodegroup
index 6d45c20..4cf527e 100644 (file)
@@ -19,7 +19,7 @@ class AdmGetNodeGroups(Method):
               NodeGroup.fields['name'])]
         ]
 
-    returns = [NodeGroup.all_fields]
+    returns = [NodeGroup.fields]
   
     def call(self, auth, nodegroup_id_or_name_list = None):
         # Get node group details
index b42391f..42a6965 100644 (file)
@@ -32,14 +32,13 @@ class AdmGetPersons(Method):
 
     # Filter out password and deleted fields
     can_return = lambda (field, value): field not in ['password', 'deleted']
-    default_fields = dict(filter(can_return, Person.default_fields.items()))
-    return_fields = dict(filter(can_return, Person.all_fields.items()))
+    return_fields = dict(filter(can_return, Person.fields.items()))
     returns = [return_fields]
 
     def __init__(self, *args, **kwds):
         Method.__init__(self, *args, **kwds)
         # Update documentation with list of default fields returned
-        self.__doc__ += os.linesep.join(self.default_fields.keys())
+        self.__doc__ += os.linesep.join(self.return_fields.keys())
 
     def call(self, auth, person_id_or_email_list = None, return_fields = None):
         # Make sure that only valid fields are specified
index 220373f..071c532 100644 (file)
@@ -20,7 +20,7 @@ class AdmGetSitePersons(Method):
               Site.fields['login_base'])
         ]
 
-    returns = Site.all_fields['person_ids']
+    returns = Site.fields['person_ids']
 
     def call(self, auth, site_id_or_login_base):
         # Authenticated function
index 5f74fcf..5f4cf33 100644 (file)
@@ -27,13 +27,13 @@ class AdmGetSites(Method):
 
     # Filter out deleted fields
     can_return = lambda (field, value): field not in ['deleted']
-    return_fields = dict(filter(can_return, Site.all_fields.items()))
+    return_fields = dict(filter(can_return, Site.fields.items()))
     returns = [return_fields]
 
     def __init__(self, *args, **kwds):
         Method.__init__(self, *args, **kwds)
         # Update documentation with list of default fields returned
-        self.__doc__ += os.linesep.join(Site.default_fields.keys())
+        self.__doc__ += os.linesep.join(self.return_fields.keys())
 
     def call(self, auth, site_id_or_login_base_list = None, return_fields = None):
         # Make sure that only valid fields are specified
index 87aa923..d97075b 100644 (file)
@@ -42,6 +42,6 @@ class AdmSetPersonEnabled(Method):
             raise PLCPermissionDenied, "Not allowed to enable specified account"
 
         person['enabled'] = enabled
-        person.flush()
+        person.sync()
 
         return 1
index 109e0af..39f1f54 100644 (file)
@@ -62,12 +62,7 @@ class AdmUpdateNode(Method):
             if node['site_id'] not in self.caller['site_ids']:
                 raise PLCPermissionDenied, "Not allowed to delete nodes from specified site"
 
-        # Check if we can update this account
-        node = nodes.values()[0]
-        if not self.caller.can_update(node):
-            raise PLCPermissionDenied, "Not allowed to update specified account"
-
         node.update(update_fields)
-        node.flush()
+        node.sync()
 
         return 1
index 90aae6e..e246a7c 100644 (file)
@@ -38,6 +38,6 @@ class AdmUpdateNodeGroup(Method):
             }
 
        nodegroup.update(update_fields)
-        nodegroup.flush()
+        nodegroup.sync()
 
         return 1
index 8977cbe..beda9df 100644 (file)
@@ -71,6 +71,6 @@ class AdmUpdateNodeNetwork(Method):
 
        # Update node network
        nodenetwork.update(update_fields)
-        nodenetwork.flush()
+        nodenetwork.sync()
        
         return 1
index a24ab2a..46c4267 100644 (file)
@@ -63,6 +63,6 @@ class AdmUpdatePerson(Method):
             raise PLCPermissionDenied, "Not allowed to update specified account"
 
         person.update(update_fields)
-        person.flush()
+        person.sync()
 
         return 1
index 13eb813..35e18b4 100644 (file)
@@ -25,9 +25,8 @@ class AdmUpdateSite(Method):
     can_update = lambda (field, value): field in \
                  ['name', 'abbreviated_name',
                   'is_public', 'latitude', 'longitude', 'url',
-                  'organization_id', 'ext_consortium_id',
-                  'max_slices', 'site_share']
-    update_fields = dict(filter(can_update, Site.all_fields.items()))
+                  'max_slices']
+    update_fields = dict(filter(can_update, Site.fields.items()))
 
     accepts = [
         PasswordAuth(),
@@ -72,6 +71,6 @@ class AdmUpdateSite(Method):
                 raise PLCInvalidArgument, "Only admins can update max_slices"
 
         site.update(update_fields)
-       site.flush()
+       site.sync()
        
        return 1