summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2016-03-21 12:05:37 -0400
committerKenny Woodson <kwoodson@redhat.com>2016-03-21 12:05:37 -0400
commit9c46574677dd345d856e505692dde5be75ec282f (patch)
tree95bfe5ff746355c81c148096a872d98504ce0a9a
parent394cb8776bdd7ece0258fd9d3b33ccbd95473b51 (diff)
downloadopenshift-9c46574677dd345d856e505692dde5be75ec282f.tar.gz
openshift-9c46574677dd345d856e505692dde5be75ec282f.tar.bz2
openshift-9c46574677dd345d856e505692dde5be75ec282f.tar.xz
openshift-9c46574677dd345d856e505692dde5be75ec282f.zip
Modified group selectors for muliple clusters per account
-rwxr-xr-xinventory/multi_inventory.py30
1 files changed, 21 insertions, 9 deletions
diff --git a/inventory/multi_inventory.py b/inventory/multi_inventory.py
index 57be259f7..be597267e 100755
--- a/inventory/multi_inventory.py
+++ b/inventory/multi_inventory.py
@@ -316,17 +316,29 @@ class MultiInventory(object):
inventory[key].append(name)
def apply_group_selectors(self, inventory, group_selectors):
- ''' Apply the account config for clone groups '''
+ ''' Apply the account config for group selectors '''
_ = self # Here for pylint. wanted an instance method instead of static
- for selector in group_selectors:
- if inventory.has_key(selector['from_group']):
- inventory[selector['from_group']].sort()
- inventory[selector['name']] = inventory[selector['from_group']][0:selector['count']]
- for host in inventory[selector['from_group']]:
- if host in inventory[selector['name']]:
- inventory['_meta']['hostvars'][host][selector['name']] = True
+ # There could be multiple clusters per account. We need to process these selectors
+ # based upon the oo_clusterid_ variable.
+ clusterids = [group for group in inventory if "oo_clusterid_" in group]
+
+ for clusterid in clusterids:
+ for selector in group_selectors:
+ if inventory.has_key(selector['from_group']):
+ hosts = list(set(inventory[clusterid]) & set(inventory[selector['from_group']]))
+ hosts.sort()
+
+ # Multiple clusters in an account
+ if inventory.has_key(selector['name']):
+ inventory[selector['name']].extend(hosts[0:selector['count']])
else:
- inventory['_meta']['hostvars'][host][selector['name']] = False
+ inventory[selector['name']] = hosts[0:selector['count']]
+
+ for host in hosts:
+ if host in inventory[selector['name']]:
+ inventory['_meta']['hostvars'][host][selector['name']] = True
+ else:
+ inventory['_meta']['hostvars'][host][selector['name']] = False
def apply_account_config(self, acc_config):
''' Apply account config settings '''