blob: 368615ac2555f77af423b3531153cc50cb5cfb37 [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 {
Thomas Vachuska94117802015-04-17 10:27:18 -070015 echo "usage: onos-app <node-ip> list" >&2
16 echo " onos-app <node-ip> {install|install!} <app-file>" >&2
17 echo " onos-app <node-ip> {reinstall|reinstall!} <app-name> <app-file>" >&2
18 echo " onos-app <node-ip> {activate|deactivate|uninstall} <app-name>" >&2
Thomas Vachuskac4cb1002015-03-29 10:28:26 -070019 exit 1
20}
21
Thomas Vachuska94117802015-04-17 10:27:18 -070022[ -z $node -o "$node" = "-h" -o "$node" = "--help" -o "$node" = "-?" ] && usage
23
Thomas Vachuska02aeb032015-01-06 22:36:30 -080024case $cmd in
25 list) $curl -X GET $URL;;
Thomas Vachuskac4cb1002015-03-29 10:28:26 -070026 install)
27 [ $# -lt 3 -o ! -f $app ] && usage
28 $curl -X POST $HDR $URL --data-binary @$app;;
29 install!)
30 [ $# -lt 3 -o ! -f $app ] && usage
31 $curl -X POST $HDR $URL?activate=true --data-binary @$app;;
32
33 reinstall)
34 [ $# -lt 4 -o ! -f $4 ] && usage
35 $curl -X DELETE $URL/$app
36 $curl -X POST $HDR $URL --data-binary @$4;;
37 reinstall!)
38 [ $# -lt 4 -o ! -f $4 ] && usage
39 $curl -X DELETE $URL/$app
40 $curl -X POST $HDR $URL?activate=true --data-binary @$4;;
41
42 uninstall)
43 [ $# -lt 3 ] && usage
44 $curl -X DELETE $URL/$app;;
45 activate)
46 [ $# -lt 3 ] && usage
47 $curl -X POST $URL/$app/active;;
48 deactivate)
49 [ $# -lt 3 ] && usage
50 $curl -X DELETE $URL/$app/active;;
51
52 *) usage;;
Thomas Vachuska02aeb032015-01-06 22:36:30 -080053esac
Brian O'Connor3938f612015-04-14 15:01:32 -070054
Thomas Vachuska94117802015-04-17 10:27:18 -070055echo # new line for prompt