aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/mass-pnf-sim
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocks/mass-pnf-sim')
-rwxr-xr-xtest/mocks/mass-pnf-sim/MassPnfSim.py25
-rwxr-xr-xtest/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh6
-rw-r--r--test/mocks/mass-pnf-sim/requirements.txt1
3 files changed, 13 insertions, 19 deletions
diff --git a/test/mocks/mass-pnf-sim/MassPnfSim.py b/test/mocks/mass-pnf-sim/MassPnfSim.py
index f782b22fb..980be1535 100755
--- a/test/mocks/mass-pnf-sim/MassPnfSim.py
+++ b/test/mocks/mass-pnf-sim/MassPnfSim.py
@@ -6,6 +6,7 @@ import argparse
import ipaddress
from sys import exit
from os import chdir, getcwd
+from shutil import copytree
from json import dumps
from requests import get
from requests.exceptions import MissingSchema, InvalidSchema, InvalidURL, ConnectionError, ConnectTimeout
@@ -130,14 +131,12 @@ class MassPnfSim():
PortFtps = start_port + 2
start_port += 2
- foldername = f"pnf-sim-lw-{i}"
- completed = subprocess.run('mkdir ' + foldername, shell=True)
- self.logger.info(f'\tCreating folder: {completed.stdout}')
- completed = subprocess.run(
- 'cp -r pnf-sim-lightweight/* ' +
- foldername,
- shell=True)
- self.logger.info(f'\tCloning folder: {completed.stdout}')
+ self.logger.info(f'\tCreating {self.sim_dirname_pattern}{i}')
+ try:
+ copytree('pnf-sim-lightweight', f'{self.sim_dirname_pattern}{i}')
+ except FileExistsError:
+ self.logger.error(f'Directory {self.sim_dirname_pattern}{i} already exists, cannot overwrite.')
+ exit(1)
composercmd = " ".join([
"./simulator.sh compose",
@@ -156,14 +155,8 @@ class MassPnfSim():
str(ftps_pasv_port_end)
])
self.logger.debug(f"Script cmdline: {composercmd}")
-
- completed = subprocess.run(
- 'set -x; cd ' +
- foldername +
- '; ' +
- composercmd,
- shell=True)
- self.logger.info(f'Cloning: {completed.stdout}')
+ self.logger.info(f"\tCreating instance #{i} configuration ")
+ self._run_cmd(composercmd, f"{self.sim_dirname_pattern}{i}")
ftps_pasv_port_start += ftps_pasv_port_num_of_ports + 1
ftps_pasv_port_end += ftps_pasv_port_num_of_ports + 1
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 3b229e167..50ef3214d 100755
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
@@ -91,9 +91,9 @@ function compose(){
write_config $URLVES $IPFILESERVER $TYPEFILESERVER $PORTSFTP $PORTFTPS $IPPNFSIM
- cd config
- envsubst < vsftpd_ssl-TEMPLATE.conf > vsftpd_ssl.conf
- cd -
+ pushd config
+ envsubst < vsftpd_ssl-TEMPLATE.conf > vsftpd_ssl.conf
+ popd
}
function build_image(){
diff --git a/test/mocks/mass-pnf-sim/requirements.txt b/test/mocks/mass-pnf-sim/requirements.txt
index 60316e13f..27dd31c35 100644
--- a/test/mocks/mass-pnf-sim/requirements.txt
+++ b/test/mocks/mass-pnf-sim/requirements.txt
@@ -2,3 +2,4 @@ argparse
ipaddress
requests
json
+shutil