Thanks for linking the feature request.
As security becomes ever more important, I see the need to implement some more flexibility in security configuration on tags. We are looking at potentially implementing 100+ security levels for different facilities. Unfortunately, security zones themselves aren't the answer for my situation as we have several remote facilities, with 10s and some 100s of thousands of tags tying into each gateway, which means dividing up within by using security levels.
Here's an example of what I've done in the meantime is write a script that replaces the system's original security levels. It will loop through a folder/udt instance and it's subfolders and replace the old security levels with the new ones. This particular version of the script relies on the security levels being defined in the gateway and security levels configured on the tag that are being replaced, but you could manipulate it to add the levels based on the tagname property, or whatever works best for your particular solution.
I'm sure someone could accomplish the this in a cleaner, slicker way but it has worked for me so far.
parentPath = "'[Plant]Test Folder/' #root folder path. Point this to your UDT Instance
pathToFolder = parentPath + 'Test' #This is the name of the UDT instance you've directed to.
configs = system.tag.getConfiguration(pathToFolder, True) #system function to read all tag properties
#define the structure of the original level
old_AdminGroup = {"type":"AnyOf","securityLevels":[{"name":"Authenticated","children":[{"name":"Roles","children":[{"name":"Admins","children":},{"name":"plt-ign-admins","children":}]}]}]}
#define the new structure
AdminGroup = {"type":"AnyOf","securityLevels":[{"name":"Authenticated","children":[{"name":"Roles","children":[{"name":"Admins","children":}]}]}]}
def ICSCheck(folder):
for tag in folder['tags']: #loops through the defined root folder
if str(tag['tagType']) == 'AtomicTag': #Check for valid tags
if tag.has_key('writePermissions'): #This .has_key is very important. This will grab all tags with write permissions configured and skip the rest
permissions = system.util.jsonDecode(str(tag['writePermissions']))
if permissions == old_AdminGroup:
tag['writePermissions'] = AdminGroup
elif tag.has_key('tags'):
ICSCheck(tag)
ICSCheck(configs[0])
system.tag.configure(parentPath,configs,'m') #Write new security levels based on the conditions in the ICSCheck function