From dc63bbf0b9686db297de8d0bb801cba0418f88f2 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Wed, 17 Jun 2015 08:18:58 -0700 Subject: [PATCH] Simplify serf inventory plugin using newly added `EnvironmentConfig` class in `serfclient`. See https://github.com/KushalP/serfclient-py/pull/17 --- plugins/inventory/serf.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/plugins/inventory/serf.py b/plugins/inventory/serf.py index 3c4cf365c6..dfda4dd855 100755 --- a/plugins/inventory/serf.py +++ b/plugins/inventory/serf.py @@ -35,7 +35,7 @@ import os import sys # https://pypi.python.org/pypi/serfclient -from serfclient.client import SerfClient +from serfclient import SerfClient, EnvironmentConfig try: import json @@ -46,17 +46,8 @@ _key = 'serf' def _serf_client(): - kwargs = {} - - rpc_addr = os.getenv('SERF_RPC_ADDR') - if rpc_addr: - kwargs['host'], kwargs['port'] = rpc_addr.split(':') - - rpc_auth = os.getenv('SERF_RPC_AUTH') - if rpc_auth: - kwargs['rpc_auth'] = rpc_auth - - return SerfClient(**kwargs) + env = EnvironmentConfig() + return SerfClient(host=env.host, port=env.port, rpc_auth=env.auth_key) def get_serf_members_data():