blind 2to3
[plcapi.git] / PLC / Methods / DeleteSliceTag.py
index 35ad927..2e133a8 100644 (file)
@@ -6,9 +6,10 @@ from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
 from PLC.Auth import Auth
 
-from PLC.SliceTags import SliceTag, SliceTags
-from PLC.Slices import Slice, Slices
+from PLC.TagTypes import TagTypes, TagType
 from PLC.Nodes import Node, Nodes
+from PLC.Slices import Slice, Slices
+from PLC.SliceTags import SliceTag, SliceTags
 
 # need to import so the core classes get decorated with caller_may_write_tag
 from PLC.AuthorizeHelpers import AuthorizeHelpers
@@ -26,7 +27,7 @@ class DeleteSliceTag(Method):
     Returns 1 if successful, faults otherwise.
     """
 
-    roles = ['admin', 'pi', 'user', 'tech']
+    roles = ['admin', 'pi', 'user', 'tech', 'node']
 
     accepts = [
         Auth(),
@@ -38,12 +39,15 @@ class DeleteSliceTag(Method):
     def call(self, auth, slice_tag_id):
         slice_tags = SliceTags(self.api, [slice_tag_id])
         if not slice_tags:
-            raise PLCInvalidArgument, "No such slice attribute"
+            raise PLCInvalidArgument("No such slice attribute")
         slice_tag = slice_tags[0]
 
+        tag_type_id = slice_tag['tag_type_id']
+        tag_type = TagTypes (self.api,[tag_type_id])[0]
+
         slices = Slices(self.api, [slice_tag['slice_id']])
         if not slices:
-            raise PLCInvalidArgument, "No such slice %d"%slice_tag['slice_id']
+            raise PLCInvalidArgument("No such slice %d"%slice_tag['slice_id'])
         slice = slices[0]
 
         assert slice_tag['slice_tag_id'] in slice['slice_tag_ids']