diff options
author | kali <kali@leap.se> | 2012-09-25 05:48:06 +0900 |
---|---|---|
committer | kali <kali@leap.se> | 2012-09-25 06:02:18 +0900 |
commit | 5173c0ee937696782a2f62078a860246ec388c39 (patch) | |
tree | 792ec3e31afda70b76b1c69528f88c16672eed84 /src/leap/eip/config.py | |
parent | f4f5fc21e186bcd94d39f78333f758ed906f5b98 (diff) |
workaround for #638 and fix for eip config check for gateways
(we were picking gateway in a wrong way)
Closes #610.
Diffstat (limited to 'src/leap/eip/config.py')
-rw-r--r-- | src/leap/eip/config.py | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/leap/eip/config.py b/src/leap/eip/config.py index 24e837d0..082cc24d 100644 --- a/src/leap/eip/config.py +++ b/src/leap/eip/config.py @@ -55,21 +55,35 @@ def get_socket_path(): def get_eip_gateway(): """ - return the first host in the list of hosts - under gateways list + return the first host in eip service config + that matches the name defined in the eip.json config + file. """ + placeholder = "testprovider.example.org" eipconfig = EIPConfig() eipconfig.load() conf = eipconfig.get_config() - gateways = conf.get('gateways', None) + primary_gateway = conf.get('primary_gateway', None) + if not primary_gateway: + return placeholder + + eipserviceconfig = EIPServiceConfig() + eipserviceconfig.load() + eipsconf = eipserviceconfig.get_config() + gateways = eipsconf.get('gateways', None) + if not gateways: + logger.error('missing gateways in eip service config') + return placeholder if len(gateways) > 0: - # we just pick first - gw = gateways[0] - hosts = gw['hosts'] - if len(hosts) > 0: - return hosts[0] - else: - return "testprovider.example.org" + for gw in gateways: + if gw['name'] == primary_gateway: + hosts = gw['hosts'] + if len(hosts) > 0: + return hosts[0] + else: + logger.error('no hosts') + logger.error('could not find primary gateway in provider' + 'gateway list') def build_ovpn_options(daemon=False, socket_path=None, **kwargs): |