Fix "permission denied to modify tag" error
authorAndy Bavier <acb@cs.princeton.edu>
Mon, 7 Mar 2011 21:59:20 +0000 (16:59 -0500)
committerAndy Bavier <acb@cs.princeton.edu>
Mon, 7 Mar 2011 21:59:20 +0000 (16:59 -0500)
The SFA should give an "Invalid RSpec: permission denied to modify tag" error when the user
tries to modify a tag without the proper role.  This fix prevents the error being generated
when the tag value has not been changed.

sfa/plc/network.py

index 2a3e6ba..d8f0c1d 100644 (file)
@@ -183,10 +183,14 @@ class Slice:
     
     # Update a slice tag if it exists, else add it             
     def update_tag(self, tagname, value, node = None, role = "user"):
+        tag = self.get_tag(tagname, node)
+        if tag and tag.value == value:
+            return tag
+
         tt = self.network.lookupTagType(tagname)
         if not tt.permit_update(role):
             raise InvalidRSpec("permission denied to modify '%s' tag" % tagname)
-        tag = self.get_tag(tagname, node)
+
         if tag:
             tag.change(value)
         else: