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
22 start $COMPOSE_FILE_NAME;;
24 start_netconf_server $COMPOSE_FILE_NAME;;
40 function build_image(){
41 if [ -f pom.xml ]; then
42 mvn clean package docker:build
44 echo "pom.xml file not found"
49 function set_vsftpd_file_owner() {
50 sudo chown root ./ftpes/vsftpd/configuration/vsftpd_ssl.conf
53 function start_netconf_server() {
55 docker-compose -f $1 up -d $NETOPEER_CONTAINER_NAME
57 echo "NETCONF server container's logs:"
58 docker exec $NETOPEER_CONTAINER_NAME /bin/bash -c "sysrepoctl --install --yang=/netconf/\$NETCONF_MODEL.yang --owner=netconf:nogroup --permissions=777"
59 docker exec $NETOPEER_CONTAINER_NAME /bin/bash -c "sysrepocfg --import=/netconf/\$NETCONF_MODEL.data.xml --datastore=startup --format=xml --level=3 \$NETCONF_MODEL"
60 docker exec -d $NETOPEER_CONTAINER_NAME /bin/bash -c "/opt/dev/sysrepo/build/examples/application_example \$NETCONF_MODEL"
66 if [[ $(running_containers) ]]; then
67 echo "Simulator containers are already up"
69 echo "Starting simulator containers using netconf model specified in config/netconf.env"
72 start_netconf_server $1
73 docker-compose -f $1 up -d $SIMULATOR_CONTAINER_NAME
74 RUNNING_COMPOSE_CONFIG=$1
78 function running_containers(){
79 docker-compose -f $COMPOSE_FILE_NAME ps -q
84 if [[ $(running_containers) ]]; then
85 docker-compose -f $RUNNING_COMPOSE_CONFIG down
87 echo "Simulator containers are already down"
91 function run_simulator(){
94 $(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)
98 function stop_simulator(){
101 $(curl -s -X POST $SIMULATOR_STOP_URL)
105 function get_status(){
107 if [[ $(running_containers) ]]; then
110 echo "Simulator containers are down"
114 function print_status(){
116 $(docker-compose -f $RUNNING_COMPOSE_CONFIG ps)
119 $(curl -s -X GET $SIMULATOR_STATUS_URL)
123 function print_help(){
126 build - locally builds simulator image from existing code
127 start - starts simulator and netopeer2 containers using remote simulator image and specified model name
128 start-dev - starts only netopeer2 container
129 run-simulator - starts sending PNF registration messages with parameters specified in config.json
130 stop-simulator - stop sending PNF registration messages
131 stop - stops both containers
132 status - prints simulator status
133 clear-logs - deletes log folder
137 - Setup environment with "./simulator.sh start". It will download required docker images from the internet and run them on docker machine
138 - To start the simulation use "./simulator.sh run-simulator", which will start sending PNF registration messages with parameters specified in config.json
140 To stop simulation use "./simulator.sh stop-simulator" command. To check simulator's status use "./simulator.sh status".
141 If you want to change message parameters simply edit config.json, then start the simulation with "./simulator.sh run-simulator" again
142 Logs are written to logs/pnf-simulator.log. After each "start/start-dev" old log files are moved to the archive
145 1. Build local simulator image using "./simulator.sh build"
146 2. Run containers with "./simulator.sh start-dev"
148 If you change the source code you have to rebuild image with "./simulator.sh build" and run "./simulator.sh start/start-dev" again
152 function archive_logs(){
155 echo "Moving log file to archive"
156 DIR_PATH=logs/archive/simulator[$(timestamp)]
158 if [ -f logs/pnfsimulator.log ]; then
159 mv logs/pnfsimulator.log $DIR_PATH
162 if [ -f logs/*.xml ]; then
163 mv logs/*.xml $DIR_PATH
171 function clear_logs(){
173 if [[ $(running_containers) ]]; then
174 echo "Cannot delete logs when simulator is running"
180 function timestamp(){