From 5c32cc7b5e00853b3cc28b5003b92ab009418dff Mon Sep 17 00:00:00 2001 From: kali Date: Mon, 24 Sep 2012 22:01:53 +0900 Subject: fix slug for eip config (was taking the one for eip-service) also correct the path (should be in root leap config folder). --- src/leap/eip/config.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/leap/eip/config.py') diff --git a/src/leap/eip/config.py b/src/leap/eip/config.py index e5fcd164..24e837d0 100644 --- a/src/leap/eip/config.py +++ b/src/leap/eip/config.py @@ -21,10 +21,8 @@ class EIPConfig(baseconfig.JSONLeapConfig): spec = eipspecs.eipconfig_spec def _get_slug(self): - dppath = baseconfig.get_default_provider_path() eipjsonpath = baseconfig.get_config_file( - 'eip-service.json', - folder=dppath) + 'eip.json') return eipjsonpath def _set_slug(self, *args, **kwargs): -- cgit v1.2.3 From abf481cab381a86d8a9c5607a131b56636081382 Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 25 Sep 2012 05:48:06 +0900 Subject: refactored jsonconfig, included jsonschema validation and type casting. --- src/leap/eip/config.py | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'src/leap/eip/config.py') diff --git a/src/leap/eip/config.py b/src/leap/eip/config.py index 24e837d0..7c9bf335 100644 --- a/src/leap/eip/config.py +++ b/src/leap/eip/config.py @@ -55,21 +55,38 @@ 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() + #import ipdb;ipdb.set_trace() eipconfig.load() - conf = eipconfig.get_config() - gateways = conf.get('gateways', None) + conf = eipconfig.config + + 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): -- cgit v1.2.3