X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=db-config.d%2F000-functions;fp=db-config.d%2F000-functions;h=f26897938fe5591c3f1f8794a8edcf91b8718ba7;hb=c9023191bc5e07fe0edc51be57418919b66e4c43;hp=28468b1d84877fc5380e172323260f9edb1068a9;hpb=bd7b9f706133094d52af73dcc6f43c920915ed02;p=plcapi.git diff --git a/db-config.d/000-functions b/db-config.d/000-functions index 28468b1..f268979 100644 --- a/db-config.d/000-functions +++ b/db-config.d/000-functions @@ -25,27 +25,27 @@ g_known_tag_types = [tag_type['tagname'] for tag_type in GetTagTypes()] g_known_tag_types.sort() def SetTagType(tag_type): - tagname=tag_type['tagname'] - global g_known_tag_types - # handle 'roles' field differently - if 'roles' in tag_type: - roles=tag_type['roles'] - del tag_type['roles'] - else: - roles=['admin'] - # just in case - if 'min_role_id' in tag_type: - print "WARNING: ignoring deprecated field min_role_id for tagtype %s"%tagname - del tag_type['min_role_id'] - # Create/update default slice tag types - if tagname not in g_known_tag_types: - AddTagType(tag_type) - g_known_tag_types.append(tagname) - g_known_tag_types.sort() - else: - UpdateTagType(tagname, tag_type) - # enforce provided roles if present try: + tagname=tag_type['tagname'] + global g_known_tag_types + # handle 'roles' field differently + if 'roles' in tag_type: + roles=tag_type['roles'] + del tag_type['roles'] + else: + roles=['admin'] + # just in case + if 'min_role_id' in tag_type: + print "WARNING: ignoring deprecated field min_role_id for tagtype %s"%tagname + del tag_type['min_role_id'] + # Create/update default slice tag types + if tagname not in g_known_tag_types: + AddTagType(tag_type) + g_known_tag_types.append(tagname) + g_known_tag_types.sort() + else: + UpdateTagType(tagname, tag_type) + # enforce provided roles if present old_roles=GetTagTypes(tagname)[0]['roles'] for minus_role in set(old_roles).difference(set(roles)): DeleteRoleFromTagType(minus_role,tagname) @@ -54,7 +54,7 @@ def SetTagType(tag_type): except: # something went wrong for that tagname, # but don't want to break the whole startup sequence - print "Could not enforce roles on tagtype %s"%tagname + print "Could not enforce tagtype %s"%tagname pass # Get list of existing (enabled, global) files