Commit 7fec7431 authored by Zenon Mousmoulas's avatar Zenon Mousmoulas

Amendment for e0adfeb0 (servdata consumer templates adjustment for the

"server re-use across institutions" use case): avoid hard-coding
Operator-Name (and F-Ticks VISINST) by tracking "usecount" for radius
clients
parent 3a60a4c0
...@@ -2,6 +2,15 @@ ...@@ -2,6 +2,15 @@
<%! <%!
import re import re
%>\ %>\
<%
for inst in insts:
if inst['type'] in (2, 3) and 'clients' in inst:
for client in inst['clients']:
if 'usecount' in clients[client]:
clients[client]['usecount'] = clients[client]['usecount'] + 1
else:
clients[client]['usecount'] = 1
%>\
% for inst in insts: % for inst in insts:
% if inst['type'] in (2, 3) and 'clients' in inst: % if inst['type'] in (2, 3) and 'clients' in inst:
#{{{${' ' + inst['id'] if 'id' in inst else ''} #{{{${' ' + inst['id'] if 'id' in inst else ''}
...@@ -19,7 +28,7 @@ ipaddr = re.split(r'/(?=[0-9]{1,2}$)', clients[client]['host']) ...@@ -19,7 +28,7 @@ ipaddr = re.split(r'/(?=[0-9]{1,2}$)', clients[client]['host'])
netmask = ${ipaddr[1]} netmask = ${ipaddr[1]}
% endif % endif
nastype = other nastype = other
% if 'id' in inst: % if clients[client]['usecount'] == 1 and 'id' in inst:
grnetopname = 1${inst['id']} grnetopname = 1${inst['id']}
% endif % endif
eduroamspco = GR eduroamspco = GR
......
...@@ -18,6 +18,15 @@ def wildcard_realm_least_precedence(a, b): ...@@ -18,6 +18,15 @@ def wildcard_realm_least_precedence(a, b):
else: else:
return 0 return 0
%>\ %>\
<%
for inst in insts:
if inst['type'] in (2, 3) and 'clients' in inst:
for client in inst['clients']:
if 'usecount' in clients[client]:
clients[client]['usecount'] = clients[client]['usecount'] + 1
else:
clients[client]['usecount'] = 1
%>\
% for inst in insts: % for inst in insts:
% if True in [c in inst for c in ['clients', 'realms']]: % if True in [c in inst for c in ['clients', 'realms']]:
#{{{${' ' + inst['id'] if 'id' in inst else ''} #{{{${' ' + inst['id'] if 'id' in inst else ''}
...@@ -28,7 +37,7 @@ def wildcard_realm_least_precedence(a, b): ...@@ -28,7 +37,7 @@ def wildcard_realm_least_precedence(a, b):
% else: % else:
rewrite rewrite-${client}-sp { rewrite rewrite-${client}-sp {
include /etc/radsecproxy.conf.d/rewrite-default-sp.conf include /etc/radsecproxy.conf.d/rewrite-default-sp.conf
% if 'id' in inst: % if clients[client]['usecount'] == 1 and 'id' in inst:
addAttribute 126:1${inst['id']} addAttribute 126:1${inst['id']}
% endif % endif
} }
...@@ -38,7 +47,7 @@ client ${client} { ...@@ -38,7 +47,7 @@ client ${client} {
type udp type udp
secret ${clients[client]['secret'] | percent_escape} secret ${clients[client]['secret'] | percent_escape}
fticksVISCOUNTRY GR fticksVISCOUNTRY GR
% if 'id' in inst: % if clients[client]['usecount'] == 1 and 'id' in inst:
fticksVISINST 1${inst['id']} fticksVISINST 1${inst['id']}
% endif % endif
rewriteIn rewrite-${client}-sp rewriteIn rewrite-${client}-sp
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment