From: Mark Huang Date: Thu, 11 Jan 2007 05:46:58 +0000 (+0000) Subject: - remove PLCCheckLocal functions, be more explicit about the error in X-Git-Tag: pycurl-7_13_1~132 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=ac29a9eebfa173766903dbc8c06c01fc18335bab;p=plcapi.git - remove PLCCheckLocal functions, be more explicit about the error in each method --- diff --git a/PLC/Methods/AddConfFileToNode.py b/PLC/Methods/AddConfFileToNode.py index 0c4899e5..3fa9c57c 100644 --- a/PLC/Methods/AddConfFileToNode.py +++ b/PLC/Methods/AddConfFileToNode.py @@ -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']: diff --git a/PLC/Methods/AddNodeToNodeGroup.py b/PLC/Methods/AddNodeToNodeGroup.py index 76696986..6829daf3 100644 --- a/PLC/Methods/AddNodeToNodeGroup.py +++ b/PLC/Methods/AddNodeToNodeGroup.py @@ -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]) diff --git a/PLC/Methods/AddNodeToPCU.py b/PLC/Methods/AddNodeToPCU.py index 0c634115..ff405413 100644 --- a/PLC/Methods/AddNodeToPCU.py +++ b/PLC/Methods/AddNodeToPCU.py @@ -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']: diff --git a/PLC/Methods/AddPersonKey.py b/PLC/Methods/AddPersonKey.py index 6badf399..0c362846 100644 --- a/PLC/Methods/AddPersonKey.py +++ b/PLC/Methods/AddPersonKey.py @@ -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']: diff --git a/PLC/Methods/AddPersonToSite.py b/PLC/Methods/AddPersonToSite.py index 6eb5072e..abc3a70f 100644 --- a/PLC/Methods/AddPersonToSite.py +++ b/PLC/Methods/AddPersonToSite.py @@ -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) diff --git a/PLC/Methods/AdmDeletePersonKeys.py b/PLC/Methods/AdmDeletePersonKeys.py index 57c63f0d..fd24eefc 100644 --- a/PLC/Methods/AdmDeletePersonKeys.py +++ b/PLC/Methods/AdmDeletePersonKeys.py @@ -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']: diff --git a/PLC/Methods/AdmGenerateNodeConfFile.py b/PLC/Methods/AdmGenerateNodeConfFile.py index 8781e557..85789bd7 100644 --- a/PLC/Methods/AdmGenerateNodeConfFile.py +++ b/PLC/Methods/AdmGenerateNodeConfFile.py @@ -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. diff --git a/PLC/Methods/DeleteKey.py b/PLC/Methods/DeleteKey.py index 3920db3a..313c2a42 100644 --- a/PLC/Methods/DeleteKey.py +++ b/PLC/Methods/DeleteKey.py @@ -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']: diff --git a/PLC/Methods/DeleteNode.py b/PLC/Methods/DeleteNode.py index c998bdc2..48bff2e9 100644 --- a/PLC/Methods/DeleteNode.py +++ b/PLC/Methods/DeleteNode.py @@ -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. diff --git a/PLC/Methods/DeletePerson.py b/PLC/Methods/DeletePerson.py index 93ae8588..d789adcd 100644 --- a/PLC/Methods/DeletePerson.py +++ b/PLC/Methods/DeletePerson.py @@ -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 diff --git a/PLC/Methods/DeletePersonFromSite.py b/PLC/Methods/DeletePersonFromSite.py index b4974637..84ea0a9f 100644 --- a/PLC/Methods/DeletePersonFromSite.py +++ b/PLC/Methods/DeletePersonFromSite.py @@ -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) diff --git a/PLC/Methods/DeleteSite.py b/PLC/Methods/DeleteSite.py index 4dde7cc7..5a832218 100644 --- a/PLC/Methods/DeleteSite.py +++ b/PLC/Methods/DeleteSite.py @@ -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() diff --git a/PLC/Methods/DeleteSlice.py b/PLC/Methods/DeleteSlice.py index e635b0da..bfb6cd60 100644 --- a/PLC/Methods/DeleteSlice.py +++ b/PLC/Methods/DeleteSlice.py @@ -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']: diff --git a/PLC/Methods/DeleteSliceAttribute.py b/PLC/Methods/DeleteSliceAttribute.py index c283c452..11ad0180 100644 --- a/PLC/Methods/DeleteSliceAttribute.py +++ b/PLC/Methods/DeleteSliceAttribute.py @@ -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'] diff --git a/PLC/Methods/DeleteSliceAttributeType.py b/PLC/Methods/DeleteSliceAttributeType.py index ab109119..922b6acc 100644 --- a/PLC/Methods/DeleteSliceAttributeType.py +++ b/PLC/Methods/DeleteSliceAttributeType.py @@ -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']] diff --git a/PLC/Methods/DeleteSliceFromNodes.py b/PLC/Methods/DeleteSliceFromNodes.py index 321169e3..75c72766 100644 --- a/PLC/Methods/DeleteSliceFromNodes.py +++ b/PLC/Methods/DeleteSliceFromNodes.py @@ -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']: diff --git a/PLC/Methods/SetPersonPrimarySite.py b/PLC/Methods/SetPersonPrimarySite.py index e2e913fb..9eff75ca 100644 --- a/PLC/Methods/SetPersonPrimarySite.py +++ b/PLC/Methods/SetPersonPrimarySite.py @@ -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" diff --git a/PLC/Methods/UpdateKey.py b/PLC/Methods/UpdateKey.py index 15a01ce9..a1754ff7 100644 --- a/PLC/Methods/UpdateKey.py +++ b/PLC/Methods/UpdateKey.py @@ -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']: diff --git a/PLC/Methods/UpdateNode.py b/PLC/Methods/UpdateNode.py index 9fa52592..5440307e 100644 --- a/PLC/Methods/UpdateNode.py +++ b/PLC/Methods/UpdateNode.py @@ -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 diff --git a/PLC/Methods/UpdateSite.py b/PLC/Methods/UpdateSite.py index cbd359e3..c9c40b7f 100644 --- a/PLC/Methods/UpdateSite.py +++ b/PLC/Methods/UpdateSite.py @@ -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 diff --git a/PLC/Methods/UpdateSlice.py b/PLC/Methods/UpdateSlice.py index ac454af0..391f2215 100644 --- a/PLC/Methods/UpdateSlice.py +++ b/PLC/Methods/UpdateSlice.py @@ -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']: diff --git a/PLC/Methods/UpdateSliceAttribute.py b/PLC/Methods/UpdateSliceAttribute.py index 81096a45..14e77543 100644 --- a/PLC/Methods/UpdateSliceAttribute.py +++ b/PLC/Methods/UpdateSliceAttribute.py @@ -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'] diff --git a/PLC/Methods/UpdateSliceAttributeType.py b/PLC/Methods/UpdateSliceAttributeType.py index 4dc852f7..a6c77014 100644 --- a/PLC/Methods/UpdateSliceAttributeType.py +++ b/PLC/Methods/UpdateSliceAttributeType.py @@ -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()