1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Persons import Person, Persons
5 from PLC.Slices import Slice, Slices
6 from PLC.Auth import Auth
8 class SliceUserDel(Method):
10 Deprecated. Can be implemented with DeletePersonFromSlice.
12 Removes the specified users from the specified slice. If the person is
13 already a member of the slice, no errors are returned.
15 Returns 1 if successful, faults otherwise.
18 roles = ['admin', 'pi']
23 [Person.fields['email']],
26 returns = Parameter(int, '1 if successful')
28 def call(self, auth, slice_name, user_list):
29 # Get account information
30 persons = Persons(self.api, user_list)
32 raise PLCInvalidArgument, "No such account"
34 # Get slice information
35 slices = Slices(self.api, [slice_id_or_name])
37 raise PLCInvalidArgument, "No such slice"
40 if slice['peer_id'] is not None:
41 raise PLCInvalidArgument, "Not a local slice"
43 # If we are not admin, make sure the caller is a PI
44 # of the site associated with the slice
45 if 'admin' not in self.caller['roles']:
46 if slice['site_id'] not in self.caller['site_ids']:
47 raise PLCPermissionDenied, "Not allowed to add users to this slice"
49 for person in persons:
50 if person['person_id'] in slice['person_ids']:
51 slice.remove_person(person, False)
54 self.object_ids = [slice['slice_id']]