summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2015-10-28 15:29:42 -0400
committerKenny Woodson <kwoodson@redhat.com>2015-10-28 15:29:42 -0400
commit1922c6ee18c3a893c130b87e0e44de5c2ecf0fa0 (patch)
tree129b95f8536b2e91be78398e532480db24ccd7fa
parent028e1ce2f711527e5fd41ffbe7505e0340e78eac (diff)
parentca492ffb62208e95e46d50dd648511bd2ae09536 (diff)
downloadopenshift-1922c6ee18c3a893c130b87e0e44de5c2ecf0fa0.tar.gz
openshift-1922c6ee18c3a893c130b87e0e44de5c2ecf0fa0.tar.bz2
openshift-1922c6ee18c3a893c130b87e0e44de5c2ecf0fa0.tar.xz
openshift-1922c6ee18c3a893c130b87e0e44de5c2ecf0fa0.zip
Merge pull request #753 from kwoodson/minven
Fixing multi_ec2 with clone_vars, clone_groups, and renamed hostvars to extra_vars.
-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