aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-06-09 12:41:08 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-06-10 06:39:05 +0000
commit700b607a52343f1b6c3d3987bddf8073bc382b40 (patch)
treeb4d55ccc39b32d4985b0480cb5cfc8053616fae2
parent0dc600f0d581c0d3f5abd0ac59f958faddfc2720 (diff)
Add helper method to generate simulator config
Change-Id: If0deb820f32d6d75c71370ff67c7c42a063d8e0a Issue-ID: INT-1618 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
-rwxr-xr-xtest/mocks/mass-pnf-sim/MassPnfSim.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/mocks/mass-pnf-sim/MassPnfSim.py b/test/mocks/mass-pnf-sim/MassPnfSim.py
index b2e7f819c..070451b27 100755
--- a/test/mocks/mass-pnf-sim/MassPnfSim.py
+++ b/test/mocks/mass-pnf-sim/MassPnfSim.py
@@ -7,7 +7,7 @@ from sys import exit
from os import chdir, getcwd, path, popen, kill, getuid, stat, mkdir
from shutil import copytree, rmtree, move
from json import loads, dumps
-from yaml import load, SafeLoader
+from yaml import load, SafeLoader, dump
from glob import glob
from time import strftime
from docker import from_env
@@ -191,6 +191,18 @@ class MassPnfSim:
except FileNotFoundError:
self.logger.error(f"Directory {sim_dir} not found")
+ def _generate_pnf_sim_config(self, i, port_sftp, port_ftps, pnf_sim_ip):
+ '''Writes a yaml formatted configuration file for Java simulator app'''
+ yml = {}
+ yml['urlves'] = self.args.urlves
+ yml['urlsftp'] = f'sftp://onap:pano@{self.args.ipfileserver}:{port_sftp}'
+ yml['urlftps'] = f'ftps://onap:pano@{self.args.ipfileserver}:{port_ftps}'
+ yml['ippnfsim'] = pnf_sim_ip
+ yml['typefileserver'] = self.args.typefileserver
+ self.logger.debug(f'Generated simulator config:\n{dump(yml)}')
+ with open(f'{self.sim_dirname_pattern}{i}/{self.sim_config}', 'w') as fout:
+ fout.write(dump(yml))
+
def bootstrap(self):
self.logger.info("Bootstrapping PNF instances")
@@ -247,6 +259,7 @@ class MassPnfSim:
])
self.logger.debug(f"Script cmdline: {composercmd}")
self.logger.info(f"\tCreating instance #{i} configuration ")
+ self._generate_pnf_sim_config(i, PortSftp, PortFtps, ip['PnfSim'])
self._run_cmd(composercmd, f"{self.sim_dirname_pattern}{i}")
ftps_pasv_port_start += ftps_pasv_port_num_of_ports + 1