summaryrefslogtreecommitdiffstats
path: root/inventory
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2015-10-28 12:31:17 -0400
committerKenny Woodson <kwoodson@redhat.com>2015-10-28 14:26:47 -0400
commitca492ffb62208e95e46d50dd648511bd2ae09536 (patch)
treead90afa112bbcfdd59f5051c94965637eaaa7ccd /inventory
parentbab6549b2fdac9df97af7cc0e6b018c8d8758291 (diff)
downloadopenshift-ca492ffb62208e95e46d50dd648511bd2ae09536.tar.gz
openshift-ca492ffb62208e95e46d50dd648511bd2ae09536.tar.bz2
openshift-ca492ffb62208e95e46d50dd648511bd2ae09536.tar.xz
openshift-ca492ffb62208e95e46d50dd648511bd2ae09536.zip
Adding clone vars and groups. Renamed hostvars to extra_vars.
Diffstat (limited to 'inventory')
-rwxr-xr-xinventory/multi_ec2.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/inventory/multi_ec2.py b/inventory/multi_ec2.py
index 2cbf33473..23cf5ecf1 100755
--- a/inventory/multi_ec2.py
+++ b/inventory/multi_ec2.py
@@ -239,22 +239,33 @@ class MultiEc2(object):
def apply_account_config(self, acc_config):
''' Apply account config settings
'''
- if not acc_config.has_key('hostvars') and not acc_config.has_key('all_group'):
- return
-
results = self.all_ec2_results[acc_config['name']]
- # Update each hostvar with the newly desired key: value
- for host_property, value in acc_config['hostvars'].items():
+
+ # Update each hostvar with the newly desired key: value
+ for new_var, value in acc_config.get('extra_vars', {}).items():
# Verify the account results look sane
# by checking for these keys ('_meta' and 'hostvars' exist)
if results.has_key('_meta') and results['_meta'].has_key('hostvars'):
for data in results['_meta']['hostvars'].values():
- data[str(host_property)] = str(value)
+ data[str(new_var)] = str(value)
# Add this group
if results.has_key(acc_config['all_group']):
- results["%s_%s" % (host_property, value)] = \
- copy.copy(results[acc_config['all_group']])
+ results["%s_%s" % (new_var, value)] = \
+ copy.copy(results[acc_config['all_group']])
+
+ # Clone groups goes here
+ for name_from, name_to in acc_config.get('clone_groups', {}).items():
+ if results.has_key(name_from):
+ results[name_to] = copy.copy(results[name_from])
+
+ # Clone vars goes here
+ for to_name, from_name in acc_config.get('clone_vars', {}).items():
+ # Verify the account results look sane
+ # by checking for these keys ('_meta' and 'hostvars' exist)
+ if results.has_key('_meta') and results['_meta'].has_key('hostvars'):
+ for data in results['_meta']['hostvars'].values():
+ data[str(to_name)] = data.get(str(from_name), 'nil')
# store the results back into all_ec2_results
self.all_ec2_results[acc_config['name']] = results