#!/bin/bash | |
maas login cord http://localhost/MAAS/api/1.0 '{{ apikey.stdout }}' > /dev/null | |
NODES=$(maas cord nodes list | jq '.[].hostname' | sed -e 's/"//g') | |
maas logout cord | |
cat <<EO_HEAD | |
{ | |
"head" : { | |
"hosts" : [ | |
"$(hostname --long)" | |
] | |
}, | |
"compute" : { | |
"hosts" : [ | |
EO_HEAD | |
if [ ! -z "$NODES" ]; then | |
for i in $(echo $NODES | sed -e 's/\([a-zA-Z0-9_-.]*\)/"\1"/g' -e 's/ /, /g'); do | |
echo " $i" | |
done | |
fi | |
cat << EO_TAIL | |
] | |
} | |
} | |
EO_TAIL |