Pass typefileserver as parameter in mass-pnf-sim 04/86904/1
authorRehanRaza <muhammad.rehan.raza@est.tech>
Fri, 3 May 2019 14:28:39 +0000 (14:28 +0000)
committerRehanRaza <muhammad.rehan.raza@est.tech>
Fri, 3 May 2019 14:28:39 +0000 (14:28 +0000)
Change-Id: I1168a5f10cce9b7d17324504a57d90dd9ee7790d
Issue-ID: DCAEGEN2-1434
Signed-off-by: RehanRaza <muhammad.rehan.raza@est.tech>
test/mocks/mass-pnf-sim/README.md
test/mocks/mass-pnf-sim/mass-pnf-sim.py
test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/config.yml
test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
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/simulator/SimulatorFactory.java

index cbbf075..07f74e2 100644 (file)
@@ -15,7 +15,7 @@ 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 --urlves http://10.148.95.??:10000/eventListener/v7 --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.??? --typefileserver sftp --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.
index 773b971..a02e3fd 100755 (executable)
@@ -39,6 +39,11 @@ parser.add_argument(
     help='Visible IP of the file server (SFTP/FTPS) to be included in the VES event',
 )
 
+parser.add_argument(
+    '--typefileserver',
+    help='Type of the file server (SFTP/FTPS) to be included in the VES event',
+)
+
 parser.add_argument(
     '--ipstart',
     help='IP address range beginning',
@@ -87,6 +92,7 @@ if args.bootstrap and args.ipstart and args.urlves:
         print("\tIp Pnf SIM:" + str(IpPnfSim))
 
         IpFileServer = args.ipfileserver
+        TypeFileServer = args.typefileserver
 
         
         PortSftp=start_port +1
@@ -114,6 +120,7 @@ if args.bootstrap and args.ipstart and args.urlves:
             str(args.urlves) + " " + \
             str(IpPnfSim) + " " + \
             str(IpFileServer) + " " + \
+            str(TypeFileServer) + " " + \
             str(PortSftp) + " " + \
             str(PortFtps) + " " + \
             str(UrlFtps) + " " + \
index 06c8320..f21329e 100644 (file)
@@ -4,6 +4,5 @@ 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
-defaultfileserver: sftp
-#defaultfileserver: ftps
+typefileserver: sftp
 ...
index 6507e05..f4435aa 100755 (executable)
@@ -20,8 +20,8 @@ function main(){
 
     case $COMMAND in
        "compose")
-            compose $2 $3 $4 $5 $6 $7 $8 $9 "${10}" "${11}" ;;
-             #IPGW, #IPSUBNET, #I, #IPVES, #IPPNFSIM, #IPFILESERVER, #PORTSFTP, #PORTFTPS, #IPFTPS, #IPSFTP
+            compose $2 $3 $4 $5 $6 $7 $8 $9 "${10}" "${11}" "${12}" ;;
+             #IPGW, #IPSUBNET, #I, #URLVES, #IPPNFSIM, #IPFILESERVER, #TYPEFILESERVER, #PORTSFTP, #PORTFTPS, #IPFTPS, #IPSFTP
         "build")
             build_image;;
         "start")
