summaryrefslogtreecommitdiffstats
path: root/bin/ansibleutil.py
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2015-02-11 10:38:47 -0500
committerKenny Woodson <kwoodson@redhat.com>2015-02-11 10:38:47 -0500
commit7d368f62f06a37a92cf8d644842c338ba55b1d67 (patch)
tree22babbeff88cbf5df9c44361e083bdb11d8d8e83 /bin/ansibleutil.py
parentaafbcce3605b7f992ba4b73d67286dbb40461baa (diff)
downloadopenshift-7d368f62f06a37a92cf8d644842c338ba55b1d67.tar.gz
openshift-7d368f62f06a37a92cf8d644842c338ba55b1d67.tar.bz2
openshift-7d368f62f06a37a92cf8d644842c338ba55b1d67.tar.xz
openshift-7d368f62f06a37a92cf8d644842c338ba55b1d67.zip
initial commit of scp utilitiy
Diffstat (limited to 'bin/ansibleutil.py')
-rw-r--r--bin/ansibleutil.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/bin/ansibleutil.py b/bin/ansibleutil.py
index b12b7b447..f5f699918 100644
--- a/bin/ansibleutil.py
+++ b/bin/ansibleutil.py
@@ -17,7 +17,8 @@ class AnsibleUtil(object):
if args:
cmd.extend(args)
- env = {}
+ env = os.environ
+
p = subprocess.Popen(cmd, stderr=subprocess.PIPE,
stdout=subprocess.PIPE, env=env)
@@ -66,4 +67,23 @@ class AnsibleUtil(object):
return inst_by_env
+ def get_hostnames(self, args=[]):
+ inv = self.get_inventory(args)
+
+ import collections
+ hostnames = collections.defaultdict(list)
+
+ for dns, host in inv['_meta']['hostvars'].items():
+ hostnames['ec2_tag_Name'].append(host['ec2_id'])
+
+ return hostnames
+
+ def get_host_ids(self, args=[]):
+ inv = self.get_inventory(args)
+
+ ids = {}
+
+ for dns, host in inv['_meta']['hostvars'].items():
+ ids['ec2_id'] = host
+ return ids