From 3c560d4a589cb7c7144f25468e0c7d2d0768853d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9na=C3=AFc=20Huard?= Date: Mon, 16 Nov 2015 14:42:45 +0100 Subject: cluster list: break host types by subtype --- filter_plugins/oo_filters.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'filter_plugins') diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index cf141d4f8..2386b5878 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -433,13 +433,16 @@ class FilterModule(object): def _add_host(clusters, env, host_type, + sub_host_type, host): ''' Add a new host in the clusters data structure ''' if env not in clusters: clusters[env] = {} if host_type not in clusters[env]: - clusters[env][host_type] = [] - clusters[env][host_type].append(host) + clusters[env][host_type] = {} + if sub_host_type not in clusters[env][host_type]: + clusters[env][host_type][sub_host_type] = [] + clusters[env][host_type][sub_host_type].append(host) clusters = {} for host in data: @@ -447,10 +450,10 @@ class FilterModule(object): _add_host(clusters=clusters, env=_get_tag_value(host['group_names'], 'env'), host_type=_get_tag_value(host['group_names'], 'host-type'), + sub_host_type=_get_tag_value(host['group_names'], 'sub-host-type'), host={'name': host['inventory_hostname'], 'public IP': host['ansible_ssh_host'], - 'private IP': host['ansible_default_ipv4']['address'], - 'subtype': _get_tag_value(host['group_names'], 'sub-host-type')}) + 'private IP': host['ansible_default_ipv4']['address']}) except KeyError: pass return clusters -- cgit v1.2.1