From 9120d723a25b86b02080962fcffb4ed1f59891a2 Mon Sep 17 00:00:00 2001 From: Difrex Date: Tue, 9 Aug 2016 15:44:23 +0300 Subject: [PATCH] SUROK_GROUP env variable --- surok/discovery.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/surok/discovery.py b/surok/discovery.py index 4090213..fc28ea1 100644 --- a/surok/discovery.py +++ b/surok/discovery.py @@ -7,12 +7,17 @@ def resolve(app, conf): hosts = {} services = app['services'] domain = conf['domain'] + group = None for service in services: hosts[service['name']] = [] + if app['env'].get('SUROK_GROUP') is not None: + group = app['env']['SUROK_GROUP'] + else: + group = service['group'] try: for rdata in dns.resolver.query('_' + service['name'] + '.' + - service['group'] + '._tcp.' + + group + '._tcp.' + domain, 'SRV'): info = str(rdata).split() server = {'name': info[3], 'port': info[2]} @@ -21,6 +26,6 @@ def resolve(app, conf): except Exception as e: print(str(e) + ": Could not resolve " + service['name'] + '.' + - service['group'] + '._tcp.' + domain) + group + '._tcp.' + domain) return hosts