David K. Bainbridge | 915105d | 2016-07-06 14:10:08 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
David K. Bainbridge | 5522789 | 2016-07-07 12:48:53 -0700 | [diff] [blame^] | 3 | maas login cord http://localhost/MAAS/api/1.0 '{{ apikey.stdout }}' > /dev/null |
David K. Bainbridge | 915105d | 2016-07-06 14:10:08 -0700 | [diff] [blame] | 4 | NODES=$(maas cord nodes list | jq '.[].hostname' | sed -e 's/"//g') |
| 5 | maas logout cord |
| 6 | |
| 7 | cat <<EO_HEAD |
| 8 | { |
| 9 | "head" : { |
| 10 | "hosts" : [ |
| 11 | "$(hostname --long)" |
| 12 | ] |
| 13 | }, |
| 14 | "compute" : { |
| 15 | "hosts" : [ |
| 16 | EO_HEAD |
| 17 | |
David K. Bainbridge | 5522789 | 2016-07-07 12:48:53 -0700 | [diff] [blame^] | 18 | if [ ! -z "$NODES" ]; then |
| 19 | for i in $(echo $NODES | sed -e 's/\([a-zA-Z0-9_-.]*\)/"\1"/g' -e 's/ /, /g'); do |
| 20 | echo " $i" |
| 21 | done |
| 22 | fi |
David K. Bainbridge | 915105d | 2016-07-06 14:10:08 -0700 | [diff] [blame] | 23 | |
| 24 | cat << EO_TAIL |
| 25 | ] |
| 26 | } |
| 27 | } |
| 28 | EO_TAIL |