Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Tool to manage ONOS applications using REST API. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | node=${1:-$OCI} |
| 7 | cmd=${2:-list} |
| 8 | app=${3} |
| 9 | |
| 10 | export URL=http://$node:8181/onos/v1/applications |
| 11 | export HDR="-HContent-Type:application/octet-stream" |
| 12 | export curl="curl -sS" |
| 13 | |
| 14 | case $cmd in |
| 15 | list) $curl -X GET $URL;; |
| 16 | install) $curl -X POST $HDR $URL --data-binary @$app;; |
Thomas Vachuska | 62ad95f | 2015-02-18 12:11:36 -0800 | [diff] [blame] | 17 | install!) $curl -X POST $HDR $URL?activate=true --data-binary @$app;; |
Thomas Vachuska | fba2857 | 2015-03-25 18:48:59 -0700 | [diff] [blame] | 18 | reinstall) $curl -X DELETE $URL/$app && $curl -X POST $HDR $URL --data-binary @$app;; |
| 19 | reinstall!) $curl -X DELETE $URL/$app && $curl -X POST $HDR $URL?activate=true --data-binary @$app;; |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 20 | uninstall) $curl -X DELETE $URL/$app;; |
| 21 | activate) $curl -X POST $URL/$app/active;; |
| 22 | deactivate) $curl -X DELETE $URL/$app/active;; |
Thomas Vachuska | fba2857 | 2015-03-25 18:48:59 -0700 | [diff] [blame] | 23 | *) echo "usage: onos-app {install|install!|reinstall|reinstall!} <app-file>" >&2 |
Thomas Vachuska | 62ad95f | 2015-02-18 12:11:36 -0800 | [diff] [blame] | 24 | echo " onos-app {activate|deactivate|uninstall} <app-name>" >&2 |
| 25 | exit 1;; |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 26 | esac |