summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMatt Woodson <mwoodson@gmail.com>2015-02-24 14:54:25 -0500
committerMatt Woodson <mwoodson@gmail.com>2015-02-24 14:54:25 -0500
commit50f53296253953fb2d3fff6bd7d7d3e538b9430b (patch)
treeb36794ef63768bab4f0fdab2fe87302c3805730d /bin
parent0d0b7fa2bba160e8d04ba0f67a0de5c7a06499db (diff)
parent44e939dba128ea0a02112af555fdf085edacf464 (diff)
downloadopenshift-50f53296253953fb2d3fff6bd7d7d3e538b9430b.tar.gz
openshift-50f53296253953fb2d3fff6bd7d7d3e538b9430b.tar.bz2
openshift-50f53296253953fb2d3fff6bd7d7d3e538b9430b.tar.xz
openshift-50f53296253953fb2d3fff6bd7d7d3e538b9430b.zip
Merge pull request #78 from mwoodson/tower_install
tower install
Diffstat (limited to 'bin')
-rw-r--r--bin/zsh_functions/_ossh49
1 files changed, 49 insertions, 0 deletions
diff --git a/bin/zsh_functions/_ossh b/bin/zsh_functions/_ossh
new file mode 100644
index 000000000..7c6cb7b0b
--- /dev/null
+++ b/bin/zsh_functions/_ossh
@@ -0,0 +1,49 @@
+#compdef ossh oscp
+
+_ossh_known_hosts(){
+ if [[ -f ~/.ansible/tmp/multi_ec2_inventory.cache ]]; then
+ print $(/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()])')
+ fi
+}
+
+_ossh(){
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+
+ common_arguments=(
+ '(- *)'{-h,--help}'[show help]' \
+ {-v,--verbose}'[enable verbose]' \
+ {-d,--debug}'[debug mode]' \
+ {-l,--login_name}+'[login name]:login_name' \
+ {-c,--command}+'[command to run on remote host]:command' \
+ {-o,--ssh_opts}+'[SSH Options to pass to SSH]:ssh options' \
+ {-e,--env}+'[environtment to use]:environment:->env' \
+ '--list[list out hosts]' \
+ ':OP Hosts:->oo_hosts'
+ )
+
+ case "$service" in
+ ossh)
+ _arguments -C -s \
+ "$common_arguments[@]" \
+ ;;
+
+ oscp)
+ _arguments -C -s \
+ "$common_arguments[@]" \
+ {-r,--recurse}'[Recursive copy]' \
+ ':file:_files'
+ ;;
+ esac
+
+ case "$state" in
+ oo_hosts)
+ _values 'oo_hosts' $(_ossh_known_hosts)
+ ;;
+ env)
+ _values 'environment' ops int stg prod
+ ;;
+ esac
+}
+
+_ossh "$@"