X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=inline;f=PLC%2FMethods%2FDeletePersonFromSlice.py;h=8cdd31651e4d8f279ff5437b0ccee231a0ea11dd;hb=bd0cbf4f7f2e4cf7ceda500bfa6f98c0a700018b;hp=f21db58e435ad9d2ac9ead0eab96e807f29034b9;hpb=e347fc823bbba9d88a3fddf07d5c21024dfd1e55;p=plcapi.git diff --git a/PLC/Methods/DeletePersonFromSlice.py b/PLC/Methods/DeletePersonFromSlice.py index f21db58..8cdd316 100644 --- a/PLC/Methods/DeletePersonFromSlice.py +++ b/PLC/Methods/DeletePersonFromSlice.py @@ -8,7 +8,7 @@ from PLC.Auth import Auth class DeletePersonFromSlice(Method): """ Deletes the specified person from the specified slice. If the person is - not a member of the slice, no errors are returned. + not a member of the slice, no errors are returned. Returns 1 if successful, faults otherwise. """ @@ -30,23 +30,30 @@ class DeletePersonFromSlice(Method): persons = Persons(self.api, [person_id_or_email]) if not persons: raise PLCInvalidArgument, "No such account" - person = persons[0] # Get slice information slices = Slices(self.api, [slice_id_or_name]) if not slices: raise PLCInvalidArgument, "No such slice" - slice = slices[0] + # N.B. Allow foreign users to be added to local slices and + # local users to be added to foreign slices (and, of course, + # local users to be added to local slices). + if person['peer_id'] is not None and slice['peer_id'] is not None: + raise PLCInvalidArgument, "Cannot delete foreign users from foreign slices" + # If we are not admin, make sure the caller is a pi # of the site associated with the slice - if 'admin' not in self.caller['roles']: - if slice['site_id'] not in self.caller['site_ids']: - raise PLCPermissionDenied, "Not allowed to delete users from this slice" + if 'admin' not in self.caller['roles']: + if slice['site_id'] not in self.caller['site_ids']: + raise PLCPermissionDenied, "Not allowed to delete users from this slice" - if slice['slice_id'] in person['slice_ids']: + if slice['slice_id'] in person['slice_ids']: slice.remove_person(person) + self.event_objects = {'Slice': [slice['slice_id']], + 'Person': [person['person_id']]} + return 1