def setup_config(args): import os from lymph.config import Configuration from lymph.utils.sockets import guess_external_ip config = Configuration({ 'container': {} }) if 'IRIS_NODE_CONFIG' in os.environ: config.load_file(os.environ['IRIS_NODE_CONFIG'], sections=['registry', 'event_system', 'plugins']) config_file = args.get('--config') or '.lymph.yml' config.load_file(config_file) config.source = config_file config.setdefault('container.ip', os.environ.get('IRIS_NODE_IP', '127.0.0.1')) ip = args.get('--ip') if args.get('--guess-external-ip'): if ip: print('cannot combine --ip and --guess-external-ip') return 1 ip = guess_external_ip() if ip: config.set('container.ip', ip) port = args.get('--port') if port: config.set('container.port', port) return config
def setup_config(args): import os import sys from lymph.config import Configuration from lymph.utils.sockets import guess_external_ip config = Configuration({ 'container': {} }) if 'LYMPH_NODE_CONFIG' in os.environ: config.load_file(os.environ['LYMPH_NODE_CONFIG'], sections=['container', 'registry', 'event_system', 'plugins', 'dependencies']) config_file = args.get('--config') or '.lymph.yml' config.load_file(config_file) config.source = config_file config.setdefault('container.ip', os.environ.get('LYMPH_NODE_IP', '127.0.0.1')) ip = args.get('--ip') if args.get('--guess-external-ip'): if ip: sys.exit('Cannot combine --ip and --guess-external-ip') ip = guess_external_ip() if ip is None: sys.exit('Cannot guess external ip, aborting ...') if ip: config.set('container.ip', ip) port = args.get('--port') if port: config.set('container.port', port) return config
def setup_config(args): import os from lymph.config import Configuration from lymph.utils.sockets import guess_external_ip config = Configuration({'container': {}}) if 'IRIS_NODE_CONFIG' in os.environ: config.load_file(os.environ['IRIS_NODE_CONFIG'], sections=['registry', 'event_system', 'plugins']) config_file = args.get('--config') or '.lymph.yml' config.load_file(config_file) config.source = config_file config.setdefault('container.ip', os.environ.get('IRIS_NODE_IP', '127.0.0.1')) ip = args.get('--ip') if args.get('--guess-external-ip'): if ip: print('cannot combine --ip and --guess-external-ip') return 1 ip = guess_external_ip() if ip: config.set('container.ip', ip) port = args.get('--port') if port: config.set('container.port', port) return config
def setup_config(args): import os import sys from lymph.config import Configuration from lymph.utils.sockets import guess_external_ip vars_file = args.get('--vars') or os.environ.get('LYMPH_VARS') env_vars = Configuration(raw=True) if vars_file: env_vars.load_file(vars_file) os.environ['LYMPH_VARS'] = vars_file config = Configuration({'container': {}}, env=os.environ, var=env_vars) if 'LYMPH_NODE_CONFIG' in os.environ: config.load_file(os.environ['LYMPH_NODE_CONFIG'], sections=[ 'container', 'registry', 'event_system', 'plugins', 'dependencies' ]) config_file = args.get('--config') or os.environ.get( 'LYMPH_CONFIG', '.lymph.yml') config.load_file(config_file) config.source = config_file config.setdefault('container.ip', os.environ.get('LYMPH_NODE_IP', '127.0.0.1')) ip = args.get('--ip') if args.get('--guess-external-ip'): if ip: sys.exit('Cannot combine --ip and --guess-external-ip') ip = guess_external_ip() if ip is None: sys.exit('Cannot guess external ip, aborting ...') if ip: config.set('container.ip', ip) port = args.get('--port') if port: config.set('container.port', port) return config
def test_guess_external_ip(self): self.assertNotEqual(guess_external_ip(), '127.0.0.1')