2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.SliceTags import SliceTag, SliceTags
6 from PLC.Slices import Slice, Slices
7 from PLC.Nodes import Node, Nodes
8 from PLC.Auth import Auth
10 class DeleteSliceTag(Method):
12 Deletes the specified slice or sliver attribute.
14 Attributes may require the caller to have a particular role in
15 order to be deleted. Users may only delete attributes of
16 slices or slivers of which they are members. PIs may only delete
17 attributes of slices or slivers at their sites, or of which they
18 are members. Admins may delete attributes of any slice or sliver.
20 Returns 1 if successful, faults otherwise.
23 roles = ['admin', 'pi', 'user']
27 SliceTag.fields['slice_tag_id']
30 returns = Parameter(int, '1 if successful')
32 def call(self, auth, slice_tag_id):
33 slice_tags = SliceTags(self.api, [slice_tag_id])
35 raise PLCInvalidArgument, "No such slice attribute"
36 slice_tag = slice_tags[0]
38 slices = Slices(self.api, [slice_tag['slice_id']])
40 raise PLCInvalidArgument, "No such slice"
43 assert slice_tag['slice_tag_id'] in slice['slice_tag_ids']
45 if 'admin' not in self.caller['roles']:
46 if self.caller['person_id'] in slice['person_ids']:
48 elif 'pi' not in self.caller['roles']:
49 raise PLCPermissionDenied, "Not a member of the specified slice"
50 elif slice['site_id'] not in self.caller['site_ids']:
51 raise PLCPermissionDenied, "Specified slice not associated with any of your sites"
53 if slice_tag['min_role_id'] is not None and \
54 min(self.caller['role_ids']) > slice_tag['min_role_id']:
55 raise PLCPermissioinDenied, "Not allowed to delete the specified attribute"
58 self.event_objects = {'SliceTag': [slice_tag['slice_tag_id']]}