From 61ed36660a4df5de9a22fa7b7d47fd7d4aab3b2c Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Tue, 2 Jun 2020 10:25:11 +0200 Subject: Add helper routine for getting iter range in lifecycle methods Change-Id: I3973b7bfd75885bf22154670a6b9f665769470fa Issue-ID: INT-1610 Signed-off-by: Bartek Grzybowski --- test/mocks/mass-pnf-sim/MassPnfSim.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/mocks/mass-pnf-sim/MassPnfSim.py b/test/mocks/mass-pnf-sim/MassPnfSim.py index d10686710..b6a32fe2f 100755 --- a/test/mocks/mass-pnf-sim/MassPnfSim.py +++ b/test/mocks/mass-pnf-sim/MassPnfSim.py @@ -174,6 +174,14 @@ class MassPnfSim: containers.append(container.attrs['Name'][1:]) return containers + def _get_iter_range(self): + '''Helper routine to get the iteration range + for the lifecycle commands''' + if not self.args.count: + return [self.existing_sim_instances] + else: + return [self.args.count] + def bootstrap(self): self.logger.info("Bootstrapping PNF instances") @@ -255,11 +263,7 @@ class MassPnfSim: pass def status(self): - if not self.args.count: - iter_range = [self.existing_sim_instances] - else: - iter_range = [self.args.count] - for i in range(*iter_range): + for i in range(*self._get_iter_range()): self.logger.info(f'Getting {self.sim_dirname_pattern}{i} instance status:') if f"{self.sim_container_name}-{i}" in self._get_docker_containers(): try: -- cgit 1.2.3-korg