Merge pull request #29 from uottremb/master
Update Voltha script with multiple BBSim capabilities (VOL-2621)
the remove helm loop needs some re-formating (indentation is wrong), i will patch that up in a post later.
diff --git a/README.md b/README.md
index 4e7120b..e774489 100644
--- a/README.md
+++ b/README.md
@@ -73,6 +73,7 @@
| `DEPLOY_K8S` | yes | Should the KinD Kubernetes cluster be deployed? |
| `JUST_K8S` | no | Should just the KinD Kubernetes cluster be depoyed? (i.e. no VOLTHA) |
| `WITH_BBSIM` | no | Should the BBSIM POD be deployed? |
+| `NUM_OF_BBSIM` | 1 | number of BBSIM POD to start (minimum = 1, maximum = 10) |
| `WITH_ONOS` | yes | Should `ONOS` service be deployed? |
| `WITH_RADIUS` | no | Should `freeradius` service be deployed? |
| `WITH_EAPOL` | no | Configure the OLT app to push EAPOL flows |
diff --git a/voltha b/voltha
index e974f2f..6ea3deb 100755
--- a/voltha
+++ b/voltha
@@ -103,6 +103,8 @@
VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION=${VOLTHA_ADAPTER_OPEN_ONU_CHART_VERSION:-latest}
ONOS_CHART_VERSION=${ONOS_CHART_VERSION:-latest}
EXTRA_HELM_INSTALL_ARGS=
+NUM_OF_BBSIM=${NUM_OF_BBSIM:-1}
+MAX_NUM_OF_BBSIM=10
HAVE_GO=$(which go >/dev/null 2>&1 && echo "yes" || echo "no")
HOSTOS=$(uname -s | tr "[:upper:]" "[:lower:"])
@@ -111,6 +113,18 @@
HOSTARCH="amd64"
fi
+# check number (range) of bbsim, max bbsim must not exceed 10 instances!
+# note: instances will be numbered from 0 to 9
+if [ "$1" == "up" ]; then
+ if [ "$NUM_OF_BBSIM" -lt 1 ]; then
+ >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is less than 1${NORMAL}"
+ exit 1
+ fi
+ if [ "$NUM_OF_BBSIM" -gt $MAX_NUM_OF_BBSIM ]; then
+ >&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid setting of BBSIM instances. NUM_OF_BBSIM is greater than $MAX_NUM_OF_BBSIM${NORMAL}"
+ exit 1
+ fi
+fi
# Verify TYPE setting
if [ $(echo ":minimal:full:" | grep -ic ":$TYPE:") -eq 0 ]; then
>&2 echo -e "${RED}${BOLD}${ERROR}ERROR:${NORMAL}${RED} Invalid \$TYPE value of '$TYPE'. Should be 'minimal' or 'full'${NORMAL}"
@@ -175,6 +189,7 @@
VOLTHA_CHART_VERSION \
VOLTHA_BBSIM_CHART \
VOLTHA_BBSIM_CHART_VERSION \
+ NUM_OF_BBSIM \
VOLTHA_ADAPTER_SIM_CHART \
VOLTHA_ADAPTER_SIM_CHART_VERSION \
VOLTHA_ADAPTER_OPEN_OLT_CHART \
@@ -633,11 +648,13 @@
EXPECT="etcd-operator onos open-olt open-onu sim voltha bbsim radius"
bspin "Remove Helm Deployments"
for i in $EXISTS; do
- if [ $(echo $EXPECT | grep -c $i) -eq 1 ]; then
+ for j in $EXPECT; do
+ if [[ $i =~ $j ]]; then
sspin "Remove Helm Deployments: $i$CEOL"
(set -x; ./bin/helm delete --no-hooks --purge $i >>$LOG 2>&1) >>$LOG 2>&1
fi
done
+ done
espin "$VERIFIED Remove Helm Deployments$CEOL"
if [ "$WAIT_ON_DOWN" == "yes" ]; then
# There should only be 13 or 15 PODs in the kube-system name
@@ -1267,13 +1284,20 @@
STIME=$(date +%s)
echo -e "Verify BBSIM $PLUG"
bspin - "Verify BBSIM Installed"
- if [ $(helm list --deployed --short --namespace voltha "^bbsim\$" | wc -l) -ne 1 ]; then
- espin - $NOT_VERIFIED
- helm_install - voltha bbsim $VOLTHA_BBSIM_CHART $VOLTHA_BBSIM_CHART_VERSION "Install BBSIM"
- else
- espin - $VERIFIED
- fi
- wait_for_pods - "voltha" 1 "includes" -1 "Waiting for BBSIM to start" "bbsim-.*"
+ for instance in $(seq 0 $(($NUM_OF_BBSIM-1))); do
+ if [ $instance -eq 0 ]; then
+ instance_num=""
+ else
+ instance_num=$instance
+ fi
+ if [ $(helm list --deployed --short --namespace voltha "^bbsim${instance_num}\$" | wc -l) -ne 1 ]; then
+ espin - $NOT_VERIFIED
+ helm_install - voltha bbsim${instance_num} $VOLTHA_BBSIM_CHART $VOLTHA_BBSIM_CHART_VERSION "Install BBSIM${instance_num}"
+ else
+ espin - $VERIFIED
+ fi
+ done
+ wait_for_pods - "voltha" $NUM_OF_BBSIM "includes" -1 "Waiting for BBSIM to start" "bbsim*"
if [ "$WITH_TIMINGS" == "yes" ]; then
printtime $(expr $(date +%s) - $STIME)
fi