From 16e012ebf5770f542f2dcb58eff2bac24f029307 Mon Sep 17 00:00:00 2001 From: "guillaume.lambert" Date: Fri, 27 Mar 2020 22:32:57 +0100 Subject: [PATCH] Improve Honeynode Docker scripts to allow 1.2.1 and 2.2.1 containers simultaneous use and make it the default behaviour Signed-off-by: guillaume.lambert Change-Id: I200ebfe108c358181d9f28a96109758f33da4fb9 --- tests/Xtesting/DockerSims/Dockerfile | 4 +-- .../Xtesting/DockerSims/dockercmd_profile.sh | 32 ++++++++++--------- tests/Xtesting/DockerSims/start_sims.sh | 10 ++++-- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/tests/Xtesting/DockerSims/Dockerfile b/tests/Xtesting/DockerSims/Dockerfile index 59906c422..37518bca9 100644 --- a/tests/Xtesting/DockerSims/Dockerfile +++ b/tests/Xtesting/DockerSims/Dockerfile @@ -25,7 +25,7 @@ LABEL Maintainer="transportpce-dev@lists.opendaylight.org" LABEL Url="https://git.opendaylight.org/gerrit/transportpce" ENV DEVICE_VERSION=1.2.1 -ENV DEVICE_FILE=oper-ROADMA-full.xml +ENV DEVICE_FILE=1.2.1/oper-ROADMA-full.xml RUN addgroup gsimulator && adduser -D usimulator -G gsimulator -u 100001\ && mkdir -p /opt/application/simulators COPY --chown=usimulator:gsimulator --from=builder /tmp/honeynode/ /opt/application/simulators/honeynode @@ -35,4 +35,4 @@ USER usimulator WORKDIR /opt/application/simulators/honeynode HEALTHCHECK CMD wget --header "Authorization: Basic `echo -n "${USER}:${PASSWORD}" | base64`" http://localhost:8130/restconf/ -S -O - EXPOSE 1830/tcp 8130/tcp -CMD /opt/application/simulators/honeynode/honeynode_$DEVICE_VERSION/honeycomb-tpce 1830 /opt/application/simulators/honeynode/config/$DEVICE_VERSION/$DEVICE_FILE +CMD /opt/application/simulators/honeynode/honeynode_$DEVICE_VERSION/honeycomb-tpce 1830 /opt/application/simulators/honeynode/config/$DEVICE_FILE diff --git a/tests/Xtesting/DockerSims/dockercmd_profile.sh b/tests/Xtesting/DockerSims/dockercmd_profile.sh index 1f3aa4be1..5a8b2db56 100755 --- a/tests/Xtesting/DockerSims/dockercmd_profile.sh +++ b/tests/Xtesting/DockerSims/dockercmd_profile.sh @@ -1,6 +1,6 @@ #!/bin/sh -DEVICE_VERSION=${1:-1.2.1} +DEVICE_VERSION=${1:-all} # this file centralizes inb one place parameters needed by docker scripts, # more especially the image lists for 1.2.1 and 2.2.1 devices. @@ -8,22 +8,22 @@ DEVICE_VERSION=${1:-1.2.1} #IMAGE_LIST format is suffix_port : container/image name : config file to fill netconf operational datastore -IMAGE121_LIST="30:xpdra-1.2.1:oper-XPDRA.xml -31:roadma-1.2.1:oper-ROADMA.xml -32:roadmb-1.2.1:oper-ROADMB.xml -33:roadmc-1.2.1:oper-ROADMC.xml -34:xpdrc-1.2.1:oper-XPDRC.xml -21:roadma-full-1.2.1:oper-ROADMA-full.xml -23:roadmc-full-1.2.1:oper-ROADMC-full.xml +IMAGE121_LIST="30:xpdra-1.2.1:1.2.1/oper-XPDRA.xml +31:roadma-1.2.1:1.2.1/oper-ROADMA.xml +32:roadmb-1.2.1:1.2.1/oper-ROADMB.xml +33:roadmc-1.2.1:1.2.1/oper-ROADMC.xml +34:xpdrc-1.2.1:1.2.1/oper-XPDRC.xml +21:roadma-full-1.2.1:1.2.1/oper-ROADMA-full.xml +23:roadmc-full-1.2.1:1.2.1/oper-ROADMC-full.xml " -IMAGE221_LIST="40:xpdra-2.2.1:oper-XPDRA.xml -41:roadma-2.2.1:oper-ROADMA.xml -42:roadmb-2.2.1:oper-ROADMB.xml -43:roadmc-2.2.1:oper-ROADMC.xml -44:xpdrc-2.2.1:oper-XPDRC.xml -45:spdrav2-2.2.1:oper-SPDRAv2.xml -46:spdrav1-2.2.1:oper-SPDRAv1.xml +IMAGE221_LIST="40:xpdra-2.2.1:2.2.1/oper-XPDRA.xml +41:roadma-2.2.1:2.2.1/oper-ROADMA.xml +42:roadmb-2.2.1:2.2.1/oper-ROADMB.xml +43:roadmc-2.2.1:2.2.1/oper-ROADMC.xml +44:xpdrc-2.2.1:2.2.1/oper-XPDRC.xml +45:spdrav2-2.2.1:2.2.1/oper-SPDRAv2.xml +46:spdrav1-2.2.1:2.2.1/oper-SPDRAv1.xml " case "$DEVICE_VERSION" in @@ -31,6 +31,8 @@ case "$DEVICE_VERSION" in ;; "2.2.1") IMAGE_LIST=$IMAGE221_LIST ;; + "all") IMAGE_LIST=$IMAGE121_LIST" "$IMAGE221_LIST + ;; *) echo "unsupported device version" exit 1 ;; diff --git a/tests/Xtesting/DockerSims/start_sims.sh b/tests/Xtesting/DockerSims/start_sims.sh index dc594f75c..14693af7f 100755 --- a/tests/Xtesting/DockerSims/start_sims.sh +++ b/tests/Xtesting/DockerSims/start_sims.sh @@ -2,13 +2,17 @@ . $(dirname $0)/dockercmd_profile.sh -DOCKER_OPTIONS="-e USER=${RESTCONF_USER} -e PASSWORD=${RESTCONF_PASSWORD} -e DEVICE_VERSION=${DEVICE_VERSION} -dit ${DOCKER_IMAGE}" +DOCKER_OPTIONS="-e USER=${RESTCONF_USER} -e PASSWORD=${RESTCONF_PASSWORD} -dit ${DOCKER_IMAGE}" for image in $IMAGE_LIST;do suffix_port=`echo -n $image| cut -d: -f1` image_name=`echo -n $image| cut -d: -f2` device_file=`echo -n $image| cut -d: -f3` - #echo "$image_name $suffix_port $device_file" + if [ "${DEVICE_VERSION}" = "all" ] + then deviceversion=`echo -n $device_file| cut -d'/' -f1` + else + deviceversion=${DEVICE_VERSION} + fi if [ ! "$(${DOCKER_CMD} ps -q -f name=${image_name})" ];then if [ "$(${DOCKER_CMD} ps -aq -f status=exited -f name=${image_name})" ];then ${DOCKER_CMD} rm ${image_name} @@ -17,7 +21,7 @@ for image in $IMAGE_LIST;do ${DOCKER_CMD} stop ${image_name} fi echo ${image_name} - ${DOCKER_CMD} run --rm -p 178$suffix_port:1830 -p 81$suffix_port:8130 --name ${image_name} -e DEVICE_FILE=${device_file} ${DOCKER_OPTIONS} + ${DOCKER_CMD} run --rm -p 178$suffix_port:1830 -p 81$suffix_port:8130 --name ${image_name} -e DEVICE_VERSION=${deviceversion} -e DEVICE_FILE=${device_file} ${DOCKER_OPTIONS} done exit -- 2.36.6