Skip to content

Commit

Permalink
[jjo] couple fixes and cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
jjo committed Jun 17, 2016
1 parent e15d159 commit 7504a84
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions etc/bash_completion.d/juju-2.0
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import json, sys; j=json.load(sys.stdin)
all_units=[]
for k,v in j["applications"].items():
if v.get("units"):
all_units.extend(v.get("units", {}).keys())
all_units.extend(v["units"].keys())
print ("\n".join([unit + trail for unit in all_units]))
' < ${1}
}
Expand All @@ -39,7 +39,7 @@ _juju_2_0_services_from_status_file() {
[ -n "${1}" ] || return 0
${_juju_cmd_PYTHON?} -c '
import json, sys; j=json.load(sys.stdin)
print ("\n".join(j("services", {}).keys()));' < ${1}
print ("\n".join(j.get("services", {}).keys()));' < ${1}
}

# Print (return) both services and units, currently used for juju status completion
Expand Down Expand Up @@ -82,10 +82,10 @@ _juju_2_0_list_controllers_models_noflags() {
# List all controller:models
local controllers=$(_juju_2_0_list_controllers_noflags 2>/dev/null)
[ -n "${controllers}" ] || { echo "ERROR: no valid controller found (current: ${cur_controller})" >&2; return 0 ;}
local controller
local controller=
for controller in ${controllers};do
_juju_2_0_cache_cmd 10 cat \
${_juju_cmd_JUJU_2_0?} list-models --controller ${controller} --format json | \
${_juju_cmd_JUJU_2_0?} list-models --controller ${controller} --format json |\
${_juju_cmd_PYTHON?} -c 'import json,sys; print ("\n".join(["'$controller:'" + m["name"] for m in json.load(sys.stdin)["models"]]))'
done

Expand Down

0 comments on commit 7504a84

Please sign in to comment.