summaryrefslogtreecommitdiffstats
path: root/bin/ossh_bash_completion
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2015-08-12 09:37:11 -0400
committerKenny Woodson <kwoodson@redhat.com>2015-08-12 11:51:38 -0400
commit95161235972ec14fa7b2e10bc0ab21f5cce65db8 (patch)
tree73e1e53c9d19f214db421f0cd1aaf18304ef1509 /bin/ossh_bash_completion
parentf0cec74c0bdcbdec69f148a5fa4b9a9985df5253 (diff)
downloadopenshift-95161235972ec14fa7b2e10bc0ab21f5cce65db8.tar.gz
openshift-95161235972ec14fa7b2e10bc0ab21f5cce65db8.tar.bz2
openshift-95161235972ec14fa7b2e10bc0ab21f5cce65db8.tar.xz
openshift-95161235972ec14fa7b2e10bc0ab21f5cce65db8.zip
Updated to read config first and default to users home dir
Diffstat (limited to 'bin/ossh_bash_completion')
-rwxr-xr-xbin/ossh_bash_completion21
1 files changed, 17 insertions, 4 deletions
diff --git a/bin/ossh_bash_completion b/bin/ossh_bash_completion
index 1467de858..5072161f0 100755
--- a/bin/ossh_bash_completion
+++ b/bin/ossh_bash_completion
@@ -1,6 +1,12 @@
__ossh_known_hosts(){
- if [[ -f ~/.ansible/tmp/multi_ec2_inventory.cache ]]; then
- /usr/bin/python -c 'import json,os; z = json.loads(open("%s"%os.path.expanduser("~/.ansible/tmp/multi_ec2_inventory.cache")).read()); print "\n".join(["%s.%s" % (host["ec2_tag_Name"],host["ec2_tag_environment"]) for dns, host in z["_meta"]["hostvars"].items() if all(k in host for k in ("ec2_tag_Name", "ec2_tag_environment"))])'
+ if python -c 'import openshift_ansible' &>/dev/null; then
+ /usr/bin/python -c 'from openshift_ansible import multi_ec2; m=multi_ec2.MultiEc2(); m.run(); z=m.result; print "\n".join(["%s.%s" % (host["ec2_tag_Name"],host["ec2_tag_environment"]) for dns, host in z["_meta"]["hostvars"].items() if all(k in host for k in ("ec2_tag_Name", "ec2_tag_environment"))])'
+
+ elif [[ -f /dev/shm/.ansible/tmp/multi_ec2_inventory.cache ]]; then
+ /usr/bin/python -c 'import json; loc="/dev/shm/.ansible/tmp/multi_ec2_inventory.cache"; z=json.loads(open(loc).read()); print "\n".join(["%s.%s" % (host["ec2_tag_Name"],host["ec2_tag_environment"]) for dns, host in z["_meta"]["hostvars"].items() if all(k in host for k in ("ec2_tag_Name", "ec2_tag_environment"))])'
+
+ elif [[ -f ~/.ansible/tmp/multi_ec2_inventory.cache ]]; then
+ /usr/bin/python -c 'import json,os; loc="%s" % os.path.expanduser("~/.ansible/tmp/multi_ec2_inventory.cache"); z=json.loads(open(loc).read()); print "\n".join(["%s.%s" % (host["ec2_tag_Name"],host["ec2_tag_environment"]) for dns, host in z["_meta"]["hostvars"].items() if all(k in host for k in ("ec2_tag_Name", "ec2_tag_environment"))])'
fi
}
@@ -19,8 +25,15 @@ _ossh()
complete -F _ossh ossh oscp
__opssh_known_hosts(){
- if [[ -f ~/.ansible/tmp/multi_ec2_inventory.cache ]]; then
- /usr/bin/python -c 'import json,os; z = json.loads(open("%s"%os.path.expanduser("~/.ansible/tmp/multi_ec2_inventory.cache")).read()); print "\n".join(["%s" % (host["ec2_tag_host-type"]) for dns, host in z["_meta"]["hostvars"].items() if "ec2_tag_host-type" in host])'
+ if python -c 'import openshift_ansible' &>/dev/null; then
+ /usr/bin/python -c 'from openshift_ansible.multi_ec2 import MultiEc2; m=MultiEc2(); m.run(); print "\n".join(["%s" % (host["ec2_tag_host-type"]) for dns, host in m.result["_meta"]["hostvars"].items() if "ec2_tag_host-type" in host])'
+
+ elif [[ -f /dev/shm/.ansible/tmp/multi_ec2_inventory.cache ]]; then
+ /usr/bin/python -c 'import json; loc="/dev/shm/.ansible/tmp/multi_ec2_inventory.cache"; z=json.loads(open(loc).read()); print "\n".join(["%s" % (host["ec2_tag_host-type"]) for dns, host in z["_meta"]["hostvars"].items() if "ec2_tag_host-type" in host])'
+
+ elif [[ -f ~/.ansible/tmp/multi_ec2_inventory.cache ]]; then
+ /usr/bin/python -c 'import json,os; loc="%s" % os.path.expanduser("/dev/shm/.ansible/tmp/multi_ec2_inventory.cache"); z=json.loads(open(loc).read()); print "\n".join(["%s" % (host["ec2_tag_host-type"]) for dns, host in z["_meta"]["hostvars"].items() if "ec2_tag_host-type" in host])'
+
fi
}