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 # need to import so the core classes get decorated with caller_may_write_tag
14 from PLC.AuthorizeHelpers import AuthorizeHelpers
16 class DeleteSliceTag(Method):
18 Deletes the specified slice or sliver attribute.
20 Attributes may require the caller to have a particular role in
21 order to be deleted. Users may only delete attributes of
22 slices or slivers of which they are members. PIs may only delete
23 attributes of slices or slivers at their sites, or of which they
24 are members. Admins may delete attributes of any slice or sliver.
26 Returns 1 if successful, faults otherwise.
29 roles = ['admin', 'pi', 'user', 'tech']
33 SliceTag.fields['slice_tag_id']
36 returns = Parameter(int, '1 if successful')
38 def call(self, auth, slice_tag_id):
39 slice_tags = SliceTags(self.api, [slice_tag_id])
41 raise PLCInvalidArgument, "No such slice attribute"
42 slice_tag = slice_tags[0]
44 tag_type_id = slice_tag['tag_type_id']
45 tag_type = TagTypes (self.api,[tag_type_id])[0]
47 slices = Slices(self.api, [slice_tag['slice_id']])
49 raise PLCInvalidArgument, "No such slice %d"%slice_tag['slice_id']
52 assert slice_tag['slice_tag_id'] in slice['slice_tag_ids']
54 # check authorizations
55 node_id_or_hostname=slice_tag['node_id']
56 nodegroup_id_or_name=slice_tag['nodegroup_id']
57 slice.caller_may_write_tag(self.api,self.caller,tag_type,node_id_or_hostname,nodegroup_id_or_name)
60 self.event_objects = {'SliceTag': [slice_tag['slice_tag_id']]}