Fast port naming service resolve. Only one port for one service

This commit is contained in:
Difrex 2016-08-17 16:38:54 +03:00
parent da0bcda185
commit 043682fbf6

View File

@ -12,6 +12,7 @@ def resolve(app, conf):
domain = conf['domain']
group = None
# Groups hack
if app['env'].get('SUROK_DISCOVERY_GROUP') is not None:
group = app['env']['SUROK_DISCOVERY_GROUP']
@ -26,7 +27,21 @@ def resolve(app, conf):
# /etc/surok/conf.d/service_conf.json
group = service['group']
fqdn = '_' + service['name'] + '.' + group + '._tcp.' + domain
# Port name from app config
port_name = None
try:
port_name = service['port_name']
except:
pass
# This is fast fix for port naming
# Will be rewrite later
fqdn = ''
if port_name is not None:
fqdn = '_' + port_name + '.' + '_' + service['name'] + '.' + group + '._tcp.' + domain
else:
fqdn = '_' + service['name'] + '.' + group + '._tcp.' + domain
hosts[service['name']] = do_query(fqdn, conf['loglevel'])
return hosts