summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2016-03-21 12:10:20 -0400
committerKenny Woodson <kwoodson@redhat.com>2016-03-21 12:10:20 -0400
commitba61ea20d8df0a19b7a1dcf01f7ec1190e3401e9 (patch)
tree95bfe5ff746355c81c148096a872d98504ce0a9a
parent394cb8776bdd7ece0258fd9d3b33ccbd95473b51 (diff)
parent9c46574677dd345d856e505692dde5be75ec282f (diff)
downloadopenshift-ba61ea20d8df0a19b7a1dcf01f7ec1190e3401e9.tar.gz
openshift-ba61ea20d8df0a19b7a1dcf01f7ec1190e3401e9.tar.bz2
openshift-ba61ea20d8df0a19b7a1dcf01f7ec1190e3401e9.tar.xz
openshift-ba61ea20d8df0a19b7a1dcf01f7ec1190e3401e9.zip
Merge pull request #1641 from kwoodson/selectorsfix
Modified group selectors to work with multpile 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 '''