Mass PNF-sim unique VSFTPD PASV ports

Issue-ID: DCAEGEN2-1660
Change-Id: Ib742755f6a924ee9c5babe8e411311e7fe0e6802
Signed-off-by: TamasBakai <tamas.bakai@est.tech>
diff --git a/test/mocks/mass-pnf-sim/mass-pnf-sim.py b/test/mocks/mass-pnf-sim/mass-pnf-sim.py
index a02e3fd..c3a17b0 100755
--- a/test/mocks/mass-pnf-sim/mass-pnf-sim.py
+++ b/test/mocks/mass-pnf-sim/mass-pnf-sim.py
@@ -76,6 +76,11 @@
     print("Bootstrap:")
 
     start_port=2000
+    ftps_pasv_port_start=8000
+    ftps_pasv_port_num_of_ports=10
+    
+    ftps_pasv_port_end=ftps_pasv_port_start + ftps_pasv_port_num_of_ports
+    
 
     for i in range(int(args.bootstrap)):
         print("PNF simulator instance: " + str(i) + ".")
@@ -124,7 +129,9 @@
             str(PortSftp) + " " + \
             str(PortFtps) + " " + \
             str(UrlFtps) + " " + \
-            str(UrlSftp)
+            str(UrlSftp) + " " + \
+            str(ftps_pasv_port_start) + " " + \
+            str(ftps_pasv_port_end)
 
         completed = subprocess.run(
             'set -x; cd ' +
@@ -133,6 +140,9 @@
             composercmd,
             shell=True)
         print('Cloning:', completed.stdout)
+        
+        ftps_pasv_port_start += ftps_pasv_port_num_of_ports + 1
+        ftps_pasv_port_end += ftps_pasv_port_num_of_ports +1
 
     completed = subprocess.run('set -x; cd pnf-sim-lightweight; ./simulator.sh build ', shell=True)
     print("Build docker image: ", completed.stdout)
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/vsftpd_ssl.conf b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/vsftpd_ssl-TEMPLATE.conf
similarity index 90%
rename from test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/vsftpd_ssl.conf
rename to test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/vsftpd_ssl-TEMPLATE.conf
index 99d64dc..75bb974 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/vsftpd_ssl.conf
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/vsftpd_ssl-TEMPLATE.conf
@@ -34,8 +34,8 @@
 connect_from_port_20=NO
 listen=YES
 tcp_wrappers=YES
-pasv_min_port=8001
-pasv_max_port=8010
+pasv_min_port=${FTPS_PASV_MIN}
+pasv_max_port=${FTPS_PASV_MAX}
 
 # SSL
 ssl_enable=Yes
@@ -55,3 +55,5 @@
 ssl_request_cert=YES
 ca_certs_file=/etc/ssl/private/dfc.crt
 
+write_enable=YES
+pasv_address=${IPFILESERVER}
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/docker-compose-template.yml b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/docker-compose-template.yml
index 2c9226a..d2c5290 100644
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/docker-compose-template.yml
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/docker-compose-template.yml
@@ -45,13 +45,14 @@
       front-${I}:
         ipv4_address: "${IPFTPS}"
     ports:
-         - "${PORTFTPS}:21"
+       - "${PORTFTPS}:21"
+       - "${FTPS_PASV_MIN}-${FTPS_PASV_MAX}:${FTPS_PASV_MIN}-${FTPS_PASV_MAX}"
     environment:
       FTP_USER: onap
       FTP_PASSWORD: pano
       PASV_ADDRESS: localhost
-      PASV_MIN_PORT: 8001
-      PASV_MAX_PORT: 8010
+      PASV_MIN_PORT: ${FTPS_PASV_MIN} 
+      PASV_MAX_PORT: ${FTPS_PASV_MAX}
     volumes:
       - ./tls/ftp.crt:/etc/ssl/private/ftp.crt:ro
       - ./tls/ftp.key:/etc/ssl/private/ftp.key:ro
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
index f4435aa..3de96da 100755
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
@@ -20,8 +20,8 @@
 
     case $COMMAND in
     	"compose")
-            compose $2 $3 $4 $5 $6 $7 $8 $9 "${10}" "${11}" "${12}" ;;
-             #IPGW, #IPSUBNET, #I, #URLVES, #IPPNFSIM, #IPFILESERVER, #TYPEFILESERVER, #PORTSFTP, #PORTFTPS, #IPFTPS, #IPSFTP
+            compose $2 $3 $4 $5 $6 $7 $8 $9 "${10}" "${11}" "${12}" "${13}" "${14}" ;;
+             #IPGW, #IPSUBNET, #I, #URLVES, #IPPNFSIM, #IPFILESERVER, #TYPEFILESERVER, #PORTSFTP, #PORTFTPS, #IPFTPS, #IPSFTP, #FTPS_PASV_MIN, #FTPS_PAST_MAX
         "build")
             build_image;;
         "start")
@@ -63,7 +63,7 @@
 function compose(){
 	#creating custom docker-compose based on IP arguments
 	#creting config.json by injecting the same IP
-
+	
 	export IPGW=$1
 	export IPSUBNET=$2
 	export I=$3
@@ -75,6 +75,8 @@
 	export PORTFTPS=$9
 	export IPFTPS=${10}
 	export IPSFTP=${11}
+	export FTPS_PASV_MIN=${12}
+	export FTPS_PASV_MAX=${13}
 	LOCALTIME=$(ls -l /etc/localtime)
 	export TIMEZONE=${LOCALTIME//*zoneinfo\/}
 
@@ -87,10 +89,14 @@
 
 	./ROP_file_creator.sh $I &
 
-	set_vsftpd_file_owner
-
 	write_config $URLVES $IPFILESERVER $TYPEFILESERVER $PORTSFTP $PORTFTPS $IPPNFSIM
 
+	cd config
+    envsubst < vsftpd_ssl-TEMPLATE.conf > vsftpd_ssl.conf
+	cd -
+
+	set_vsftpd_file_owner
+
 }
 
 function build_image(){