summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2015-01-30 16:29:56 -0500
committerKenny Woodson <kwoodson@redhat.com>2015-01-30 16:29:56 -0500
commitd3dee2db1c87b074075b3bbcbe8931862ee7eca3 (patch)
tree5d1a0f38b7da189a2581376058082b71f12ddb2e /bin
parent0457b96cd5b5252010208ee8f74d0a3da49573b2 (diff)
downloadopenshift-d3dee2db1c87b074075b3bbcbe8931862ee7eca3.tar.gz
openshift-d3dee2db1c87b074075b3bbcbe8931862ee7eca3.tar.bz2
openshift-d3dee2db1c87b074075b3bbcbe8931862ee7eca3.tar.xz
openshift-d3dee2db1c87b074075b3bbcbe8931862ee7eca3.zip
Adding ossh.py
Diffstat (limited to 'bin')
-rw-r--r--bin/ansibleutil.py20
-rwxr-xr-xbin/ossh.py45
2 files changed, 64 insertions, 1 deletions
diff --git a/bin/ansibleutil.py b/bin/ansibleutil.py
index 7ba2c461e..a16a4dca9 100644
--- a/bin/ansibleutil.py
+++ b/bin/ansibleutil.py
@@ -22,7 +22,9 @@ class AnsibleUtil(object):
if p.returncode != 0:
raise RuntimeError(err)
- return json.loads(out)
+ with open('/tmp/ans.out','w') as fd:
+ fd.writelines(out)
+ return json.loads(out.strip())
def get_environments(self):
pattern = re.compile(r'^tag_environment_(.*)')
@@ -47,3 +49,19 @@ class AnsibleUtil(object):
groups.append(m.group(1))
return groups
+
+ def get_host_address(self):
+ pattern = re.compile(r'^tag_Name_(.*)')
+ inv = self.get_inventory()
+
+ inst_names = {}
+ for key in inv.keys():
+ m = pattern.match(key)
+ if m: inst_names[m.group(1)] = inv[key]
+
+
+ return inst_names
+
+
+
+
diff --git a/bin/ossh.py b/bin/ossh.py
new file mode 100755
index 000000000..2a24e807d
--- /dev/null
+++ b/bin/ossh.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+import argparse
+import ansibleutil
+import sys
+import os
+
+
+# use dynamic inventory
+# list instances
+# symlinked to ~/bin
+# list instances that match pattern
+# python!
+
+
+class Ossh(object):
+ def __init__(self):
+ self.file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)))
+ self.parse_cli_args()
+ self.ansible = ansibleutil.AnsibleUtil()
+
+ self.list_hosts()
+
+ def parse_cli_args(self):
+ parser = argparse.ArgumentParser(description='Openshift Online SSH Tool.')
+ parser.add_argument('-l', '--list', default=True,
+ action="store_true", help="list out hosts")
+
+ self.args = parser.parse_args()
+
+ def list_hosts(self):
+ # TODO: perform a numerical sort on these hosts
+ # and display them
+ print self.ansible.get_host_address()
+
+ def ssh(self):
+ pass
+
+def main():
+ ossh = Ossh()
+
+
+if __name__ == '__main__':
+ main()
+