Merge branch 'testing' into consul
This commit is contained in:
commit
0ad579a4b9
@ -13,7 +13,7 @@ def resolve(app, conf):
|
|||||||
domain = conf['domain']
|
domain = conf['domain']
|
||||||
|
|
||||||
for service in services:
|
for service in services:
|
||||||
hosts[service['name']] = {}
|
hosts[service['name']] = []
|
||||||
|
|
||||||
group = get_group(service, app)
|
group = get_group(service, app)
|
||||||
if group is False:
|
if group is False:
|
||||||
@ -23,25 +23,45 @@ def resolve(app, conf):
|
|||||||
|
|
||||||
# Port name from app config
|
# Port name from app config
|
||||||
ports = None
|
ports = None
|
||||||
try:
|
if 'ports' in service:
|
||||||
ports = service['ports']
|
ports = service['ports']
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# This is fast fix for port naming
|
# "service-with-defined-ports":
|
||||||
# Will be rewrite later
|
# [
|
||||||
|
# {
|
||||||
|
# "name": "example1.com",
|
||||||
|
# "ip": ["10.10.10.1"],
|
||||||
|
# "ports": {
|
||||||
|
# "rpc": 12342,
|
||||||
|
# "web": 12341
|
||||||
|
# }
|
||||||
|
# },
|
||||||
|
# {
|
||||||
|
# "name": "example2.com",
|
||||||
|
# "ports": {
|
||||||
|
# "rpc": 12344,
|
||||||
|
# "web": 12343
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# ]
|
||||||
fqdn = ''
|
fqdn = ''
|
||||||
|
|
||||||
# Discovery over Consul DNS
|
# Discovery over Consul DNS
|
||||||
if 'consul' in conf and conf['consul']['enabled']:
|
if 'consul' in conf and conf['consul']['enabled']:
|
||||||
fqdn = '_' + service['name'] + '._tcp.' + conf['consul']['domain']
|
fqdn = '_' + service['name'] + '._tcp.' + conf['consul']['domain']
|
||||||
hosts[service['name']] = do_query(fqdn, conf['loglevel'])
|
hosts[service['name']].append(do_query(fqdn, conf['loglevel']))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if ports is not None:
|
if ports is not None:
|
||||||
for port_name in ports:
|
for port_name in ports:
|
||||||
fqdn = '_' + port_name + '.' + '_' + service['name'] + '.' + group + '._tcp.' + domain
|
fqdn = '_' + port_name + '.' + '_' + service['name'] + '.' + group + '._tcp.' + domain # Need support for udp ports. See #16
|
||||||
hosts[service['name']][port_name] = do_query(fqdn, conf['loglevel'])
|
discovered = do_query(fqdn, conf['loglevel'])
|
||||||
|
for d in discovered:
|
||||||
|
to_append = {}
|
||||||
|
to_append['name'] = d['name']
|
||||||
|
to_append['ip'] = d['ip']
|
||||||
|
to_append['ports'][port_name] = d['port']
|
||||||
|
hosts[service['name']].append(to_append)
|
||||||
else:
|
else:
|
||||||
fqdn = '_' + service['name'] + '.' + group + '._tcp.' + domain
|
fqdn = '_' + service['name'] + '.' + group + '._tcp.' + domain
|
||||||
hosts[service['name']] = do_query(fqdn, conf['loglevel'])
|
hosts[service['name']] = do_query(fqdn, conf['loglevel'])
|
||||||
|
Loading…
Reference in New Issue
Block a user