|
@@ -119,6 +119,7 @@ class MultiEc2(object):
|
|
"code": process.returncode
|
|
"code": process.returncode
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ # process --host results
|
|
if not self.args.host:
|
|
if not self.args.host:
|
|
# For any non-zero, raise an error on it
|
|
# For any non-zero, raise an error on it
|
|
for result in all_results:
|
|
for result in all_results:
|
|
@@ -128,7 +129,7 @@ class MultiEc2(object):
|
|
self.all_ec2_results[result['name']] = json.loads(result['out'])
|
|
self.all_ec2_results[result['name']] = json.loads(result['out'])
|
|
values = self.all_ec2_results.values()
|
|
values = self.all_ec2_results.values()
|
|
values.insert(0, self.result)
|
|
values.insert(0, self.result)
|
|
- [self.merge_destructively(self.result, x) for x in values]
|
|
|
|
|
|
+ [MultiEc2.merge_destructively(self.result, x) for x in values]
|
|
else:
|
|
else:
|
|
# For any 0 result, return it
|
|
# For any 0 result, return it
|
|
count = 0
|
|
count = 0
|
|
@@ -139,12 +140,13 @@ class MultiEc2(object):
|
|
if count > 1:
|
|
if count > 1:
|
|
raise RuntimeError("Found > 1 results for --host %s. \
|
|
raise RuntimeError("Found > 1 results for --host %s. \
|
|
This is an invalid state." % self.args.host)
|
|
This is an invalid state." % self.args.host)
|
|
- def merge_destructively(self, a, b):
|
|
|
|
|
|
+ @staticmethod
|
|
|
|
+ def merge_destructively(a, b):
|
|
"merges b into a"
|
|
"merges b into a"
|
|
for key in b:
|
|
for key in b:
|
|
if key in a:
|
|
if key in a:
|
|
if isinstance(a[key], dict) and isinstance(b[key], dict):
|
|
if isinstance(a[key], dict) and isinstance(b[key], dict):
|
|
- self.merge_destructively(a[key], b[key])
|
|
|
|
|
|
+ MultiEc2.merge_destructively(a[key], b[key])
|
|
elif a[key] == b[key]:
|
|
elif a[key] == b[key]:
|
|
pass # same leaf value
|
|
pass # same leaf value
|
|
# both lists so add each element in b to a if it does ! exist
|
|
# both lists so add each element in b to a if it does ! exist
|
|
@@ -181,7 +183,7 @@ class MultiEc2(object):
|
|
parser = argparse.ArgumentParser(description='Produce an Ansible Inventory file based on a provider')
|
|
parser = argparse.ArgumentParser(description='Produce an Ansible Inventory file based on a provider')
|
|
parser.add_argument('--list', action='store_true', default=True,
|
|
parser.add_argument('--list', action='store_true', default=True,
|
|
help='List instances (default: True)')
|
|
help='List instances (default: True)')
|
|
- parser.add_argument('--host', action='store',
|
|
|
|
|
|
+ parser.add_argument('--host', action='store', default=False,
|
|
help='Get all the variables about a specific instance')
|
|
help='Get all the variables about a specific instance')
|
|
self.args = parser.parse_args()
|
|
self.args = parser.parse_args()
|
|
|
|
|