Merge "Clean up RKE scripts"
authorYang Xu <yang.xu3@huawei.com>
Wed, 27 Mar 2019 21:04:20 +0000 (21:04 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 27 Mar 2019 21:04:20 +0000 (21:04 +0000)
23 files changed:
test/mocks/datafilecollector-testharness/simulator-group/README.md [new file with mode: 0644]
test/mocks/datafilecollector-testharness/simulator-group/docker-compose-setup.sh [new file with mode: 0755]
test/mocks/datafilecollector-testharness/simulator-group/docker-compose-template.yml [new file with mode: 0644]
test/mocks/datafilecollector-testharness/simulator-group/setup-ftp-files-for-image.sh [new file with mode: 0755]
test/mocks/datafilecollector-testharness/simulator-group/simulators-kill.sh [new file with mode: 0755]
test/mocks/datafilecollector-testharness/simulator-group/simulators-start.sh [new file with mode: 0755]
test/mocks/mass-pnf-sim/README.md
test/mocks/mass-pnf-sim/clean.sh [new file with mode: 0755]
test/mocks/mass-pnf-sim/diagnostic.sh [new file with mode: 0755]
test/mocks/mass-pnf-sim/mass-pnf-sim.py
test/mocks/mass-pnf-sim/pnf-sim-lightweight/ROP_file_creator.sh
test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.json
test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.yml
test/mocks/mass-pnf-sim/pnf-sim-lightweight/json_schema/input_validator.json
test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/ConfigurationProvider.java
test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/FileProvider.java
test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/PnfSimConfig.java
test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/JSONObjectFactory.java
test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageConstants.java
test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/message/MessageProvider.java
test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/main/java/org/onap/pnfsimulator/simulator/SimulatorFactory.java
test/mocks/mass-pnf-sim/pnf-sim-lightweight/templates/file_template_new.xml.gz [moved from test/mocks/mass-pnf-sim/pnf-sim-lightweight/templates/file_template.xml.gz with 100% similarity]

diff --git a/test/mocks/datafilecollector-testharness/simulator-group/README.md b/test/mocks/datafilecollector-testharness/simulator-group/README.md
new file mode 100644 (file)
index 0000000..4d448f8
--- /dev/null
@@ -0,0 +1,41 @@
+#Introduction
+The purpose of the "simulator-group" is to run all containers in one go with specified behavior.
+Mainly this is needed for CSIT tests but can be used also for local testing.
+
+
+###Preparation 
+Build the mr-sim image.
+
+cd ../mr-sim
+
+Run the docker build command to build the image for the MR simulator: 'docker build -t mrsim:latest .
+
+cd ../dr-sim
+
+Run the docker build command to build the image for the DR simulators: `docker build -t drsim_common:latest . 
+
+
+cd ../simulator-group
+
+Copy the 'configuration' and 'tls' catalogues from the ftps-sftp-server dir.
+
+Check the README.md in ftps-sftp-server dir in case the cert need to be updated.
+
+cp -r ./ftps-sftp-server/configuration .
+
+cp -r ../ftps-sftp-server/tls .
+
+
+###Execution
+
+Edit the `docker-compose-setup.sh` to setup the env variables to the desired test behavior for each simulators.
+See each simulator to find a description of the available settings.
+
+Run the script `docker-compose-setup.sh`to create a docker-compose with the desired settings. All simulators
+will be started with the generated docker-compose.yml file
+
+Kill all the containers with `simulators-kill.se`
+
+`simulators_start.sh` is for CSIT test and requires the env variables for test setting to be present in the shell.
+`setup-ftp-files.for-image.sh` is for CSIT and executed when the ftp servers are started from the docker-compose-setup.sh`.
+
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-setup.sh b/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-setup.sh
new file mode 100755 (executable)
index 0000000..d0171a5
--- /dev/null
@@ -0,0 +1,11 @@
+#/bin/bash
+
+#Script for manually starting all simulators with test setting below
+
+export DR_TC=""
+export DR_REDIR_TC=""
+export MR_TC="--tc100"
+export BC_TC=""
+export NUM_FTPFILES="250"
+
+source ./simulators-start.sh
\ No newline at end of file
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-template.yml b/test/mocks/datafilecollector-testharness/simulator-group/docker-compose-template.yml
new file mode 100644 (file)
index 0000000..e7c7007
--- /dev/null
@@ -0,0 +1,59 @@
+version: '2'
+services:
+      
+  drsim:
+    network_mode: "host"
+    image: drsim_common:latest
+    ports:
+     - "3906:3906"
+     - "3907:3907"
+    container_name: dfc_dr-sim
+    command: node dmaapDR.js ${DR_TC}
+
+  drsim_redir:
+    image: drsim_common:latest
+    ports:
+     - "3908:3908"
+     - "3909:3909"
+    container_name: dfc_dr-redir-sim
+    command: node dmaapDR_redir.js ${DR_REDIR_TC}
+
+  mrsim:
+    image: mrsim:latest
+    ports:
+     - "2222:2222"
+    container_name: dfc_mr-sim
+    command: python mr-sim.py ${MR_TC}
+
+  sftp-server:
+    container_name: dfc_sftp-server
+    image: atmoz/sftp:alpine
+    ports:
+      - "1022:22"
+#    volumes:
+#      - ./files/onap/sftp/:/home/onap/
+    restart: on-failure
+    command: onap:pano:1001
+
+
+  ftpes-server-vsftpd:
+    container_name: dfc_ftpes-server-vsftpd
+    image: docker.io/panubo/vsftpd
+    ports:
+      - "21:21"
+      - "8001-8010:8001-8010"
+    environment:
+      FTP_USER: onap
+      FTP_PASSWORD: pano
+      PASV_ADDRESS: localhost
+      PASV_MIN_PORT: 8001
+      PASV_MAX_PORT: 8010
+    volumes:
+      - ./tls/ftp.crt:/etc/ssl/private/ftp.crt:ro
+      - ./tls/ftp.key:/etc/ssl/private/ftp.key:ro
+      - ./tls/dfc.crt:/etc/ssl/private/dfc.crt:ro
+      - ./configuration/vsftpd_ssl.conf:/etc/vsftpd_ssl.conf:ro
+
+#      - ./files/onap/ftps/:/srv/
+    restart: on-failure
+  
\ No newline at end of file
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/setup-ftp-files-for-image.sh b/test/mocks/datafilecollector-testharness/simulator-group/setup-ftp-files-for-image.sh
new file mode 100755 (executable)
index 0000000..d8e57a3
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# Script to create files for the FTP server to return upon request.
+# The file names matches the files names in the events polled from the MR simulator.
+# Intended for execution in the running ftp containers in the ftp-root dir.
+
+echo "Running ftp file creations"
+
+NUM=200 #Default number of files 
+
+if [ $# -eq 1 ]; then 
+    NUM=$1
+fi
+
+truncate -s 1MB 1MB.tar.gz
+truncate -s 5MB 5MB.tar.gz
+truncate -s 50MB 50MB.tar.gz
+
+
+i=0
+while [ $i -lt $NUM ]; do  #Problem with for loop and var substituion in curly bracket....so used good old style loop
+   ln -s 1MB.tar.gz 1MB_$i.tar.gz
+   ln -s 5MB.tar.gz 5MB_$i.tar.gz
+   let i=i+1
+done
+
+
+ln -s 50MB.tar.gz 50MB_0.tar.gz   #Large file, only for single file test
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/simulators-kill.sh b/test/mocks/datafilecollector-testharness/simulator-group/simulators-kill.sh
new file mode 100755 (executable)
index 0000000..b7cd6a3
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+#Stop all simulators 
+
+docker kill dfc_dr-sim
+docker kill dfc_dr-redir-sim
+docker kill dfc_mr-sim
+docker kill dfc_sftp-server
+docker kill dfc_ftpes-server-vsftpd
+
diff --git a/test/mocks/datafilecollector-testharness/simulator-group/simulators-start.sh b/test/mocks/datafilecollector-testharness/simulator-group/simulators-start.sh
new file mode 100755 (executable)
index 0000000..ef1b90a
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+
+# Starts all simulators with the test settings
+# Intended for CSIT test. For manual start, use the docker-compose-setup.sh
+
+docker-compose -f docker-compose-template.yml config > docker-compose.yml
+
+docker-compose up -d
+
+DR_SIM="$(docker ps -q --filter='name=dfc_dr-sim')"
+DR_RD_SIM="$(docker ps -q --filter='name=dfc_dr-redir-sim')"
+MR_SIM="$(docker ps -q --filter='name=dfc_mr-sim')"
+SFTP_SIM="$(docker ps -q --filter='name=dfc_sftp-server')"
+FTPS_SIM="$(docker ps -q --filter='name=dfc_ftpes-server-vsftpd')"
+
+#Wait for initialization of docker containers for all simulators
+for i in {1..10}; do
+if [ $(docker inspect --format '{{ .State.Running }}' $DR_SIM) ] && \
+[ $(docker inspect --format '{{ .State.Running }}' $DR_RD_SIM) ] && \
+[ $(docker inspect --format '{{ .State.Running }}' $MR_SIM) ] && \
+[ $(docker inspect --format '{{ .State.Running }}' $SFTP_SIM) ] && \
+[ $(docker inspect --format '{{ .State.Running }}' $FTPS_SIM) ]
+ then
+   echo "All simulators Running"
+   break
+ else
+   echo sleep $i
+   sleep $i
+ fi 
+done
+
+#Populate the ftp server with files
+if [ -z "$NUM_FTPFILES" ]
+ then
+ NUM_FTPFILES=200
+fi
+
+
+docker cp setup-ftp-files-for-image.sh $SFTP_SIM:/tmp/
+docker exec -w /home/onap/ $SFTP_SIM /tmp/setup-ftp-files-for-image.sh $NUM_FTPFILES >/dev/null 2>&1
+
+docker cp setup-ftp-files-for-image.sh $FTPS_SIM:/tmp/setup-ftp-files-for-image.sh
+docker exec -w /srv $FTPS_SIM /tmp/setup-ftp-files-for-image.sh $NUM_FTPFILES >/dev/null 2>&1
+
index ffa82c1..507a692 100644 (file)
@@ -15,7 +15,10 @@ The ipstart should align to a /28 Ip address range start (e.g. 10.11.0.16, 10.11
 For debug purposes, you can use your own IP address as VES collector, use "ip" command to determine it.
 
 Example:
-./mass-pnf-sim.py  --bootstrap 2 --ipves http://10.148.95.??:10000 --ipfileserver 10.148.95.??? --ipstart 10.11.0.16
+./mass-pnf-sim.py  --bootstrap 2 --urlves http://10.148.95.??:10000/eventListener/v7 --ipfileserver 10.148.95.??? --ipstart 10.11.0.16
+
+Note that the file creator is started at a time of the bootstrapping.
+Stop/start will not re-launch it.
 
 ###Replacing VES for test purposes
 `sudo nc -vv -l -k -p 10000`
@@ -24,7 +27,7 @@ Example:
 Define the amount of simulators to be launched
 ./mass-pnf-sim.py  --start 2
 
-###Trigger 
+###Trigger
 ./mass-pnf-sim.py  --trigger 2
 
 ###Stop and clean
diff --git a/test/mocks/mass-pnf-sim/clean.sh b/test/mocks/mass-pnf-sim/clean.sh
new file mode 100755 (executable)
index 0000000..28df0ef
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+killall ROP_file_creator.sh
+
+docker stop $(docker ps -aq); docker rm $(docker ps -aq)
+
+./mass-pnf-sim.py --clean
+
diff --git a/test/mocks/mass-pnf-sim/diagnostic.sh b/test/mocks/mass-pnf-sim/diagnostic.sh
new file mode 100755 (executable)
index 0000000..99e35cd
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+echo "======= docker ps"
+docker ps
+
+echo "======= Docker image cache"
+docker images nexus3.onap.org:10003/onap/masspnf-simulator
+
+export NUM_OF_SIMS=`find pnf-sim-lw* -maxdepth 0 | wc -l`
+echo $NUM_OF_SIMS
+
+if [ "$NUM_OF_SIMS" -gt 0 ];
+then
+       echo "======= docker-compose, first instance"
+       cat pnf-sim-lw-0/docker-compose.yml
+       
+       echo "======= Java config.yml, first instance"
+       cat pnf-sim-lw-0/config/config.yml
+fi
+
+if (("$NUM_OF_SIMS" > 2));
+then
+       echo "======= docker-compose, last instance"
+       cat pnf-sim-lw-$(($NUM_OF_SIMS-1))/docker-compose.yml
+       
+       echo "======= Java config.yml, last instance"
+       cat pnf-sim-lw-$(($NUM_OF_SIMS-1))/config/config.yml
+fi
+
+
index 898cd65..8a4f390 100755 (executable)
@@ -19,8 +19,8 @@ parser.add_argument(
 )
 
 parser.add_argument(
-    '--ipves',
-    help='IP of the VES collector',
+    '--urlves',
+    help='URL of the VES collector',
 )
 
 parser.add_argument(
@@ -56,7 +56,7 @@ parser.add_argument(
 
 args = parser.parse_args()
 
-if args.bootstrap and args.ipstart and args.ipves:
+if args.bootstrap and args.ipstart and args.urlves:
     print("Bootstrap:")
 
     start_port=2000
@@ -81,11 +81,11 @@ if args.bootstrap and args.ipstart and args.ipves:
         PortSftp=start_port +1
         PortFtps=start_port +2 
         start_port +=2
-        IpFtps = ipaddress.ip_address(args.ipstart) + int(3 + (i * 16))
-        print("\tIp Ftps: " + str(IpFtps))
+        UrlFtps = str(ipaddress.ip_address(args.ipstart) + int(3 + (i * 16)))
+        print("\tUrl Ftps: " + str(UrlFtps))
  
-        IpSftp = ipaddress.ip_address(args.ipstart) + int(4 + (i * 16))
-        print("\tIp Sftp:" + str(IpSftp))
+        UrlSftp = str(ipaddress.ip_address(args.ipstart) + int(4 + (i * 16)))
+        print("\tUrl Sftp: " + str(UrlSftp))
 
         foldername = "pnf-sim-lw-" + str(i)
         completed = subprocess.run('mkdir ' + foldername, shell=True)
@@ -96,17 +96,17 @@ if args.bootstrap and args.ipstart and args.ipves:
             shell=True)
         print('\tCloning folder:', completed.stdout)
 
-        composercmd = "./simulator.sh compose " +\
-            str(ip_gw) + " " +\
-            str(ip_subnet) + " " +\
-            str(i) + " " +\
-            str(args.ipves) + " " +\
-            str(IpPnfSim) + " " +\
-            str(IpFileServer) + " " +\
-            str(PortSftp) + " " +\
-            str(PortFtps) + " " +\
-            str(IpFtps) + " " +\
-            str(IpSftp)
+        composercmd = "./simulator.sh compose " + \
+            str(ip_gw) + " " + \
+            str(ip_subnet) + " " + \
+            str(i) + " " + \
+            str(args.urlves) + " " + \
+            str(IpPnfSim) + " " + \
+            str(IpFileServer) + " " + \
+            str(PortSftp) + " " + \
+            str(PortFtps) + " " + \
+            str(UrlFtps) + " " + \
+            str(UrlSftp)
 
         completed = subprocess.run(
             'set -x; cd ' +
@@ -116,6 +116,9 @@ if args.bootstrap and args.ipstart and args.ipves:
             shell=True)
         print('Cloning:', completed.stdout)
 
+    completed = subprocess.run('set -x; cd pnf-sim-lightweight; ./simulator.sh build ', shell=True)
+    print("Build docker image: ", completed.stdout)
+
     sys.exit()
 
 if args.clean:
index 39d8498..6ea6ffd 100755 (executable)
@@ -1,7 +1,8 @@
 #!/bin/bash
 MAIN_DIRECTORY=${PWD##*/}
-FILE_DIRECTORY=./files/onap
-FILE_TEMPLATE=./templates/file_template.xml.gz
+FULL_DIRECTORY=${PWD}
+FILE_DIRECTORY=$FULL_DIRECTORY/files/onap
+FILE_TEMPLATE=$FULL_DIRECTORY/templates/file_template_new.xml.gz
 UPDATE_MINS=15
 NUM_FILES=96
 
@@ -11,11 +12,11 @@ mkdir -p "$FILE_DIRECTORY"
 for ((n=0;n<$NUM_FILES;n++))
 do
        if [[ "$OSTYPE" == "linux-gnu" ]]; then         # Linux OS
-               DATE=$(date -d $(($UPDATE_MINS*$n))" minutes ago" +"%Y%m%d")
+               DATE=$(date -d $(($UPDATE_MINS*($n+1)-1))" minutes ago" +"%Y%m%d")
                TIME_START=$(date -d $(($UPDATE_MINS*($n+1)-1))" minutes ago" +"%H%M%z")
                TIME_END=$(date -d $(($UPDATE_MINS*$n))" minutes ago" +"%H%M%z")  
        elif [[ "$OSTYPE" == "darwin"* ]]; then         # Mac OS
-               DATE=$(date -v "-"$(($UPDATE_MINS*$n))"M" +"%Y%m%d")
+               DATE=$(date -v "-"$(($UPDATE_MINS*($n+1)-1))"M" +"%Y%m%d")
                TIME_START=$(date -v "-"$(($UPDATE_MINS*($n+1)-1))"M" +"%H%M%z")
                TIME_END=$(date -v "-"$(($UPDATE_MINS*$n))"M" +"%H%M%z")
        else
@@ -36,11 +37,12 @@ do
        OLD_TIMESTAMP=${TIMESTAMP_ARRAY[$NUM_FILES-1]}
        unset TIMESTAMP_ARRAY[$NUM_FILES-1]
 
-       DATE=$(date +"%Y%m%d")
        TIME_END=$(date +"%H%M%z")
        if [[ "$OSTYPE" == "linux-gnu" ]]; then         # Linux OS
+               DATE=$(date -d $(($UPDATE_MINS-1))" minutes ago" +"%Y%m%d")
                TIME_START=$(date -d $(($UPDATE_MINS-1))" minutes ago" +"%H%M%z")
        elif [[ "$OSTYPE" == "darwin"* ]]; then         # Mac OS
+               DATE=$(date -v "-"$(($UPDATE_MINS-1))"M" +"%Y%m%d")
                TIME_START=$(date -v "-"$(($UPDATE_MINS-1))"M" +"%H%M%z")
        else
                echo "ERROR: OS not supported"
index 8d6342d..9d2ba7e 100644 (file)
@@ -1,35 +1,15 @@
 {
   "simulatorParams": {
-    "vesServerUrl": "http://10.10.1.99:9999/eventListener/v7",
-    "testDuration": "1",
-    "messageInterval": "1"
+    "testDuration": "86400",
+    "messageInterval": "900"
   },
   "commonEventHeaderParams": {
-    "eventName": "pnfRegistration_Nokia_5gDu",
+    "eventName": "Noti_RnNode-Ericsson_FileReady",
     "nfNamingCode": "gNB",
-    "nfcNamingCode": "oam",
-    "sourceName": "NOK6061ZW3",
-    "sourceId": "val13",
-    "reportingEntityName": "NOK6061ZW3"
+    "nfcNamingCode": "oam"
   },
   "notificationParams": {
     "changeIdentifier": "PM_MEAS_FILES",
-    "changeType": "FileReady",
-    "arrayOfNamedHashMap": [
-      {"name": "A20161221.1031-1041.bin.gz", "hashMap": {
-        "location": "ftpes://192.169.0.1:22/ftp/rop/A20161224.1030-1045.bin.gz",
-        "compression": "gzip",
-        "fileFormatType": "org.3GPP.32.435#measCollec",
-        "fileFormatVersion": "V10"
-      }
-      },
-      {"name": "A20161222.1042-1102.bin.gz", "hashMap": {
-        "location": "ftpes://192.168.0.102:22/ftp/rop/A20161224.1045-1100.bin.gz",
-        "compression": "gzip",
-        "fileFormatType": "org.3GPP.32.435#measCollec",
-        "fileFormatVersion": "V10"
-      }
-      }
-    ]
+    "changeType": "FileReady"
   }
 }
index 206d918..06c8320 100644 (file)
@@ -1,7 +1,9 @@
 ---
-vesip: http://localhost:10000
-ipftps: 10.11.0.67
-ipsftp: 10.11.0.68
+urlves: http://localhost:10000/eventListener/v7
+urlftps: ftps://onap:pano@10.11.0.67
+urlsftp: sftp://onap:pano@10.11.0.68
 #when run in simulator, it does not have own IP
-ippnfsim: localhost  
+ippnfsim: localhost
+defaultfileserver: sftp
+#defaultfileserver: ftps
 ...
index 4e75e0a..7b38e05 100644 (file)
@@ -5,9 +5,6 @@
     "simulatorParams": {
       "type": "object",
       "properties": {
-        "vesServerUrl": {
-          "type": "string"
-        },
         "testDuration": {
           "type": "string"
         },
@@ -16,7 +13,6 @@
         }
       },
       "required": [
-        "vesServerUrl",
         "testDuration",
         "messageInterval"
       ]
         },
         "nfcNamingCode": {
           "type": "string"
-        },
-        "sourceName": {
-          "type": "string"
-        },
-        "sourceId": {
-          "type": "string"
-        },
-        "reportingEntityName": {
-          "type": "string"
         }
       },
       "required": [
-        "eventName",
-        "sourceName",
-        "sourceId",
-        "reportingEntityName"
+        "eventName"
       ]
     },
 
         },
         "changeType": {
           "type": "string"
-        },
-        "arrayOfNamedHashMap": {
-          "type": "array",
-          "items": [
-            {
-              "type": "object",
-              "properties": {
-                "name": {
-                  "type": "string"
-                },
-                "hashMap": {
-                  "type": "object",
-                  "properties": {
-                    "location": {
-                      "type": "string"
-                    },
-                    "compression": {
-                      "type": "string"
-                    },
-                    "fileFormatType": {
-                      "type": "string"
-                    },
-                    "fileFormatVersion": {
-                      "type": "string"
-                    }
-                  },
-                  "required": [
-                    "location",
-                    "compression",
-                    "fileFormatType",
-                    "fileFormatVersion"
-                  ]
-                }
-              },
-              "required": [
-                "name",
-                "hashMap"
-              ]
-            },
-            {
-              "type": "object",
-              "properties": {
-                "name": {
-                  "type": "string"
-                },
-                "hashMap": {
-                  "type": "object",
-                  "properties": {
-                    "location": {
-                      "type": "string"
-                    },
-                    "compression": {
-                      "type": "string"
-                    },
-                    "fileFormatType": {
-                      "type": "string"
-                    },
-                    "fileFormatVersion": {
-                      "type": "string"
-                    }
-                  },
-                  "required": [
-                    "location",
-                    "compression",
-                    "fileFormatType",
-                    "fileFormatVersion"
-                  ]
-                }
-              },
-              "required": [
-                "name",
-                "hashMap"
-              ]
-            }
-          ]
         }
       },
       "required": [
         "changeIdentifier",
-        "changeType",
-        "arrayOfNamedHashMap"
+        "changeType"
       ]
     }
   },
