Honeynode Docker refactoring for Java11
[transportpce.git] / tests / Xtesting / DockerSims / dockercmd_profile.sh
1 #!/bin/sh
2
3 DEVICE_VERSION=${1:-1.2.1}
4
5 # this file centralizes inb one place parameters needed by docker scripts,
6 # more especially the image lists for 1.2.1 and 2.2.1 devices.
7 # device versions supported as scripts argument are 1.2.1 and 2.2.1 and "all"
8
9 #IMAGE_LIST format is suffix_port : container/image name : config file to fill netconf operational datastore
10
11 IMAGE121_LIST="30:xpdra-1.2.1:oper-XPDRA.xml
12 31:roadma-1.2.1:oper-ROADMA.xml
13 32:roadmb-1.2.1:oper-ROADMB.xml
14 33:roadmc-1.2.1:oper-ROADMC.xml
15 34:xpdrc-1.2.1:oper-XPDRC.xml
16 21:roadma-full-1.2.1:oper-ROADMA-full.xml
17 23:roadmc-full-1.2.1:oper-ROADMC-full.xml
18 "
19
20 IMAGE221_LIST="40:xpdra-2.2.1:oper-XPDRA.xml
21 41:roadma-2.2.1:oper-ROADMA.xml
22 42:roadmb-2.2.1:oper-ROADMB.xml
23 43:roadmc-2.2.1:oper-ROADMC.xml
24 44:xpdrc-2.2.1:oper-XPDRC.xml
25 45:spdrav2-2.2.1:oper-SPDRAv2.xml
26 46:spdrav1-2.2.1:oper-SPDRAv1.xml
27 "
28
29 case "$DEVICE_VERSION" in
30     "1.2.1") IMAGE_LIST=$IMAGE121_LIST
31     ;;
32     "2.2.1") IMAGE_LIST=$IMAGE221_LIST
33     ;;
34     *) echo "unsupported device version"
35     exit 1
36     ;;
37 esac
38
39 DOCKER_CMD=docker
40 DOCKER_IMAGE=honeynode:alpine-jre11
41 RESTCONF_USER=admin
42 RESTCONF_PASSWORD=admin
43 if [ `which podman` ]
44 then DOCKER_CMD=podman
45 else
46     if [ ! `which $DOCKER_CMD` ]
47     then  echo "no docker command available" >&2
48         exit 1
49     fi
50     #if "docker ps" cannot be run without error, prepend sudo
51     if ( ! $DOCKER_CMD ps >/dev/null 2>&1 );then
52         echo "docker command only usable as root, using sudo" >&2
53         DOCKER_CMD="sudo docker"
54     fi
55 fi
56
57