X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FAddPersonToSlice.py;h=e3392eb9a69f986504a1c54f1378aa9d9c3c0bfd;hb=801d1c69ef9f19c5f2e439e261407d4d28892884;hp=865ff9dfa8d2a721c6ebf7e96b37335eb3250fbc;hpb=86f246c43a5cf8fb1b9cfcc88cc623bc09998271;p=plcapi.git diff --git a/PLC/Methods/AddPersonToSlice.py b/PLC/Methods/AddPersonToSlice.py index 865ff9d..e3392eb 100644 --- a/PLC/Methods/AddPersonToSlice.py +++ b/PLC/Methods/AddPersonToSlice.py @@ -24,24 +24,26 @@ class AddPersonToSlice(Method): ] returns = Parameter(int, '1 if successful') - event_type = 'AddTo' - 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" - 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 add foreign users to 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']: @@ -50,6 +52,10 @@ class AddPersonToSlice(Method): if slice['slice_id'] not in person['slice_ids']: slice.add_person(person) + + # Logging variables + self.event_objects = {'Person': [person['person_id']], + 'Slice': [slice['slice_id']]} self.object_ids = [slice['slice_id']] return 1