PEP8
This commit is contained in:
parent
4766ad74ee
commit
ca0df7c33c
@ -1,5 +1,8 @@
|
||||
import dns.resolver
|
||||
|
||||
|
||||
# Resolve service from mesos-dns SRV record
|
||||
# return dict {"servicename": [{"name": "service.f.q.d.n", "port": 9999}]}
|
||||
def resolve(app, conf):
|
||||
hosts = {}
|
||||
services = app['services']
|
||||
@ -7,12 +10,17 @@ def resolve(app, conf):
|
||||
for service in services:
|
||||
hosts[service['name']] = []
|
||||
try:
|
||||
for rdata in dns.resolver.query('_' + service['name'] + '.' + service['group'] + '._tcp.' + domain, 'SRV'):
|
||||
for rdata in dns.resolver.query('_' +
|
||||
service['name'] + '.' +
|
||||
service['group'] + '._tcp.' +
|
||||
domain, 'SRV'):
|
||||
info = str(rdata).split()
|
||||
server = { 'name': info[3], 'port': info[2] }
|
||||
server = {'name': info[3], 'port': info[2]}
|
||||
|
||||
hosts[ service['name'] ].append(server)
|
||||
hosts[service['name']].append(server)
|
||||
except Exception as e:
|
||||
print("Could not resolve " + service['name'] + '.' + service['group'] + '._tcp.' + domain)
|
||||
print(str(e) + ": Could not resolve " +
|
||||
service['name'] + '.' +
|
||||
service['group'] + '._tcp.' + domain)
|
||||
|
||||
return hosts
|
||||
|
Loading…
Reference in New Issue
Block a user