- remove PLCCheckLocal functions, be more explicit about the error in
authorMark Huang <mlhuang@cs.princeton.edu>
Thu, 11 Jan 2007 05:46:58 +0000 (05:46 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Thu, 11 Jan 2007 05:46:58 +0000 (05:46 +0000)
  each method

23 files changed:
PLC/Methods/AddConfFileToNode.py
PLC/Methods/AddNodeToNodeGroup.py
PLC/Methods/AddNodeToPCU.py
PLC/Methods/AddPersonKey.py
PLC/Methods/AddPersonToSite.py
PLC/Methods/AdmDeletePersonKeys.py
PLC/Methods/AdmGenerateNodeConfFile.py
PLC/Methods/DeleteKey.py
PLC/Methods/DeleteNode.py
PLC/Methods/DeletePerson.py
PLC/Methods/DeletePersonFromSite.py
PLC/Methods/DeleteSite.py
PLC/Methods/DeleteSlice.py
PLC/Methods/DeleteSliceAttribute.py
PLC/Methods/DeleteSliceAttributeType.py
PLC/Methods/DeleteSliceFromNodes.py
PLC/Methods/SetPersonPrimarySite.py
PLC/Methods/UpdateKey.py
PLC/Methods/UpdateNode.py
PLC/Methods/UpdateSite.py
PLC/Methods/UpdateSlice.py
PLC/Methods/UpdateSliceAttribute.py
PLC/Methods/UpdateSliceAttributeType.py

index 0c4899e..3fa9c57 100644 (file)
@@ -37,7 +37,9 @@ class AddConfFileToNode(Method):
        if not nodes:
                raise PLCInvalidArgument, "No such node"
        node = nodes[0]
-       PLCCheckLocalNode (node,"AddConfFileToNode")
+
+        if node['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local node"
        
        # Link configuration file to node
         if node['node_id'] not in conf_file['node_ids']:
index 7669698..6829daf 100644 (file)
@@ -32,7 +32,9 @@ class AddNodeToNodeGroup(Method):
        if not nodes:
                raise PLCInvalidArgument, "No such node"
        node = nodes[0]
-       PLCCheckLocalNode (node,"AddNodeToNodeGroup")
+
+        if node['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local node"
 
        # Get nodegroup info
         nodegroups = NodeGroups(self.api, [nodegroup_id_or_name])
index 0c63411..ff40541 100644 (file)
@@ -32,15 +32,15 @@ class AddNodeToPCU(Method):
         nodes = Nodes(self.api, [node_id_or_hostname])
         if not nodes:
             raise PLCInvalidArgument, "No such node"
-
         node = nodes[0]
-       PLCCheckLocalNode(node,"AddNodeToPCU")
+
+        if node['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local node"
 
         # Get PCU
         pcus = PCUs(self.api, [pcu_id])
         if not pcus:
             raise PLCInvalidArgument, "No such PCU"
-
         pcu = pcus[0]
 
         if 'admin' not in self.caller['roles']:
index 6badf39..0c36284 100644 (file)
@@ -38,7 +38,9 @@ class AddPersonKey(Method):
         if not persons:
             raise PLCInvalidArgument, "No such account"
         person = persons[0]
-       PLCCheckLocalPerson (person,"AddPersonKey")
+
+        if person['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local account"
 
        # If we are not admin, make sure caller is adding a key to their account
         if 'admin' not in self.caller['roles']:
index 6eb5072..abc3a70 100644 (file)
@@ -31,17 +31,19 @@ class AddPersonToSite(Method):
         persons = Persons(self.api, [person_id_or_email])
         if not persons:
             raise PLCInvalidArgument, "No such account"
-
         person = persons[0]
-       PLCCheckLocalPerson(person,"AddPersonToSite")
+
+        if person['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local account"
 
         # Get site information
         sites = Sites(self.api, [site_id_or_login_base])
         if not sites:
             raise PLCInvalidArgument, "No such site"
-
         site = sites[0]
-       PLCCheckLocalSite(site,"AddPersonToSite")
+
+        if site['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local site"
 
         if site['site_id'] not in person['site_ids']:
             site.add_person(person)
index 57c63f0..fd24eef 100644 (file)
@@ -34,9 +34,10 @@ class AdmDeletePersonKeys(Method):
         persons = Persons(self.api, [person_id_or_email])
         if not persons:
             raise PLCInvalidArgument, "No such account"
-
         person = persons[0]
-       PLCCheckLocalPerson(person,"AdmDeletePersonKeys")
+
+        if person['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local account"
 
         if 'admin' not in self.caller['roles']:
             if self.caller['person_id'] != person['person_id']:
index 8781e55..85789bd 100644 (file)
@@ -41,7 +41,9 @@ class AdmGenerateNodeConfFile(Method):
         if not nodes:
             raise PLCInvalidArgument, "No such node"
         node = nodes[0]
-       PLCCheckLocalNode(node,"AdmGenerateNodeConfFile")
+
+        if node['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local node"
 
         # If we are not an admin, make sure that the caller is a
         # member of the site at which the node is located.
index 3920db3..313c2a4 100644 (file)
@@ -29,7 +29,9 @@ class DeleteKey(Method):
         if not keys:
             raise PLCInvalidArgument, "No such key"
         key = keys[0]
-       PLCCheckLocalKey(key,"DeleteKey")
+
+        if key['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local key"
 
         if 'admin' not in self.caller['roles']:
             if key['key_id'] not in self.caller['key_ids']:
index c998bdc..48bff2e 100644 (file)
@@ -30,9 +30,10 @@ class DeleteNode(Method):
         nodes = Nodes(self.api, [node_id_or_hostname])
         if not nodes:
             raise PLCInvalidArgument, "No such node"
-
         node = nodes[0]
-       PLCCheckLocalNode(node,"DeleteNode")
+
+        if node['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local node"
 
         # If we are not an admin, make sure that the caller is a
         # member of the site at which the node is located.
index 93ae858..d789adc 100644 (file)
@@ -31,9 +31,10 @@ class DeletePerson(Method):
         persons = Persons(self.api, [person_id_or_email])
         if not persons:
             raise PLCInvalidArgument, "No such account"
-
         person = persons[0]
-       PLCCheckLocalPerson(person,"DeletePerson")
+
+        if person['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local account"
 
         # Authenticated function
         assert self.caller is not None
index b497463..84ea0a9 100644 (file)
@@ -32,16 +32,19 @@ class DeletePersonFromSite(Method):
         persons = Persons(self.api, [person_id_or_email])
         if not persons:
             raise PLCInvalidArgument, "No such account"
-
         person = persons[0]
 
+        if person['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local account"
+
         # Get site information
         sites = Sites(self.api, [site_id_or_login_base])
         if not sites:
             raise PLCInvalidArgument, "No such site"
-
         site = sites[0]
-       PLCCheckLocalSite(site,"DeletePersonFromSite")
+
+        if site['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local site"
 
         if site['site_id'] in person['site_ids']:
             site.remove_person(person)
index 4dde7cc..5a83221 100644 (file)
@@ -33,9 +33,10 @@ class DeleteSite(Method):
         sites = Sites(self.api, [site_id_or_login_base])
         if not sites:
             raise PLCInvalidArgument, "No such site"
-
         site = sites[0]
-       PLCCheckLocalSite(site,"DeleteSite")
+
+        if site['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local site"
 
         site.delete()
        
index e635b0d..bfb6cd6 100644 (file)
@@ -31,7 +31,9 @@ class DeleteSlice(Method):
         if not slices:
             raise PLCInvalidArgument, "No such slice"
         slice = slices[0]
-       PLCCheckLocalSlice(slice,"DeleteSlice")
+
+        if slice['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local slice"
 
         if 'admin' not in self.caller['roles']:
             if self.caller['person_id'] in slice['person_ids']:
index c283c45..11ad018 100644 (file)
@@ -34,13 +34,14 @@ class DeleteSliceAttribute(Method):
         if not slice_attributes:
             raise PLCInvalidArgument, "No such slice attribute"
         slice_attribute = slice_attributes[0]
-       PLCCheckLocalSliceAttribute(slice_attribute,"DeleteSliceAttribute")
 
         slices = Slices(self.api, [slice_attribute['slice_id']])
         if not slices:
             raise PLCInvalidArgument, "No such slice"
         slice = slices[0]
-       PLCCheckLocalSlice(slice,"DeleteSliceAttribute")
+
+        if slice['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local slice"
 
         assert slice_attribute['slice_attribute_id'] in slice['slice_attribute_ids']
 
index ab10911..922b6ac 100644 (file)
@@ -27,7 +27,6 @@ class DeleteSliceAttributeType(Method):
         if not attribute_types:
             raise PLCInvalidArgument, "No such slice attribute type"
         attribute_type = attribute_types[0]
-       PLCCheckLocalSliceAttributeType(attribute_type,"DeleteSliceAttributeType")
 
         attribute_type.delete()
        self.object_ids = [attribute_type['attribute_type_id']]
index 321169e..75c7276 100644 (file)
@@ -31,9 +31,10 @@ class DeleteSliceFromNodes(Method):
         slices = Slices(self.api, [slice_id_or_name])
         if not slices:
             raise PLCInvalidArgument, "No such slice"
-
         slice = slices[0]
-       PLCCheckLocalSlice(slice,"DeleteSliceFromNodes")
+
+        if slice['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local slice"
 
         if 'admin' not in self.caller['roles']:
             if self.caller['person_id'] in slice['person_ids']:
index e2e913f..9eff75c 100644 (file)
@@ -30,9 +30,10 @@ class SetPersonPrimarySite(Method):
         persons = Persons(self.api, [person_id_or_email])
         if not persons:
             raise PLCInvalidArgument, "No such account"
-
         person = persons[0]
-       PLCCheckLocalPerson(person,"SetPersonPrimarySite")
+
+        if person['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local account"
 
         # Authenticated function
         assert self.caller is not None
@@ -46,9 +47,10 @@ class SetPersonPrimarySite(Method):
         sites = Sites(self.api, [site_id_or_login_base])
         if not sites:
             raise PLCInvalidArgument, "No such site"
-
         site = sites[0]
-       PLCCheckLocalSite(site,"SetPersonPrimarySite")
+
+        if site['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local site"
 
         if site['site_id'] not in person['site_ids']:
             raise PLCInvalidArgument, "Not a member of the specified site"
index 15a01ce..a1754ff 100644 (file)
@@ -37,7 +37,9 @@ class UpdateKey(Method):
         if not keys:
             raise PLCInvalidArgument, "No such key"
         key = keys[0]
-       PLCCheckLocalKey(key,"UpdateKey")
+
+        if key['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local key"
 
         if 'admin' not in self.caller['roles']:
             if key['key_id'] not in self.caller['key_ids']:
index 9fa5259..5440307 100644 (file)
@@ -44,9 +44,10 @@ class UpdateNode(Method):
         nodes = Nodes(self.api, [node_id_or_hostname])
         if not nodes:
             raise PLCInvalidArgument, "No such node"
-
         node = nodes[0]
-       PLCCheckLocalNode(node,"UpdateNode")
+
+        if node['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local node"
 
         # Authenticated function
         assert self.caller is not None
index cbd359e..c9c40b7 100644 (file)
@@ -40,9 +40,10 @@ class UpdateSite(Method):
         sites = Sites(self.api, [site_id_or_login_base])
         if not sites:
             raise PLCInvalidArgument, "No such site"
-
         site = sites[0]
-       PLCCheckLocalSite(site,"UpdateSite")
+
+        if site['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local site"
 
         # Authenticated function
         assert self.caller is not None
index ac454af..391f221 100644 (file)
@@ -46,7 +46,9 @@ class UpdateSlice(Method):
         if not slices:
             raise PLCInvalidArgument, "No such slice"
         slice = slices[0]
-       PLCCheckLocalSlice(slice,"UpdateSlice")
+
+        if slice['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local slice"
 
         if 'admin' not in self.caller['roles']:
             if self.caller['person_id'] in slice['person_ids']:
index 81096a4..14e7754 100644 (file)
@@ -32,13 +32,14 @@ class UpdateSliceAttribute(Method):
         if not slice_attributes:
             raise PLCInvalidArgument, "No such slice attribute"
         slice_attribute = slice_attributes[0]
-       PLCCheckLocalSliceAttribute(slice_attribute,"UpdateSliceAttribute")
 
         slices = Slices(self.api, [slice_attribute['slice_id']])
         if not slices:
             raise PLCInvalidArgument, "No such slice"
         slice = slices[0]
-       PLCCheckLocalSlice(slice,"UpdateSliceAttribute")
+
+        if slice['peer_id'] is not None:
+            raise PLCInvalidArgument, "Not a local slice"
 
         assert slice_attribute['slice_attribute_id'] in slice['slice_attribute_ids']
 
index 4dc852f..a6c7701 100644 (file)
@@ -35,7 +35,6 @@ class UpdateSliceAttributeType(Method):
         if not attribute_types:
             raise PLCInvalidArgument, "No such attribute"
         attribute_type = attribute_types[0]
-       PLCCheckLocalSliceAttributeType(attribute_type,"UpdateSliceAttributeType")
 
         attribute_type.update(attribute_type_fields)
         attribute_type.sync()