@@ -67,13 +67,14 @@ function compose(){
        export IPGW=$1
        export IPSUBNET=$2
        export I=$3
-       export IPVES=$4
+       export URLVES=$4
        export IPPNFSIM=$5
        export IPFILESERVER=$6
-       export PORTSFTP=$7
-       export PORTFTPS=$8
-       export IPFTPS=$9
-       export IPSFTP=${10}
+       export TYPEFILESERVER=$7
+       export PORTSFTP=$8
+       export PORTFTPS=$9
+       export IPFTPS=${10}
+       export IPSFTP=${11}
        LOCALTIME=$(ls -l /etc/localtime)
        export TIMEZONE=${LOCALTIME//*zoneinfo\/}
 
@@ -88,7 +89,7 @@ function compose(){
 
        set_vsftpd_file_owner
 
-       write_config $IPVES $IPFILESERVER $PORTSFTP $PORTFTPS $IPPNFSIM
+       write_config $URLVES $IPFILESERVER $TYPEFILESERVER $PORTSFTP $PORTFTPS $IPPNFSIM
 
 }
 
@@ -109,10 +110,10 @@ function set_vsftpd_file_owner() {
 function write_config(){
        #building a YML file for usage in Java
        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
+       echo "urlsftp: sftp://onap:pano@$2:$4" >> config/config.yml
+       echo "urlftps: ftps://onap:pano@$2:$5" >> config/config.yml
+       echo "ippnfsim: $6" >> config/config.yml
+       echo "typefileserver: $3" >> config/config.yml
 }
 
 function start(){
@@ -203,12 +204,14 @@ clear-logs - deletes log folder
 
 Starting simulation:
 - Setup the instance of this simulator by:
-  - ./simulator.sh compose IPGW IPSUBNET I IPVES IPPNFSIM IPFTPS IPSFTP
-       where Gw and subnet will be used for docker network
+  - ./simulator.sh compose IPGW IPSUBNET I URLVES IPPNFSIM IPFILESERVER TYPEFILESERVER PORTSFTP PORTFTPS IPFTPS IPSFTP
+       where IPGW and IPSUBNET will be used for docker network
        where I is the integer suffix to differentiate instances
-       where IPVES is the address of the VES collector
-       where IPPNFSIM, IPFTPS, IPSFTP are the addresses for containers
-       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
+       where URLVES is the URL of the VES collector
+       where IPPNFSIM, IPFILESERVER, IPFTPS, IPSFTP are the IP addresses for containers
+    where TYPEFILESERVER is the type of fileserver, i.e., FTPS or SFTP
+       where PORTSFTP, PORTFTPS are the SFTP and FTPS ports
+       e.g. ./simulator.sh compose 10.11.0.65 10.11.0.64 3 http://10.11.0.69:10000/eventListener/v7 10.11.0.2 10.11.0.66 ftps 2001 2002 10.11.0.67 10.11.0.68
 
 - Setup environment with "./simulator.sh start". It will download required docker images from the internet and run them on docker machine
 - 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}
index 89f59a3..3dd4aba 100644 (file)
@@ -5,14 +5,14 @@ public class PnfSimConfig {
     private String urlftps;
     private String urlsftp;
     private String ippnfsim;
-    private String defaultfileserver;
+    private String typefileserver;
 
-    public String getDefaultfileserver() {
-        return defaultfileserver;
+    public String getTypefileserver() {
+        return typefileserver;
     }
 
-    public void setDefaultfileserver(String defaultfileserver) {
-        this.defaultfileserver = defaultfileserver;
+    public void setTypefileserver(String typefileserver) {
+        this.typefileserver = typefileserver;
     }
 
 
@@ -50,10 +50,8 @@ public class PnfSimConfig {
 
     @Override
     public String toString() {
-        return "PnfSimConfig [vesip=" + urlves + ", urlftps=" + urlftps + ", ippnfsim=" + ippnfsim + ", urlsftp="
-                + urlsftp + "]";
+        return "PnfSimConfig [vesip=" + urlves + ", urlftps=" + urlftps + ", urlsftp=" + urlsftp + ", ippnfsim="
+                + ippnfsim + ", typefileserver=" + typefileserver + "]";
     }
 
-
-
 }
index 21717d8..851e6ad 100644 (file)
@@ -36,9 +36,9 @@ public class SimulatorFactory {
         PnfSimConfig configuration = ConfigurationProvider.getConfigInstance();
 
         String xnfUrl = null;
-        if (configuration.getDefaultfileserver().equals("sftp")) {
+        if (configuration.getTypefileserver().equals("sftp")) {
             xnfUrl = configuration.getUrlsftp() + "/";
-        } else if (configuration.getDefaultfileserver().equals("ftps")) {
+        } else if (configuration.getTypefileserver().equals("ftps")) {
             xnfUrl = configuration.getUrlftps() + "/";
         }