my dict update
This commit is contained in:
parent
d62a424cf2
commit
0c3c2014cc
2
surok.py
2
surok.py
@ -36,7 +36,7 @@ while 1:
|
||||
for app in confs:
|
||||
app_conf = load_app_conf(app)
|
||||
app_hosts = resolve(app_conf, conf)
|
||||
my = { 'hosts': app_hosts }
|
||||
my = { 'services': app_hosts }
|
||||
service_conf = gen(my, app_conf['template'])
|
||||
|
||||
print(reload_conf(service_conf, app_conf))
|
||||
|
@ -1,13 +1,18 @@
|
||||
import dns.resolver
|
||||
|
||||
def resolve(app, conf):
|
||||
hosts = []
|
||||
hosts = {}
|
||||
services = app['services']
|
||||
domain = conf['domain']
|
||||
for service in services:
|
||||
hosts[service['name']] = []
|
||||
try:
|
||||
for rdata in dns.resolver.query('_' + service['name'] + '.' + service['group'] + '._tcp.' + domain, 'SRV'):
|
||||
info = str(rdata).split()
|
||||
server = { service['name']: { 'name': info[3], 'port': info[2] } }
|
||||
hosts.append(server)
|
||||
server = { 'name': info[3], 'port': info[2] }
|
||||
|
||||
hosts[ service['name'] ].append(server)
|
||||
except Exception as e:
|
||||
print("Could not resolve " + service['name'] + '.' + service['group'] + '._tcp.' + domain)
|
||||
|
||||
return hosts
|
||||
|
Loading…
Reference in New Issue
Block a user