lib/cac.sh cac_listservers: check response status

This commit is contained in:
tv 2015-05-20 21:26:55 +02:00
parent 4c00375cb2
commit 952ea06725
3 changed files with 10 additions and 19 deletions

8
infest
View File

@ -21,14 +21,6 @@ nix_find_sha1sum=86f8775bd4f0841edd4c816df861cebf509d58c3
main() {
listservers=$(cac_listservers)
listserversstatus=$(echo $listservers | jq -r .status)
case $listserversstatus in
ok) : ;;
*)
echo $0: bad listservers status: $listserversstatus >&2
exit 1
esac
config=$(echo $listservers \
| jq -r ".data|map(select(.servername == \"$cac_servername\"))[]")

View File

@ -1,8 +1,15 @@
. ./lib/url.sh
cac_listservers() {
_cac_get_api_v1 listservers
}
cac_listservers() {(
listservers=$(_cac_get_api_v1 listservers)
status=$(echo "$listservers" | jq -r .status)
if [ "$status" = ok ]; then
echo "$listservers"
else
echo "$0: bad listservers status: $status" >&2
exit 1
fi
)}
cac_listtasks() {
_cac_get_api_v1 listtasks

View File

@ -22,14 +22,6 @@ hostname=$2
main() {
listservers=$(cac_listservers)
listserversstatus=$(echo $listservers | jq -r .status)
case $listserversstatus in
ok) : ;;
*)
echo $0: bad listservers status: $listserversstatus >&2
exit 1
esac
config=$(echo $listservers \
| jq -r ".data|map(select(.servername == \"$cac_servername\"))[]")