Merge pull request #1 from ciena/master
update fork uottremb/kind-voltha
diff --git a/README.md b/README.md
index de00524..e774489 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,9 @@
This repository describes how to deploy a 4 node (one control plane and
## Prerequisites
-You must have both Docker and the Go programming language install for this
-test environment to function. How to get these working is beyond the scope
-of this document.
+You must have both Docker, the Go programming language, and various tools
+installed (including `curl`, `sed`, and `jq`) for this test environment to
+function. How to get these working is beyond the scope of this document.
## Fetch Tools
```bash
@@ -13,8 +13,9 @@
curl -o $GOPATH/bin/kubectl -sSL https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/$(go env GOHOSTOS)/$(go env GOARCH)/kubectl
curl -o $GOPATH/bin/kind \
-sSL https://github.com/kubernetes-sigs/kind/releases/download/v0.4.0/kind-$(go env GOHOSTOS)-$(go env GOARCH)
+export VOLTCTL_VERSION=$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
curl -o $GOPATH/bin/voltctl \
- -sSL https://github.com/ciena/voltctl/releases/download/0.0.5-dev/voltctl-0.0.5_dev-$(go env GOHOSTOS)-$(go env GOARCH)
+ -sSL https://github.com/opencord/voltctl/releases/download/v$VOLTCTL_VERSION/voltctl-$VOLTCTL_VERSION-$(go env GOHOSTOS)-$(go env GOARCH)
curl -sSL https://git.io/get_helm.sh | USE_SUDO=false HELM_INSTALL_DIR=$(go env GOPATH)/bin bash
chmod 755 $GOPATH/bin/kind $GOPATH/bin/voltctl $GOPATH/bin/kubectl
export PATH=$(go env GOPATH)/bin:$PATH
diff --git a/voltha b/voltha
index b557ba6..4685cce 100755
--- a/voltha
+++ b/voltha
@@ -67,6 +67,8 @@
TYPE=${TYPE:-minimal}
NAME=${NAME:-$TYPE}
+
+ENABLE_ONOS_EXTRANEOUS_RULES=${ENABLE_ONOS_EXTRANEOUS_RULES:-no}
WITH_TIMINGS=${WITH_TIMINGS:-no}
WITH_BBSIM=${WITH_BBSIM:-no}
WITH_RADIUS=${WITH_RADIUS:-no}
@@ -78,6 +80,7 @@
WITH_ADAPTERS=${WITH_ADAPTERS:-yes}
WITH_SIM_ADAPTERS=${WITH_SIM_ADAPTERS:-yes}
WITH_OPEN_ADAPTERS=${WITH_OPEN_ADAPTERS:-yes}
+WITH_PORT_FORWARDS=${WITH_PORT_FORWARDS:-yes}
ONLY_ONE=${ONLY_ONE:-yes}
CONFIG_SADIS=${CONFIG_SADIS:-no}
INSTALL_ONOS_APPS=${INSTALL_ONOS_APPS:-no}
@@ -128,6 +131,12 @@
exit 1
fi
+function get_service_ep() {
+ local NS=$1
+ local NAME=$2
+ kubectl -n $NS get service $NAME -o json | jq -r '.spec.clusterIP + ":" + (.spec.ports[0].port|tostring)'
+}
+
# Used to verify configuration values are set to "yes" or "no" value or convert
# equivalents to "yes" or "no"
function verify_yes_no() {
@@ -147,6 +156,7 @@
}
ALL_YES_NO="\
+ ENABLE_ONOS_EXTRANEOUS_RULES \
WITH_TIMINGS \
WITH_BBSIM \
WITH_RADIUS \
@@ -158,6 +168,7 @@
WITH_ADAPTERS \
WITH_SIM_ADAPTERS \
WITH_OPEN_ADAPTERS \
+ WITH_PORT_FORWARDS \
CONFIG_SADIS \
JUST_K8S \
DEPLOY_K8S \
@@ -190,6 +201,7 @@
VOLTHA_API_PORT \
VOLTHA_SSH_PORT \
VOLTHA_ETCD_PORT \
+ VOLTHA_KAFKA_PORT \
VK_RELEASE \
KIND_VERSION \
VOLTCTL_VERSION \
@@ -221,6 +233,7 @@
VOLTHA_API_PORT=${VOLTHA_API_PORT:-5$(expr 55 + $DELTA)55}
VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(expr 50 + $DELTA)22}
VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(expr 23 + $DELTA)79}
+ VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
else
VALUES=$(echo $HAVE | sed -e 's/\s//g' | cut -d= -f2)
ONOS_API_PORT=${ONOS_API_PORT:-$(echo $VALUES | cut -d, -f1)}
@@ -228,11 +241,21 @@
VOLTHA_API_PORT=${VOLTHA_API_PORT:-$(echo $VALUES | cut -d, -f3)}
VOLTHA_SSH_PORT=${VOLTHA_SSH_PORT:-$(echo $VALUES | cut -d, -f4)}
VOLTHA_ETCD_PORT=${VOLTHA_ETCD_PORT:-$(echo $VALUES | cut -d, -f5)}
+ VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(echo $VALUES | cut -d, -f6)}
+
+ # A bit of a hueristic required here as the KAFKA port forward was
+ # added after the .voltha/ports files was created. Basically, if
+ # the VOLTHA_KAFKA_PORT isn't in the file then calculate the original
+ # DELTA from the VOLTHA_SSH_PORT and apply it to the VOLTHA_KAFKA_PORT
+ if [ -z "$VOLTHA_KAFKA_PORT" ]; then
+ DELTA=$((VOLTHA_SSH_PORT/100-50))
+ VOLTHA_KAFKA_PORT=${VOLTHA_KAFKA_PORT:-$(expr 90 + $DELTA)92}
+ fi
fi
PORTTMP=$(mktemp -u)
cat .voltha/ports | grep -v $NAME > $PORTTMP
-echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT" >> $PORTTMP
+echo "$NAME=$ONOS_API_PORT,$ONOS_SSH_PORT,$VOLTHA_API_PORT,$VOLTHA_SSH_PORT,$VOLTHA_ETCD_PORT,$VOLTHA_KAFKA_PORT" >> $PORTTMP
cp $PORTTMP .voltha/ports
rm -f $PORTTMP
@@ -408,10 +431,10 @@
bspin - "$MSG $GEAR"
while true; do
if [ $TYPE == "file" ]; then
- (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://127.0.0.1:$ONOS_API_PORT/onos/v1/$RESOURCE --data @$DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1
+ (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://$_ONOS_API_EP/onos/v1/$RESOURCE --data @$DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1
fi
if [ $TYPE == "json" ]; then
- (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://127.0.0.1:$ONOS_API_PORT/onos/v1/$RESOURCE --data $DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1
+ (set -x; curl --fail -sSL --user karaf:karaf -w "%{http_code}" -o $CMD_OUTPUT -X POST -H Content-Type:application/json http://$_ONOS_API_EP/onos/v1/$RESOURCE --data $DATA >$SC_OUTPUT 2>/dev/null) >>$CMD_ECHO 2>&1
fi
RESULT=$?
# Dump everything to the log
@@ -435,7 +458,7 @@
bspin - "Checking that $APP_ID is active $CLOCK"
while true; do
- (set -x; curl --fail -sSL --user karaf:karaf -X GET http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications/$APP_ID | grep ACTIVE >>$LOG 2>&1) >>$LOG 2>&1
+ (set -x; curl --fail -sSL --user karaf:karaf -X GET http://$_ONOS_API_EP/onos/v1/applications/$APP_ID | grep ACTIVE >>$LOG 2>&1) >>$LOG 2>&1
if [ $? -eq 0 ]; then
break
fi
@@ -452,12 +475,12 @@
while true; do
sspin -
# Attempt to delete old version (if it exists)
- (set -x; curl --fail -sSL --user karaf:karaf -X DELETE http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications/$NAME >>$LOG 2>&1) >>$LOG 2>&1
+ (set -x; curl --fail -sSL --user karaf:karaf -X DELETE http://$_ONOS_API_EP/onos/v1/applications/$NAME >>$LOG 2>&1) >>$LOG 2>&1
sspin -
if [ $? -ne 0 ]; then
continue
fi
- (set -x; curl --fail -sSL --user karaf:karaf -X POST -H Content-Type:application/octet-stream http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications?activate=true --data-binary @$APP >>$LOG 2>&1) >>$LOG 2>&1
+ (set -x; curl --fail -sSL --user karaf:karaf -X POST -H Content-Type:application/octet-stream http://$_ONOS_API_EP/onos/v1/applications?activate=true --data-binary @$APP >>$LOG 2>&1) >>$LOG 2>&1
if [ $? -eq 0 ]; then
break
fi
@@ -472,7 +495,7 @@
bspin - "$MSG $GO"
while true; do
sspin -
- (set -x; curl --fail -sSL --user karaf:karaf -X POST http://127.0.0.1:$ONOS_API_PORT/onos/v1/applications/$APP/active >>$LOG 2>&1) >>$LOG 2>&1
+ (set -x; curl --fail -sSL --user karaf:karaf -X POST http://$_ONOS_API_EP/onos/v1/applications/$APP/active >>$LOG 2>&1) >>$LOG 2>&1
if [ $? -eq 0 ]; then
break
fi
@@ -608,6 +631,8 @@
kill_port_forward voltha-api
sspin "Remove port-forwards: voltha-etcd-$NAME$CEOL"
kill_port_forward voltha-etcd-cluster-client
+ sspin "Remove port-forwards: voltha-kafka-$NAME$CEOL"
+ kill_port_forward voltha-kafka
espin "$VERIFIED Remove port-forwards$CEOL"
if [ $DEPLOY_K8S == "yes" ]; then
if [ -x ./bin/kind ]; then
@@ -1099,14 +1124,19 @@
fi
wait_for_pods - "default" 1 "includes" -1 "Waiting for ONOS to start" "onos-.*"
- bspin - "Forward ONOS API port $FORWARD"
- kill_port_forward onos-ui
- port_forward default onos-ui $ONOS_API_PORT 8181
- espin - $VERIFIED
- bspin - "Forward ONOS SSH port $FORWARD"
- kill_port_forward onos-ssh
- port_forward default onos-ssh $ONOS_SSH_PORT 8101
- espin - $VERIFIED
+ if [ $WITH_PORT_FORWARDS == "yes" ]; then
+ bspin - "Forward ONOS API port $FORWARD"
+ kill_port_forward onos-ui
+ port_forward default onos-ui $ONOS_API_PORT 8181
+ espin - $VERIFIED
+ bspin - "Forward ONOS SSH port $FORWARD"
+ kill_port_forward onos-ssh
+ port_forward default onos-ssh $ONOS_SSH_PORT 8101
+ espin - $VERIFIED
+ _ONOS_API_EP="127.0.0.1:$ONOS_API_PORT"
+ else
+ _ONOS_API_EP=$(get_service_ep default onos-ui)
+ fi
bspin - "Verify or download ONOS configuration support files $DOWNLOAD"
ONOS_FILES="olt-onos-enableExtraneousRules.json onos-aaa.json \
onos-dhcpl2relay.json onos-kafka.json onos-sadis-sample.json"
@@ -1164,7 +1194,9 @@
elif [ $WITH_IGMP == "no" ]; then
push_onos_config "json" "Disable VOLTHA ONOS IGMP provisioning" "configuration/org.opencord.olt.impl.OltFlowService" '{"enableIgmpOnProvisioning":false}'
fi
- push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
+ if [ $ENABLE_ONOS_EXTRANEOUS_RULES == "yes" ]; then
+ push_onos_config "file" "Enabling extraneous rules for ONOS" "configuration/org.onosproject.net.flow.impl.FlowRuleManager" "onos-files/olt-onos-enableExtraneousRules.json"
+ fi
if [ -f onos-files/onos-sadis.json ]; then
push_onos_config "file" "[optional] Push ONOS SADIS Configuration" "network/configuration/apps/org.opencord.sadis" "onos-files/onos-sadis.json"
elif [ "$CONFIG_SADIS" == "yes" ]; then
@@ -1286,22 +1318,28 @@
fi
fi
-STIME=$(date +%s)
-bspin - "Forward VOLTHA API port $FORWARD"
-kill_port_forward voltha-api
-port_forward voltha voltha-api $VOLTHA_API_PORT 55555
-espin - $VERIFIED
-bspin - "Forward VOLTHA ETCD port $FORWARD"
-kill_port_forward voltha-etcd-cluster-client
-port_forward voltha voltha-etcd-cluster-client $VOLTHA_ETCD_PORT 2379
-espin - $VERIFIED
-if [ "$WITH_TIMINGS" == "yes" ]; then
- printtime $(expr $(date +%s) - $STIME)
+if [ $WITH_PORT_FORWARDS == "yes" ]; then
+ STIME=$(date +%s)
+ bspin - "Forward VOLTHA API port $FORWARD"
+ kill_port_forward voltha-api
+ port_forward voltha voltha-api $VOLTHA_API_PORT 55555
+ espin - $VERIFIED
+ bspin - "Forward VOLTHA ETCD port $FORWARD"
+ kill_port_forward voltha-etcd-cluster-client
+ port_forward voltha voltha-etcd-cluster-client $VOLTHA_ETCD_PORT 2379
+ espin - $VERIFIED
+ bspin - "Forward VOLTHA Kafka port $FORWARD"
+ kill_port_forward voltha-kafka
+ port_forward voltha voltha-kafka $VOLTHA_KAFKA_PORT 9092
+ espin - $VERIFIED
+ if [ "$WITH_TIMINGS" == "yes" ]; then
+ printtime $(expr $(date +%s) - $STIME)
+ fi
fi
if [ $WITH_ONOS == "yes" -a $WITH_RADIUS == "yes" ]; then
bspin "Configure ONOS RADIUS Connection $GEAR"
- (set -x; cat onos-files/onos-aaa.json | sed -e "s/:RADIUS_IP:/$(kubectl -n voltha get service/radius -o jsonpath={.spec.clusterIP})/g" | curl --fail -sSL --user karaf:karaf -X POST http://127.0.0.1:$ONOS_API_PORT/onos/v1/network/configuration/apps/org.opencord.aaa -H Content-type:application/json -d@- >>$LOG 2>&1) >>$LOG 2>&1
+ (set -x; cat onos-files/onos-aaa.json | sed -e "s/:RADIUS_IP:/$(kubectl -n voltha get service/radius -o jsonpath={.spec.clusterIP})/g" | curl --fail -sSL --user karaf:karaf -X POST http://$_ONOS_API_EP/onos/v1/network/configuration/apps/org.opencord.aaa -H Content-type:application/json -d@- >>$LOG 2>&1) >>$LOG 2>&1
espin $VERIFIED
fi
@@ -1323,7 +1361,11 @@
bspin "Create voltctl configuration file"
(set -x; mkdir -p $HOME/.volt >>$LOG 2>&1) >>$LOG 2>&1
-(set -x; voltctl -a v2 -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1
+if [ $WITH_PORT_FORWARDS == "yes" ]; then
+ (set -x; voltctl -a v3 -k localhost:$VOLTHA_KAFKA_PORT -s localhost:$VOLTHA_API_PORT config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1
+else
+ (set -x; voltctl -a v3 -k $(get_service_ep voltha voltha-kafka) -s $(get_service_ep voltha voltha-api) config > $HOME/.volt/config-$NAME 2>>$LOG) >>$LOG 2>&1
+fi
espin $VERIFIED
if [ ! -f "$NAME-env.sh" ]; then