aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/mass-pnf-sim
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-06-01 12:31:42 +0200
committerMorgan Richomme <morgan.richomme@orange.com>2020-06-02 15:13:29 +0000
commit110badf8a806ced0368d970fd96def9d790fb949 (patch)
tree881189ec4bba4ff7ea2e017133456d30c8eed335 /test/mocks/mass-pnf-sim
parent07b7d00688282affba8df8014924519421374517 (diff)
Add helper method to get running docker containers names list
Change-Id: I8346302706d6e896b55d845051fe2de18aaafd16 Issue-ID: INT-1606 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test/mocks/mass-pnf-sim')
-rwxr-xr-xtest/mocks/mass-pnf-sim/MassPnfSim.py9
-rwxr-xr-xtest/mocks/mass-pnf-sim/setup.py3
2 files changed, 11 insertions, 1 deletions
diff --git a/test/mocks/mass-pnf-sim/MassPnfSim.py b/test/mocks/mass-pnf-sim/MassPnfSim.py
index b69e0fcac..f932c8286 100755
--- a/test/mocks/mass-pnf-sim/MassPnfSim.py
+++ b/test/mocks/mass-pnf-sim/MassPnfSim.py
@@ -9,6 +9,7 @@ from shutil import copytree, rmtree
from json import dumps
from yaml import load, SafeLoader
from glob import glob
+from docker import from_env
from requests import get
from requests.exceptions import MissingSchema, InvalidSchema, InvalidURL, ConnectionError, ConnectTimeout
@@ -161,6 +162,14 @@ class MassPnfSim:
chdir(oldpwd)
return yml['ippnfsim']
+ def _get_docker_containers(self):
+ '''Returns a list containing 'name' attribute of running docker containers'''
+ dc = from_env()
+ containers = []
+ for container in dc.containers.list():
+ containers.append(container.attrs['Name'][1:])
+ return containers
+
def bootstrap(self):
self.logger.info("Bootstrapping PNF instances")
diff --git a/test/mocks/mass-pnf-sim/setup.py b/test/mocks/mass-pnf-sim/setup.py
index 1d3dd7293..99d722ca5 100755
--- a/test/mocks/mass-pnf-sim/setup.py
+++ b/test/mocks/mass-pnf-sim/setup.py
@@ -32,6 +32,7 @@ setuptools.setup(
'argparse',
'ipaddress',
'requests',
- 'pyyaml'
+ 'pyyaml',
+ 'docker'
]
)