From 110badf8a806ced0368d970fd96def9d790fb949 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Mon, 1 Jun 2020 12:31:42 +0200 Subject: Add helper method to get running docker containers names list Change-Id: I8346302706d6e896b55d845051fe2de18aaafd16 Issue-ID: INT-1606 Signed-off-by: Bartek Grzybowski --- test/mocks/mass-pnf-sim/MassPnfSim.py | 9 +++++++++ test/mocks/mass-pnf-sim/setup.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) 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' ] ) -- cgit 1.2.3-korg