index 86f15a8..4c5d9f0 100755 (executable)
@@ -27,6 +27,11 @@ function main(){
         "start")
             start $COMPOSE_FILE_NAME;;
         "stop")
+            if [[ -z ${2+x} ]]
+            then
+               echo "Error: action 'stop' requires the instance identifier"
+               exit
+            fi
             stop $2;;
         "run-simulator")
             run_simulator;;
@@ -101,10 +106,11 @@ function set_vsftpd_file_owner() {
 
 function write_config(){
        #building a YML file for usage in Java
-       echo "vesip: $1" > config/config.yml
-       echo "ipsftp: $2:$3" >> config/config.yml
-       echo "ipftps: $2:$4" >> config/config.yml
+       echo "urlves: $1" > config/config.yml
+       echo "urlsftp: sftp://onap:pano@$2:$3" >> config/config.yml
+       echo "urlftps: ftps://onap:pano@$2:$4" >> config/config.yml
        echo "ippnfsim: $5" >> config/config.yml
+       echo "defaultfileserver: sftp" >> config/config.yml
 }
 
 function start(){
@@ -127,7 +133,7 @@ function running_containers(){
 
 function stop(){
        get_pnfsim_ip
-    kill $(ps -a | grep "[.]/ROP_file_creator.sh $1" | awk '{print $1}')
+    kill $(ps -ef | grep "[.]/ROP_file_creator.sh $1" | head -n 1 | awk '{print $2}')
 
     if [[ $(running_containers) ]]; then
         docker-compose -f $RUNNING_COMPOSE_CONFIG down
index 4b293e8..15c687e 100644 (file)
@@ -7,11 +7,6 @@ import java.io.File;
 public class ConfigurationProvider {
     static PnfSimConfig conf = null;
 
-    String IpVes = null;
-    String IpSftp = null;
-    String IpFtps = null;
-    String IpPnfsim = null;
-
     public static PnfSimConfig getConfigInstance() {
 
         ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
@@ -19,10 +14,10 @@ public class ConfigurationProvider {
             File file = new File("./config/config.yml");
 
             conf = mapper.readValue(file, PnfSimConfig.class);
-            System.out.println("Ves IP: " + conf.getVesip());
-            System.out.println("SFTP IP: " + conf.getIpsftp());
-            System.out.println("FTPS IP: " + conf.getIpftps());
-            System.out.println("FTPS IP: " + conf.getIppnfsim());
+            System.out.println("Ves URL: " + conf.getUrlves());
+            System.out.println("SFTP URL: " + conf.getUrlsftp());
+            System.out.println("FTPS URL: " + conf.getUrlftps());
+            System.out.println("PNF sim IP: " + conf.getIppnfsim());
 
         } catch (Exception e) {
             e.printStackTrace();
index 9361e4c..9eb7332 100644 (file)
@@ -7,34 +7,34 @@ import java.util.List;
 
 public class FileProvider {
 
-    public static ArrayList<String> getFiles() {
+    private FileProvider() {}
 
-        List<String> files = QueryFiles();
+    public static List<String> getFiles() {
 
-        Collections.sort(files);
+        List<String> files = queryFiles();
 
-        ArrayList<String> fileListSorted = new ArrayList<String>();
+        files.sort(Collections.reverseOrder());
+
+        List<String> fileListSorted = new ArrayList<>();
         for (String f : files) {
-            System.out.println("Next file: " + f);
             fileListSorted.add(f);
         }
         return fileListSorted;
     }
 
-    private static List<String> QueryFiles() {
+    private static List<String> queryFiles() {
 
         File folder = new File("./files/onap/");
         File[] listOfFiles = folder.listFiles();
-        ArrayList<String> results = new ArrayList<String>();
+        List<String> results = new ArrayList<>();
 
         if (listOfFiles.length == 0) {
-            return null;
+            return results;
             // TODO: this should be a thrown exception catched in the Simulator class
         }
 
         for (int i = 0; i < listOfFiles.length; i++) {
             if (listOfFiles[i].isFile()) {
-                System.out.println("File: " + listOfFiles[i].getName());
                 results.add(listOfFiles[i].getName());
             }
         }
index 4931b57..89f59a3 100644 (file)
@@ -1,49 +1,59 @@
 package org.onap.pnfsimulator;
 
 public class PnfSimConfig {
-    private String vesip;
-    private String ipftps;
-    private String ipsftp;
+    private String urlves;
+    private String urlftps;
+    private String urlsftp;
     private String ippnfsim;
+    private String defaultfileserver;
 
-    public String getVesip() {
-        return vesip;
+    public String getDefaultfileserver() {
+        return defaultfileserver;
     }
 
-    public void setVesip(String vesip) {
-        this.vesip = vesip;
+    public void setDefaultfileserver(String defaultfileserver) {
+        this.defaultfileserver = defaultfileserver;
     }
 
-    public String getIpftps() {
-        return ipftps;
+
+    public String getUrlves() {
+        return urlves;
     }
 
-    public void setIpftps(String ipftps) {
-        this.ipftps = ipftps;
+    public void setUrlves(String urlves) {
+        this.urlves = urlves;
     }
 
-    public String getIpsftp() {
-        return ipsftp;
+    public String getUrlftps() {
+        return urlftps;
     }
 
-    public void setIpsftp(String ipsftp) {
-        this.ipsftp = ipsftp;
+    public void setUrlftps(String urlftps) {
+        this.urlftps = urlftps;
     }
 
-    public void setIppnfsim(String ippnfsim) {
-        this.ippnfsim = ippnfsim;
+    public String getUrlsftp() {
+        return urlsftp;
     }
 
-    @Override
-    public String toString() {
-        return "PnfSimConfig [vesip=" + vesip + ", ipftps=" + ipftps + ", ippnfsim=" + ippnfsim + ", ipsftp=" + ipsftp
-                + "]";
+    public void setUrlsftp(String urlsftp) {
+        this.urlsftp = urlsftp;
+    }
+
+    public void setIppnfsim(String ippnfsim) {
+        this.ippnfsim = ippnfsim;
     }
 
     public String getIppnfsim() {
         return ippnfsim;
     }
 
+    @Override
+    public String toString() {
+        return "PnfSimConfig [vesip=" + urlves + ", urlftps=" + urlftps + ", ippnfsim=" + ippnfsim + ", urlsftp="
+                + urlsftp + "]";
+    }
+
 
 
 }
index 3ebf567..545a568 100644 (file)
 
 package org.onap.pnfsimulator.message;
 
+import static org.onap.pnfsimulator.message.MessageConstants.COMPRESSION;
+import static org.onap.pnfsimulator.message.MessageConstants.COMPRESSION_VALUE;
 import static org.onap.pnfsimulator.message.MessageConstants.EVENT_ID;
+import static org.onap.pnfsimulator.message.MessageConstants.FILE_FORMAT_TYPE;
+import static org.onap.pnfsimulator.message.MessageConstants.FILE_FORMAT_TYPE_VALUE;
+import static org.onap.pnfsimulator.message.MessageConstants.FILE_FORMAT_VERSION;
+import static org.onap.pnfsimulator.message.MessageConstants.FILE_FORMAT_VERSION_VALUE;
+import static org.onap.pnfsimulator.message.MessageConstants.HASH_MAP;
 import static org.onap.pnfsimulator.message.MessageConstants.INTERNAL_HEADER_FIELDS;
 import static org.onap.pnfsimulator.message.MessageConstants.LAST_EPOCH_MICROSEC;
+import static org.onap.pnfsimulator.message.MessageConstants.LOCATION;
+import static org.onap.pnfsimulator.message.MessageConstants.NAME;
 import static org.onap.pnfsimulator.message.MessageConstants.NOTIFICATION_FIELDS_VERSION;
 import static org.onap.pnfsimulator.message.MessageConstants.NOTIFICATION_FIELDS_VERSION_VALUE;
 import static org.onap.pnfsimulator.message.MessageConstants.PNF_LAST_SERVICE_DATE;
@@ -31,14 +40,20 @@ import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FI
 import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FIELDS_VERSION_VALUE;
 import static org.onap.pnfsimulator.message.MessageConstants.PRIORITY;
 import static org.onap.pnfsimulator.message.MessageConstants.PRIORITY_NORMAL;
+import static org.onap.pnfsimulator.message.MessageConstants.REPORTING_ENTITY_NAME;
 import static org.onap.pnfsimulator.message.MessageConstants.SEQUENCE;
 import static org.onap.pnfsimulator.message.MessageConstants.SEQUENCE_NUMBER;
+import static org.onap.pnfsimulator.message.MessageConstants.SOURCE_NAME;
 import static org.onap.pnfsimulator.message.MessageConstants.START_EPOCH_MICROSEC;
+import static org.onap.pnfsimulator.message.MessageConstants.TIME_ZONE_OFFSET;
 import static org.onap.pnfsimulator.message.MessageConstants.VERSION;
 import static org.onap.pnfsimulator.message.MessageConstants.VERSION_NUMBER;
 import static org.onap.pnfsimulator.message.MessageConstants.VES_EVENT_LISTENER_VERSION;
 import static org.onap.pnfsimulator.message.MessageConstants.VES_EVENT_LISTENER_VERSION_NUMBER;
-
+import java.io.File;
+import java.util.List;
+import java.util.TimeZone;
+import org.json.JSONArray;
 import org.json.JSONObject;
 
 final class JSONObjectFactory {
@@ -47,6 +62,7 @@ final class JSONObjectFactory {
         JSONObject commonEventHeader = new JSONObject();
         long timestamp = System.currentTimeMillis();
         commonEventHeader.put(EVENT_ID, generateEventId());
+        commonEventHeader.put(TIME_ZONE_OFFSET, generateTimeZone(timestamp));
         commonEventHeader.put(LAST_EPOCH_MICROSEC, timestamp);
         commonEventHeader.put(PRIORITY, PRIORITY_NORMAL);
         commonEventHeader.put(SEQUENCE, SEQUENCE_NUMBER);
@@ -54,6 +70,10 @@ final class JSONObjectFactory {
         commonEventHeader.put(INTERNAL_HEADER_FIELDS, new JSONObject());
         commonEventHeader.put(VERSION, VERSION_NUMBER);
         commonEventHeader.put(VES_EVENT_LISTENER_VERSION, VES_EVENT_LISTENER_VERSION_NUMBER);
+        String absPath = System.getProperty("user.dir");
+        String nodeName = absPath.substring(absPath.lastIndexOf(File.separator)+1);
+        commonEventHeader.put(SOURCE_NAME, nodeName);
+        commonEventHeader.put(REPORTING_ENTITY_NAME, nodeName);
         return commonEventHeader;
     }
 
@@ -71,11 +91,39 @@ final class JSONObjectFactory {
         return notificationFields;
     }
 
+    static JSONArray generateArrayOfNamedHashMap(List<String> fileList, String xnfUrl) {
+        JSONArray arrayOfNamedHashMap = new JSONArray();
+
+        for (String fileName : fileList) {
+            JSONObject namedHashMap = new JSONObject();
+            namedHashMap.put(NAME, fileName);
+
+            JSONObject hashMap = new JSONObject();
+            hashMap.put(FILE_FORMAT_TYPE, FILE_FORMAT_TYPE_VALUE);
+            hashMap.put(LOCATION, xnfUrl.concat(fileName));
+            hashMap.put(FILE_FORMAT_VERSION, FILE_FORMAT_VERSION_VALUE);
+            hashMap.put(COMPRESSION, COMPRESSION_VALUE);
+            namedHashMap.put(HASH_MAP, hashMap);
+
+            arrayOfNamedHashMap.put(namedHashMap);
+        }
+
+
+        return arrayOfNamedHashMap;
+    }
+
 
     static String generateEventId() {
         String timeAsString = String.valueOf(System.currentTimeMillis());
-        return String.format("registration_%s",
-            timeAsString.substring(timeAsString.length() - 11, timeAsString.length() - 3));
+        return String.format("FileReady_%s", timeAsString);
+    }
+
+    static String generateTimeZone(long timestamp) {
+        TimeZone timeZone = TimeZone.getDefault();
+        int offsetInMillis = timeZone.getOffset(timestamp);
+        String offsetHHMM = String.format("%02d:%02d", Math.abs(offsetInMillis / 3600000),
+                Math.abs((offsetInMillis / 60000) % 60));
+        return ("UTC" + (offsetInMillis >= 0 ? "+" : "-") + offsetHHMM);
     }
 
     private JSONObjectFactory() {
index 95e8f69..6ff6e5d 100644 (file)
@@ -43,6 +43,7 @@ public final class MessageConstants {
     //parameters
     static final String DOMAIN = "domain";
     static final String EVENT_ID = "eventId";
+    static final String TIME_ZONE_OFFSET = "timeZoneOffset";
     static final String EVENT_TYPE = "eventType";
     static final String LAST_EPOCH_MICROSEC = "lastEpochMicrosec";
     static final String PRIORITY = "priority";
@@ -51,6 +52,8 @@ public final class MessageConstants {
     static final String INTERNAL_HEADER_FIELDS = "internalHeaderFields";
     static final String VERSION = "version";
     static final String VES_EVENT_LISTENER_VERSION = "vesEventListenerVersion";
+    static final String SOURCE_NAME = "sourceName";
+    static final String REPORTING_ENTITY_NAME = "reportingEntityName";
     //constant values
     static final int SEQUENCE_NUMBER = 0;
     static final String VERSION_NUMBER = "4.0.1";
@@ -71,9 +74,20 @@ public final class MessageConstants {
     // Notifications
     //parameters
     static final String NOTIFICATION_FIELDS_VERSION = "notificationFieldsVersion";
+    static final String ARRAY_OF_NAMED_HASH_MAP = "arrayOfNamedHashMap";
+    static final String NAME = "name";
+    static final String HASH_MAP = "hashMap";
+    static final String FILE_FORMAT_TYPE = "fileFormatType";
+    static final String LOCATION = "location";
+    static final String FILE_FORMAT_VERSION = "fileFormatVersion";
+    static final String COMPRESSION = "compression";
+
     //constant values
     static final String NOTIFICATION_FIELDS_VERSION_VALUE = "2.0";
     static final String DOMAIN_NOTIFICATION ="notification";
+    static final String FILE_FORMAT_TYPE_VALUE = "org.3GPP.32.435#measCollec";
+    static final String FILE_FORMAT_VERSION_VALUE = "V10";
+    static final String COMPRESSION_VALUE = "gzip";
 
     private MessageConstants() {
     }
index 839d402..c863625 100644 (file)
@@ -17,6 +17,7 @@
 
 package org.onap.pnfsimulator.message;
 
+import static org.onap.pnfsimulator.message.MessageConstants.ARRAY_OF_NAMED_HASH_MAP;
 import static org.onap.pnfsimulator.message.MessageConstants.COMMON_EVENT_HEADER;
 import static org.onap.pnfsimulator.message.MessageConstants.DOMAIN;
 import static org.onap.pnfsimulator.message.MessageConstants.DOMAIN_NOTIFICATION;
@@ -25,7 +26,8 @@ import static org.onap.pnfsimulator.message.MessageConstants.EVENT;
 import static org.onap.pnfsimulator.message.MessageConstants.EVENT_TYPE;
 import static org.onap.pnfsimulator.message.MessageConstants.NOTIFICATION_FIELDS;
 import static org.onap.pnfsimulator.message.MessageConstants.PNF_REGISTRATION_FIELDS;
-import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import org.json.JSONArray;
@@ -35,6 +37,13 @@ public class MessageProvider {
 
     public JSONObject createMessage(JSONObject commonEventHeaderParams, Optional<JSONObject> pnfRegistrationParams,
             Optional<JSONObject> notificationParams) {
+        List<String> emptyList = new ArrayList<>();
+        String emptyString = "";
+        return createMessage(commonEventHeaderParams, pnfRegistrationParams, notificationParams, emptyList, emptyString);
+    }
+
+    public JSONObject createMessage(JSONObject commonEventHeaderParams, Optional<JSONObject> pnfRegistrationParams,
+            Optional<JSONObject> notificationParams, List<String> fileList, String xnfUrl) {
 
         if (!pnfRegistrationParams.isPresent() && !notificationParams.isPresent()) {
             throw new IllegalArgumentException(
@@ -59,6 +68,8 @@ public class MessageProvider {
         JSONObject notificationFields = JSONObjectFactory.generateNotificationFields();
         notificationParams.ifPresent(jsonObject -> {
             copyParametersToFields(jsonObject.toMap(), notificationFields);
+            JSONArray arrayOfNamedHashMap = JSONObjectFactory.generateArrayOfNamedHashMap(fileList, xnfUrl);
+            notificationFields.put(ARRAY_OF_NAMED_HASH_MAP, arrayOfNamedHashMap);
             commonEventHeader.put(DOMAIN, DOMAIN_NOTIFICATION);
             event.put(NOTIFICATION_FIELDS, notificationFields);
         });
@@ -74,150 +85,4 @@ public class MessageProvider {
             fieldsJsonObject.put(key, value);
         });
     }
-
-    public JSONObject createOneVes(JSONObject commonEventHeaderParams, Optional<JSONObject> pnfRegistrationParams,
-            Optional<JSONObject> notificationParams, String url, String fileName) {
-
-
-        if (!pnfRegistrationParams.isPresent() && !notificationParams.isPresent()) {
-            throw new IllegalArgumentException(
-                    "Both PNF registration and notification parameters objects are not present");
-        }
-        JSONObject event = new JSONObject();
-
-        JSONObject commonEventHeader = JSONObjectFactory.generateConstantCommonEventHeader();
-        Map<String, Object> commonEventHeaderFields = commonEventHeaderParams.toMap();
-        commonEventHeaderFields.forEach((key, value) -> {
-            commonEventHeader.put(key, value);
-        });
-
-        JSONObject pnfRegistrationFields = JSONObjectFactory.generatePnfRegistrationFields();
-        pnfRegistrationParams.ifPresent(jsonObject -> {
-            copyParametersToFields(jsonObject.toMap(), pnfRegistrationFields);
-            commonEventHeader.put(DOMAIN, DOMAIN_PNF_REGISTRATION);
-            commonEventHeader.put(EVENT_TYPE, DOMAIN_PNF_REGISTRATION);
-            event.put(PNF_REGISTRATION_FIELDS, pnfRegistrationFields);
-        });
-
-        JSONObject notificationFields = JSONObjectFactory.generateNotificationFields();
-
-        Map hashMap = new HashMap();
-        hashMap.put("location", "LOCATION_DUMMY");
-        hashMap.put("fileFormatType", "org.3GPP.32.435#measCollec");
-        hashMap.put("fileFormatVersion", "V10");
-        hashMap.put("compression", "gzip");
-
-
-        JSONObject jsonHashMap = new JSONObject();
-        jsonHashMap.put("hashmap", jsonHashMap);
-
-        JSONArray jsonArrayOfNamedHashMap = new JSONArray();
-        jsonArrayOfNamedHashMap.put(jsonHashMap);
-
-        event.put(COMMON_EVENT_HEADER, commonEventHeader);
-        JSONObject root = new JSONObject();
-        root.put(EVENT, event);
-        return root;
-
-    }
-
-    public JSONObject createOneVesEvent(String xnfUrl, String fileName) {
-
-        JSONObject nof = new JSONObject();
-
-        nof.put("notificationFieldsVersion", "2.0");
-
-        nof.put("changeType", "FileReady");
-        nof.put("changeIdentifier", "PM_MEAS_FILES");
-
-        JSONObject hm = new JSONObject();
-        hm.put("location", "ftpes://".concat(xnfUrl).concat(fileName));
-        hm.put("fileFormatType", "org.3GPP.32.435#measCollec");
-        hm.put("fileFormatVersion", "V10");
-        hm.put("compression", "gzip");
-
-        JSONObject aonhElement = new JSONObject();
-        aonhElement.put("name", fileName);
-        aonhElement.put("hashMap", hm);
-
-        JSONArray aonh = new JSONArray();
-        aonh.put(aonhElement);
-
-        nof.put("arrayOfNamedHashMap", aonh);
-
-        JSONObject ceh = new JSONObject(); // commonEventHandler
-        ceh.put("startEpochMicrosec", "1551865758690");
-        ceh.put("sourceId", "val13");
-        ceh.put("eventId", "registration_51865758");
-        ceh.put("nfcNamingCode", "oam");
-        ceh.put("priority", "Normal");
-        ceh.put("version", "4.0.1");
-        ceh.put("reportingEntityName", "NOK6061ZW3");
-        ceh.put("sequence", "0");
-        ceh.put("domain", "notification");
-        ceh.put("lastEpochMicrosec", "1551865758690");
-        ceh.put("eventName", "pnfRegistration_Nokia_5gDu");
-        ceh.put("vesEventListenerVersion", "7.0.1");
-        ceh.put("sourceName", "NOK6061ZW3");
-        ceh.put("nfNamingCode", "gNB");
-
-        JSONObject ihf = new JSONObject(); // internalHeaderFields
-        ceh.put("internalHeaderFields", ihf);
-
-        JSONObject eventContent = new JSONObject();
-        eventContent.put("commonEventHeader", ceh);
-        eventContent.put("notificationFields", nof);
-
-
-        JSONObject event = new JSONObject();
-        event.put("event", eventContent);
-
-        System.out.println("VES messages to be sent: ");
-        System.out.println(event.toString());
-
-        return event;
-
-     // @formatter:off
-        /*
-    {
-        "event": {
-            "commonEventHeader": {                          <== "ceh"
-                "startEpochMicrosec": "1551865758690",
-                "sourceId": "val13",
-                "eventId": "registration_51865758",
-                "nfcNamingCode": "oam",
-                "internalHeaderFields": {},                 <== "ihf"
-                "priority": "Normal",
-                "version": "4.0.1",
-                "reportingEntityName": "NOK6061ZW3",
-                "sequence": "0",
-                "domain": "notification",
-                "lastEpochMicrosec": "1551865758690",
-                "eventName": "pnfRegistration_Nokia_5gDu",
-                "vesEventListenerVersion": "7.0.1",
-                "sourceName": "NOK6061ZW3",
-                "nfNamingCode": "gNB"
-            },
-            "notificationFields": {                         <== "nof"
-                "": "",
-                "notificationFieldsVersion": "2.0",
-                "changeType": "FileReady",
-                "changeIdentifier": "PM_MEAS_FILES",
-                "arrayOfNamedHashMap": [                    <== "aonh"
-                    {                                       <== "aonhElement"
-                        "name": "A20161224.1030-1045.bin.gz",
-                        "hashMap": {                            <== "hm"
-                            "location": "ftpes://192.169.0.1:22/ftp/rop/A20161224.1030-1045.bin.gz",
-                            "fileFormatType": "org.3GPP.32.435#measCollec",
-                            "fileFormatVersion": "V10",
-                            "compression": "gzip"
-                         }
-                    }
-                ]
-            }
-        }
-    }
-    */
-     // @formatter:on
-    }
 }
index 917e4eb..54af2b9 100644 (file)
@@ -20,13 +20,11 @@ package org.onap.pnfsimulator.simulator;
 import static java.lang.Integer.parseInt;
 import static org.onap.pnfsimulator.message.MessageConstants.MESSAGE_INTERVAL;
 import static org.onap.pnfsimulator.message.MessageConstants.TEST_DURATION;
-import static org.onap.pnfsimulator.message.MessageConstants.VES_SERVER_URL;
 import com.github.fge.jsonschema.core.exceptions.ProcessingException;
 import java.io.IOException;
 import java.time.Duration;
-import java.util.ArrayList;
+import java.util.List;
 import java.util.Optional;
-import org.json.JSONArray;
 import org.json.JSONObject;
 import org.onap.pnfsimulator.ConfigurationProvider;
 import org.onap.pnfsimulator.FileProvider;
@@ -54,35 +52,28 @@ public class SimulatorFactory {
     public Simulator create(JSONObject simulatorParams, JSONObject commonEventHeaderParams,
             Optional<JSONObject> pnfRegistrationParams, Optional<JSONObject> notificationParams)
             throws ProcessingException, IOException, ValidationException {
-        Duration duration = Duration.ofSeconds(parseInt(simulatorParams.getString(TEST_DURATION)));
-        Duration interval = Duration.ofSeconds(parseInt(simulatorParams.getString(MESSAGE_INTERVAL)));
-        String vesUrl = simulatorParams.getString(VES_SERVER_URL);
+        PnfSimConfig configuration = ConfigurationProvider.getConfigInstance();
 
-        JSONObject messageBody =
-                messageProvider.createMessage(commonEventHeaderParams, pnfRegistrationParams, notificationParams);
-        validator.validate(messageBody.toString(), DEFAULT_OUTPUT_SCHEMA_PATH);
+        String xnfUrl = null;
 
-        JSONArray messageBodyArray = new JSONArray();
+        if (configuration.getDefaultfileserver().equals("sftp")) {
+            xnfUrl = configuration.getUrlsftp() + "/";
+        } else if (configuration.getDefaultfileserver().equals("ftps")) {
+            xnfUrl = configuration.getUrlftps() + "/";
+        }
 
-        PnfSimConfig configuration = ConfigurationProvider.getConfigInstance();
-        String xnfUrl = configuration.getIpsftp() + "/";
+        String urlVes = configuration.getUrlves();
 
-        ArrayList<String> fileList = FileProvider.getFiles();
-
-        // for (String f : fileList) {
-        // System.out.println("f processed from fileList: " + f.toString());
-        // JSONObject vesEvent = messageProvider.createOneVes(commonEventHeaderParams,
-        // pnfRegistrationParams,
-        // notificationParams, url, f);
-        // messageBodyArray.put(vesEvent);
-        // }
+        Duration duration = Duration.ofSeconds(parseInt(simulatorParams.getString(TEST_DURATION)));
+        Duration interval = Duration.ofSeconds(parseInt(simulatorParams.getString(MESSAGE_INTERVAL)));
 
-        String fileName = fileList.get(1);
-        System.out.println("f processed from fileList: " + fileName.toString());
-        JSONObject vesEvent = messageProvider.createOneVesEvent(xnfUrl, fileName);
+        List<String> fileList = FileProvider.getFiles();
+        JSONObject messageBody = messageProvider.createMessage(commonEventHeaderParams, pnfRegistrationParams,
+                notificationParams, fileList, xnfUrl);
+        validator.validate(messageBody.toString(), DEFAULT_OUTPUT_SCHEMA_PATH);
 
-        return Simulator.builder().withVesUrl(configuration.getVesip()).withDuration(duration).withInterval(interval)
-                .withMessageBody(vesEvent).build();
+        return Simulator.builder().withVesUrl(urlVes).withDuration(duration).withInterval(interval)
+                .withMessageBody(messageBody).build();
 
     }
 }