Commit e0adfeb0 authored by Zenon Mousmoulas's avatar Zenon Mousmoulas

Adjust servdata consumer templates so they can handle the "server re-use across

institutions" use case.
parent 95bb2910
...@@ -6,6 +6,9 @@ import re ...@@ -6,6 +6,9 @@ import re
% 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 ''}
% for client in inst['clients']: % for client in inst['clients']:
% if 'seen' in clients[client]:
# client ${client} defined previously
% else:
client ${client} { client ${client} {
secret = ${clients[client]['secret']} secret = ${clients[client]['secret']}
<% <%
...@@ -21,6 +24,10 @@ ipaddr = re.split(r'/(?=[0-9]{1,2}$)', clients[client]['host']) ...@@ -21,6 +24,10 @@ ipaddr = re.split(r'/(?=[0-9]{1,2}$)', clients[client]['host'])
% endif % endif
eduroamspco = GR eduroamspco = GR
} }
<%
clients[client]['seen'] = True
%>\
% endif
% endfor % endfor
#}}} #}}}
% endif % endif
......
...@@ -31,6 +31,9 @@ for r in inst['realms']: ...@@ -31,6 +31,9 @@ for r in inst['realms']:
for srv in inst_servers: for srv in inst_servers:
</%doc>\ </%doc>\
% for srv in set([s for r in inst['realms'] for s in inst['realms'][r]['proxy_to'] if 'proxy_to' in inst['realms'][r]]): % for srv in set([s for r in inst['realms'] for s in inst['realms'][r]['proxy_to'] if 'proxy_to' in inst['realms'][r]]):
% if 'seen' in servers[srv]:
# server ${srv} defined previously
% else:
home_server ${srv} { home_server ${srv} {
type = ${servers[srv]['rad_pkt_type']} type = ${servers[srv]['rad_pkt_type']}
ipaddr = ${servers[srv]['host']} ipaddr = ${servers[srv]['host']}
...@@ -47,6 +50,10 @@ home_server ${srv} { ...@@ -47,6 +50,10 @@ home_server ${srv} {
check_interval = 30 check_interval = 30
num_answers_to_alive = 3 num_answers_to_alive = 3
} }
<%
servers[srv]['seen'] = True
%>\
% endif
% endfor % endfor
% for realm in sorted([r for r in inst['realms'] if 'proxy_to' in inst['realms'][r]], cmp=wildcard_realm_least_precedence, reverse=True): % for realm in sorted([r for r in inst['realms'] if 'proxy_to' in inst['realms'][r]], cmp=wildcard_realm_least_precedence, reverse=True):
<% <%
......
...@@ -23,6 +23,9 @@ def wildcard_realm_least_precedence(a, b): ...@@ -23,6 +23,9 @@ def wildcard_realm_least_precedence(a, b):
#{{{${' ' + inst['id'] if 'id' in inst else ''} #{{{${' ' + inst['id'] if 'id' in inst else ''}
% if inst['type'] in (2, 3) and 'clients' in inst: % if inst['type'] in (2, 3) and 'clients' in inst:
% for client in inst['clients']: % for client in inst['clients']:
% if 'seen' in clients[client]:
# client ${client} defined previously
% 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 'id' in inst:
...@@ -40,6 +43,10 @@ client ${client} { ...@@ -40,6 +43,10 @@ client ${client} {
% endif % endif
rewriteIn rewrite-${client}-sp rewriteIn rewrite-${client}-sp
} }
% endif
<%
clients[client]['seen'] = True
%>\
% endfor % endfor
% endif % endif
% if inst['type'] in (1, 3) and 'realms' in inst: % if inst['type'] in (1, 3) and 'realms' in inst:
...@@ -53,6 +60,9 @@ for r in inst['realms']: ...@@ -53,6 +60,9 @@ for r in inst['realms']:
for srv in inst_servers: for srv in inst_servers:
</%doc>\ </%doc>\
% for srv in set([s for r in inst['realms'] for s in inst['realms'][r]['proxy_to'] if 'proxy_to' in inst['realms'][r]]): % for srv in set([s for r in inst['realms'] for s in inst['realms'][r]['proxy_to'] if 'proxy_to' in inst['realms'][r]]):
% if 'seen' in servers[srv]:
# server ${srv} defined previously
% else:
rewrite rewrite-${srv}-idp { rewrite rewrite-${srv}-idp {
include /etc/radsecproxy.conf.d/rewrite-default-idp.conf include /etc/radsecproxy.conf.d/rewrite-default-idp.conf
} }
...@@ -80,6 +90,10 @@ server ${srv}-acct { ...@@ -80,6 +90,10 @@ server ${srv}-acct {
rewriteIn rewrite-${srv}-idp rewriteIn rewrite-${srv}-idp
} }
% endif % endif
<%
servers[srv]['seen'] = True
%>\
% endif
% endfor % endfor
% for realm in sorted([r for r in inst['realms'] if 'proxy_to' in inst['realms'][r]], cmp=wildcard_realm_least_precedence, reverse=True): % for realm in sorted([r for r in inst['realms'] if 'proxy_to' in inst['realms'][r]], cmp=wildcard_realm_least_precedence, reverse=True):
realm ${realm | realm_regex} { realm ${realm | realm_regex} {
......
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