X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=PLC%2FMethods%2FDeletePersonFromSlice.py;h=e47ebbeae40f636a6f39f71f20abe3f77c8dd8a1;hb=28d7d3517f7c3de04ce65d449a0e948fde226863;hp=df8b367ad0fb89777da7b5c422d0bdc9fbfb9b0a;hpb=286cdfc25f6ef8fd3e0ed59a175bcf801b14038a;p=plcapi.git diff --git a/PLC/Methods/DeletePersonFromSlice.py b/PLC/Methods/DeletePersonFromSlice.py index df8b367..e47ebbe 100644 --- a/PLC/Methods/DeletePersonFromSlice.py +++ b/PLC/Methods/DeletePersonFromSlice.py @@ -1,4 +1,3 @@ -# $Id# from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed @@ -9,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,31 +29,31 @@ class DeletePersonFromSlice(Method): # Get account information persons = Persons(self.api, [person_id_or_email]) if not persons: - raise PLCInvalidArgument, "No such account" + raise PLCInvalidArgument("No such account %s"%person_id_or_email) person = persons[0] # Get slice information slices = Slices(self.api, [slice_id_or_name]) if not slices: - raise PLCInvalidArgument, "No such slice" + raise PLCInvalidArgument("No such slice %s"%slice_id_or_name) 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" + 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 slice %s"%slice_id_or_name) - 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']]} + + self.event_objects = {'Slice': [slice['slice_id']], + 'Person': [person['person_id']]} return 1