blob: 268fb1b6fa2708095615c1938cd942072bc414af [file] [log] [blame]
Thomas Vachuska02aeb032015-01-06 22:36:30 -08001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Tool to manage ONOS applications using REST API.
4# -----------------------------------------------------------------------------
5
6node=${1:-$OCI}
7cmd=${2:-list}
8app=${3}
9
10export URL=http://$node:8181/onos/v1/applications
11export HDR="-HContent-Type:application/octet-stream"
12export curl="curl -sS"
13
Thomas Vachuskac4cb1002015-03-29 10:28:26 -070014function usage {
15 echo "usage: onos-app {install|install!} <app-file>" >&2
16 echo " onos-app {reinstall|reinstall!} <app-name> <app-file>" >&2
17 echo " onos-app {activate|deactivate|uninstall} <app-name>" >&2
18 exit 1
19}
20
Thomas Vachuska02aeb032015-01-06 22:36:30 -080021case $cmd in
22 list) $curl -X GET $URL;;
Thomas Vachuskac4cb1002015-03-29 10:28:26 -070023 install)
24 [ $# -lt 3 -o ! -f $app ] && usage
25 $curl -X POST $HDR $URL --data-binary @$app;;
26 install!)
27 [ $# -lt 3 -o ! -f $app ] && usage
28 $curl -X POST $HDR $URL?activate=true --data-binary @$app;;
29
30 reinstall)
31 [ $# -lt 4 -o ! -f $4 ] && usage
32 $curl -X DELETE $URL/$app
33 $curl -X POST $HDR $URL --data-binary @$4;;
34 reinstall!)
35 [ $# -lt 4 -o ! -f $4 ] && usage
36 $curl -X DELETE $URL/$app
37 $curl -X POST $HDR $URL?activate=true --data-binary @$4;;
38
39 uninstall)
40 [ $# -lt 3 ] && usage
41 $curl -X DELETE $URL/$app;;
42 activate)
43 [ $# -lt 3 ] && usage
44 $curl -X POST $URL/$app/active;;
45 deactivate)
46 [ $# -lt 3 ] && usage
47 $curl -X DELETE $URL/$app/active;;
48
49 *) usage;;
Thomas Vachuska02aeb032015-01-06 22:36:30 -080050esac