aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-05-28 07:40:02 -0700
committerMorgan Richomme <morgan.richomme@orange.com>2020-06-02 15:13:29 +0000
commit07b7d00688282affba8df8014924519421374517 (patch)
tree7fa3659158b5b560dd2bd1ce249425b074882fbf /test
parentc27b77fcd8dff92d9b891c75bff3267931cec35a (diff)
Add helper method to get simulator instance data
Superfluous call to 'get_pnfsim_ip' function in simulator.sh was also removed. Change-Id: Ifd7be4843fe26768f4b86b64e07d2d9479735ad1 Issue-ID: INT-1606 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/mocks/mass-pnf-sim/MassPnfSim.py11
-rwxr-xr-xtest/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh1
-rwxr-xr-xtest/mocks/mass-pnf-sim/setup.py3
3 files changed, 13 insertions, 2 deletions
diff --git a/test/mocks/mass-pnf-sim/MassPnfSim.py b/test/mocks/mass-pnf-sim/MassPnfSim.py
index d15b69551..b69e0fcac 100755
--- a/test/mocks/mass-pnf-sim/MassPnfSim.py
+++ b/test/mocks/mass-pnf-sim/MassPnfSim.py
@@ -7,6 +7,7 @@ from sys import exit
from os import chdir, getcwd, path
from shutil import copytree, rmtree
from json import dumps
+from yaml import load, SafeLoader
from glob import glob
from requests import get
from requests.exceptions import MissingSchema, InvalidSchema, InvalidURL, ConnectionError, ConnectTimeout
@@ -104,6 +105,7 @@ class MassPnfSim:
return action_decorator
log_lvl = logging.INFO
+ sim_config = 'config/config.yml'
def __init__(self, args):
self.args = args
@@ -150,6 +152,15 @@ class MassPnfSim:
'''Helper method that returns bootstraped simulator instances count'''
return len(glob(f"{self.sim_dirname_pattern}[0-9]*"))
+ def _get_sim_instance_data(self, instance_id):
+ '''Helper method that returns specific instance data'''
+ oldpwd = getcwd()
+ chdir(f"{self.sim_dirname_pattern}{instance_id}")
+ with open(self.sim_config) as cfg:
+ yml = load(cfg, Loader=SafeLoader)
+ chdir(oldpwd)
+ return yml['ippnfsim']
+
def bootstrap(self):
self.logger.info("Bootstrapping PNF instances")
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 8c5390ed5..b957279af 100755
--- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
+++ b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/simulator.sh
@@ -187,7 +187,6 @@ EndOfMessage
}
function get_status(){
- get_pnfsim_ip
if [[ $(running_containers) ]]; then
print_status
else
diff --git a/test/mocks/mass-pnf-sim/setup.py b/test/mocks/mass-pnf-sim/setup.py
index 662976b03..1d3dd7293 100755
--- a/test/mocks/mass-pnf-sim/setup.py
+++ b/test/mocks/mass-pnf-sim/setup.py
@@ -31,6 +31,7 @@ setuptools.setup(
install_requires=[
'argparse',
'ipaddress',
- 'requests'
+ 'requests',
+ 'pyyaml'
]
)