2 # Thierry Parmentelat - INRIA
4 from PLC.Faults import *
5 from PLC.Method import Method
6 from PLC.Parameter import Parameter, Mixed
7 from PLC.Auth import Auth
9 from PLC.SliceTags import SliceTag, SliceTags
10 from PLC.Slices import Slice, Slices
11 from PLC.Nodes import Node, Nodes
13 class DeleteSliceTag(Method):
15 Deletes the specified slice or sliver attribute.
17 Attributes may require the caller to have a particular role in
18 order to be deleted. Users may only delete attributes of
19 slices or slivers of which they are members. PIs may only delete
20 attributes of slices or slivers at their sites, or of which they
21 are members. Admins may delete attributes of any slice or sliver.
23 Returns 1 if successful, faults otherwise.
26 roles = ['admin', 'pi', 'user', 'tech']
30 SliceTag.fields['slice_tag_id']
33 returns = Parameter(int, '1 if successful')
35 def call(self, auth, slice_tag_id):
36 slice_tags = SliceTags(self.api, [slice_tag_id])
38 raise PLCInvalidArgument, "No such slice attribute"
39 slice_tag = slice_tags[0]
41 slices = Slices(self.api, [slice_tag['slice_id']])
43 raise PLCInvalidArgument, "No such slice %d"%slice_tag['slice_id']
46 assert slice_tag['slice_tag_id'] in slice['slice_tag_ids']
48 # check authorizations
49 node_id_or_hostname=slice_tag['node_id']
50 nodegroup_id_or_name=slice_tag['nodegroup_id']
51 slice.caller_may_write_tag(self.api,self.caller,tag_type,node_id_or_hostname,nodegroup_id_or_name)
54 self.event_objects = {'SliceTag': [slice_tag['slice_tag_id']]}