summaryrefslogtreecommitdiffstats
path: root/bin/hostinfo
diff options
context:
space:
mode:
Diffstat (limited to 'bin/hostinfo')
-rwxr-xr-xbin/hostinfo16
1 files changed, 8 insertions, 8 deletions
diff --git a/bin/hostinfo b/bin/hostinfo
index 444bae7..f1453e9 100755
--- a/bin/hostinfo
+++ b/bin/hostinfo
@@ -19,7 +19,7 @@ def _get_data(path):
stream = file(path, 'r')
return yaml.load(stream)
-def match_key(data, keys):
+def _match_key(data, keys):
if data is None:
return None
@@ -30,19 +30,19 @@ def match_key(data, keys):
rest = keys[1:]
if key == 'addresses' and 'addresses' in data:
- return match_key(utils.group_by(data['addresses'], 'interface'), rest)
+ return _match_key(utils.group_by(data['addresses'], 'interface'), rest)
if key == 'ports' and 'ports' in data:
- return match_key(utils.group_by(data['ports'], 'process', 'UNKNOWN'), rest)
+ return _match_key(utils.group_by(data['ports'], 'process', 'UNKNOWN'), rest)
if isinstance(data, dict):
if key in data:
- return match_key(data[key], rest)
+ return _match_key(data[key], rest)
return None
if isinstance(data, list):
for elem in data:
- result = match_key(elem, keys)
+ result = _match_key(elem, keys)
if result is not None:
return result
return None
@@ -52,10 +52,10 @@ def match_key(data, keys):
return None
-def match(host, search_key, search_value, negate):
+def _match(host, search_key, search_value, negate):
search_keys = search_key.split('.')
- result = match_key(host, search_keys)
+ result = _match_key(host, search_keys)
if search_value is None:
if negate:
if result is not None:
@@ -106,7 +106,7 @@ def print_search(basepath, flags, search, filter_key=None):
search_key, search_value, negate = _parse_search(search)
for host in hosts['hosts']:
data = _get_data(os.path.join(basepath, host))
- key, result = match(data, search_key, search_value, negate)
+ key, result = _match(data, search_key, search_value, negate)
if result is not None:
if flags.only_names:
print(_get_label(host))