5 COMPOSE_FILE_NAME=docker-compose.yml
6 NETOPEER_CONTAINER_NAME=netopeer
7 SIMULATOR_CONTAINER_NAME=pnf-simulator
9 SIMULATOR_START_URL=http://localhost:$SIMULATOR_PORT/simulator/start
10 SIMULATOR_STOP_URL=http://localhost:$SIMULATOR_PORT/simulator/stop
11 SIMULATOR_STATUS_URL=http://localhost:$SIMULATOR_PORT/simulator/status
12 RUNNING_COMPOSE_CONFIG=$COMPOSE_FILE_NAME
20 compose $2 $3 $4 $5 $6 $7 $8;;
21 #IPGW, #IPSUBNET, #I, #IPVES, #IPPNFSIM, #IPFTP, #IPSFTP,
25 start $COMPOSE_FILE_NAME;;
42 #creating custom docker-compose based on IP arguments
43 #creting config.json by injecting the same IP
53 #will insert $I to distinguish containers, networks properly
54 #docker compose cannot substitute these, as they are keys, not values.
55 envsubst < docker-compose-template.yml > docker-compose-temporary.yml
56 #variable substitution
57 docker-compose -f docker-compose-temporary.yml config > docker-compose.yml
58 rm docker-compose-temporary.yml
61 ./prepare-ROP-files.sh
66 write_config $IPVES $IPFTPS $IPSFTP
70 function build_image(){
71 if [ -f pom.xml ]; then
72 mvn clean package docker:build
74 echo "pom.xml file not found"
79 function set_vsftpd_file_owner() {
80 sudo chown root ./config/vsftpd_ssl.conf
84 function write_config(){
85 #building a YML file for usage in Java
86 echo "---" > config/config.yml
87 echo "configuration:" >> config/config.yml
88 echo " vesip: $1" >> config/config.yml
89 echo " ipftps: $2" >> config/config.yml
90 echo " ipsftp: $3" >> config/config.yml
95 if [[ $(running_containers) ]]; then
96 echo "Simulator containers are already up"
98 echo "Starting simulator containers using netconf model specified in config/netconf.env"
101 docker-compose -f $1 up -d
102 RUNNING_COMPOSE_CONFIG=$1
106 function running_containers(){
107 docker-compose -f $COMPOSE_FILE_NAME ps -q
112 if [[ $(running_containers) ]]; then
113 docker-compose -f $RUNNING_COMPOSE_CONFIG down
114 docker-compose -f $RUNNING_COMPOSE_CONFIG rm
116 echo "Simulator containers are already down"
120 function run_simulator(){
124 $(curl -s -X POST -H "Content-Type: application/json" -H "X-ONAP-RequestID: 123" -H "X-InvocationID: 456" -d @config/$CONFIG_JSON $SIMULATOR_START_URL)
128 function stop_simulator(){
131 $(curl -s -X POST $SIMULATOR_STOP_URL)
135 function get_status(){
137 if [[ $(running_containers) ]]; then
140 echo "Simulator containers are down"
144 function print_status(){
146 $(docker-compose -f $RUNNING_COMPOSE_CONFIG ps)
149 $(curl -s -X GET $SIMULATOR_STATUS_URL)
153 function print_help(){
156 build - locally builds simulator image from existing code
157 start - starts simulator and netopeer2 containers using remote simulator image and specified model name
158 compose - customize the docker-compose and configuration based on arguments
159 run-simulator - starts sending PNF registration messages with parameters specified in config.json
160 stop-simulator - stop sending PNF registration messages
161 stop - stops both containers
162 status - prints simulator status
163 clear-logs - deletes log folder
166 - Setup the instance of this simulator by:
167 - ./simulator.sh compose IPGW IPSUBNET I IPVES IPPNFSIM IPFTPS IPSFTP
168 where Gw and subnet will be used for docker network
169 where I is the integer suffix to differentiate instances
170 where IPVES is the address of the VES collector
171 where IPPNFSIM, IPFTPS, IPSFTP are the addresses for containers
172 e.g. ./simulator.sh compose 10.11.0.65 10.11.0.64 3 10.11.0.2 10.11.0.66 10.11.0.67 10.11.0.68
174 - Setup environment with "./simulator.sh start". It will download required docker images from the internet and run them on docker machine
175 - To start the simulation use "./simulator.sh run-simulator", which will start sending PNF registration messages with parameters specified in config.json {TODO, might not be needed}
177 To stop simulation use "./simulator.sh stop-simulator" command. To check simulator's status use "./simulator.sh status".
178 If you want to change message parameters simply edit config.json, then start the simulation with "./simulator.sh run-simulator" again
179 Logs are written to logs/pnf-simulator.log.
181 If you change the source code you have to rebuild image with "./simulator.sh build" and run "./simulator.sh start" again
185 function archive_logs(){
188 echo "Moving log file to archive"
189 DIR_PATH=logs/archive/simulator[$(timestamp)]
191 if [ -f logs/pnfsimulator.log ]; then
192 mv logs/pnfsimulator.log $DIR_PATH
195 if [ -f logs/*.xml ]; then
196 mv logs/*.xml $DIR_PATH
204 function clear_logs(){
206 if [[ $(running_containers) ]]; then
207 echo "Cannot delete logs when simulator is running"
213 function timestamp(){