X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FAddPersonToSlice.py;h=41e6a6a159526752444113428b6047bc84f9c9f0;hb=da06561d0f5240a5409474e16824e4e015f31fac;hp=e9c00161ca99310013e8299268255f4ebbebec95;hpb=e4c0c59e6bf7d7112f019272e04e6595639bcb90;p=plcapi.git diff --git a/PLC/Methods/AddPersonToSlice.py b/PLC/Methods/AddPersonToSlice.py index e9c0016..41e6a6a 100644 --- a/PLC/Methods/AddPersonToSlice.py +++ b/PLC/Methods/AddPersonToSlice.py @@ -8,7 +8,7 @@ from PLC.Auth import Auth class AddPersonToSlice(Method): """ Adds the specified person to the specified slice. If the person is - already a member of the slice, no errors are returned. + already a member of the slice, no errors are returned. Returns 1 if successful, faults otherwise. """ @@ -25,19 +25,17 @@ class AddPersonToSlice(Method): returns = Parameter(int, '1 if successful') - object_type = 'Slice' - def call(self, auth, person_id_or_email, slice_id_or_name): # 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 @@ -48,14 +46,16 @@ class AddPersonToSlice(Method): # 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 'admin' not in self.caller['roles']: if slice['site_id'] not in self.caller['site_ids']: - raise PLCPermissionDenied, "Not allowed to add users to this slice" + raise PLCPermissionDenied, "Not allowed to add users to slice %s"%slice_id_or_name - if slice['slice_id'] not in person['slice_ids']: + if slice['slice_id'] not in person['slice_ids']: slice.add_person(person) # Logging variables - self.object_ids = [slice['slice_id']] + self.event_objects = {'Person': [person['person_id']], + 'Slice': [slice['slice_id']]} + self.object_ids = [slice['slice_id']] return 1