Mass PNF-sim unique VSFTPD PASV ports 47/91247/1
authorTamasBakai <tamas.bakai@est.tech>
Thu, 11 Jul 2019 11:26:20 +0000 (11:26 +0000)
committerTamasBakai <tamas.bakai@est.tech>
Thu, 11 Jul 2019 11:26:20 +0000 (11:26 +0000)
Issue-ID: DCAEGEN2-1660
Change-Id: Ib742755f6a924ee9c5babe8e411311e7fe0e6802
Signed-off-by: TamasBakai <tamas.bakai@est.tech>
test/mocks/mass-pnf-sim/mass-pnf-sim.py
test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/vsftpd_ssl-TEMPLATE.conf [moved from test/mocks/mass-pnf-sim/pnf-sim-lightweight/config/vsftpd_ssl.conf with 90% similarity]
test/mocks/mass-pnf-sim/pnf-sim-lightweight/docker-compose-template.yml
test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh

index a02e3fd..c3a17b0 100755 (executable)
@@ -76,6 +76,11 @@ if args.bootstrap and args.ipstart and args.urlves:
     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 @@ if args.bootstrap and args.ipstart and args.urlves:
             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 @@ if args.bootstrap and args.ipstart and args.urlves:
             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)
@@ -34,8 +34,8 @@ hide_ids=YES
 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 @@ require_cert=YES
 ssl_request_cert=YES
 ca_certs_file=/etc/ssl/private/dfc.crt
 
+write_enable=YES
+pasv_address=${IPFILESERVER}
index 2c9226a..d2c5290 100644 (file)
@@ -45,13 +45,14 @@ services:
       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
index f4435aa..3de96da 100755 (executable)
@@ -20,8 +20,8 @@ function main(){
 
     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 get_pnfsim_ip() {
 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 @@ function compose(){
        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 @@ function compose(){
 
        ./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(){