Thomas Vachuska
Committed by Gerrit Code Review

Added support to pre-stage apps as part of onos-setup-karaf.

Fixed onos-app reinstall command usage.

Change-Id: I1f5eb084a06fb16f7b2db7b61376211c25c4327a
...@@ -11,16 +11,40 @@ export URL=http://$node:8181/onos/v1/applications ...@@ -11,16 +11,40 @@ export URL=http://$node:8181/onos/v1/applications
11 export HDR="-HContent-Type:application/octet-stream" 11 export HDR="-HContent-Type:application/octet-stream"
12 export curl="curl -sS" 12 export curl="curl -sS"
13 13
14 +function 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 +
14 case $cmd in 21 case $cmd in
15 list) $curl -X GET $URL;; 22 list) $curl -X GET $URL;;
16 - install) $curl -X POST $HDR $URL --data-binary @$app;; 23 + install)
17 - install!) $curl -X POST $HDR $URL?activate=true --data-binary @$app;; 24 + [ $# -lt 3 -o ! -f $app ] && usage
18 - reinstall) $curl -X DELETE $URL/$app && $curl -X POST $HDR $URL --data-binary @$app;; 25 + $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;; 26 + install!)
20 - uninstall) $curl -X DELETE $URL/$app;; 27 + [ $# -lt 3 -o ! -f $app ] && usage
21 - activate) $curl -X POST $URL/$app/active;; 28 + $curl -X POST $HDR $URL?activate=true --data-binary @$app;;
22 - deactivate) $curl -X DELETE $URL/$app/active;; 29 +
23 - *) echo "usage: onos-app {install|install!|reinstall|reinstall!} <app-file>" >&2 30 + reinstall)
24 - echo " onos-app {activate|deactivate|uninstall} <app-name>" >&2 31 + [ $# -lt 4 -o ! -f $4 ] && usage
25 - exit 1;; 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;;
26 esac 50 esac
......
...@@ -70,9 +70,9 @@ if [ ! -f $KARAF_ROOT/lib/onos-branding-$ONOS_POM_VERSION.jar ]; then ...@@ -70,9 +70,9 @@ if [ ! -f $KARAF_ROOT/lib/onos-branding-$ONOS_POM_VERSION.jar ]; then
70 $KARAF_ROOT/lib 70 $KARAF_ROOT/lib
71 fi 71 fi
72 72
73 -if [ ! -d $STAGE/apps -o ! -d $STAGE/config ]; then 73 +if [ ! -d $STAGE/config ]; then
74 echo "Creating local cluster configs for IP $IP..." 74 echo "Creating local cluster configs for IP $IP..."
75 - mkdir -p $STAGE/apps $STAGE/config 75 + mkdir -p $STAGE/config
76 cat > $STAGE/config/cluster.json <<EOF 76 cat > $STAGE/config/cluster.json <<EOF
77 { "ipPrefix": "$SUBNET.*", 77 { "ipPrefix": "$SUBNET.*",
78 "nodes":[ { "id": "$IP", "ip": "$IP", "tcpPort": 9876 }]} 78 "nodes":[ { "id": "$IP", "ip": "$IP", "tcpPort": 9876 }]}
...@@ -88,3 +88,20 @@ echo "Setting up hazelcast.xml for subnet $SUBNET..." ...@@ -88,3 +88,20 @@ echo "Setting up hazelcast.xml for subnet $SUBNET..."
88 cp $ONOS_ROOT/tools/package/etc/hazelcast.xml $KARAF_ROOT/etc/hazelcast.xml 88 cp $ONOS_ROOT/tools/package/etc/hazelcast.xml $KARAF_ROOT/etc/hazelcast.xml
89 perl -pi.old -e "s/192.168.56/$SUBNET/" $KARAF_ROOT/etc/hazelcast.xml 89 perl -pi.old -e "s/192.168.56/$SUBNET/" $KARAF_ROOT/etc/hazelcast.xml
90 perl -pi.old -e "s/ <name>onos</ <name>$IP</" $KARAF_ROOT/etc/hazelcast.xml 90 perl -pi.old -e "s/ <name>onos</ <name>$IP</" $KARAF_ROOT/etc/hazelcast.xml
91 +
92 +
93 +echo "Staging builtin apps..."
94 +rm -fr $STAGE/apps
95 +mkdir -p $STAGE/apps
96 +find $ONOS_ROOT -name 'app.xml' | egrep -v '/src/test/|/target/|org\.foo\.' | \
97 + xargs grep 'name=' | sed 's/<app name="//g;s/".*//g' | while read line; do
98 + appxml=${line%:*}
99 + app=${line#*:}
100 + mkdir $STAGE/apps/$app
101 + cp $appxml $STAGE/apps/$app/app.xml
102 + done
103 +
104 +echo "Customizing apps to be auto-activated..."
105 +for app in $(echo $ONOS_APPS | tr ',' ' '); do
106 + touch $STAGE/apps/org.onosproject.$app/active
107 +done
......