From 043682fbf6ffc39fb32fa4108d4c3cc6a2ffaf88 Mon Sep 17 00:00:00 2001 From: Difrex Date: Wed, 17 Aug 2016 16:38:54 +0300 Subject: [PATCH] Fast port naming service resolve. Only one port for one service --- surok/discovery.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/surok/discovery.py b/surok/discovery.py index 3ad583a..6c1a6ad 100644 --- a/surok/discovery.py +++ b/surok/discovery.py @@ -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