From 97e9e355bf4dfffa6abbbfad69626ef662ae8ef2 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 12 Sep 2017 15:02:25 +0200 Subject: config: replicate_times: insert replicates in place In the following suite.conf, position matters when matching against scenarios: [suite.conf] resources: bts: - type: sysmo times: 2 - type: osmo-bts-trx times: 1 [scenario] resources: bts: - - ip_addr: 1.2.3.4 In this case, for instance, we make it clear that we want the second sysmo bts which has IP 1.2.3.4. With old behaviour, the replicated sysmo would have been created at the end (3rd position), and the ip_addr would match against the osmo-bts-trx BTS. Change-Id: Id78e2326db964d5efb6648854b57d8addce4deb0 --- src/osmo_gsm_tester/config.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/osmo_gsm_tester') diff --git a/src/osmo_gsm_tester/config.py b/src/osmo_gsm_tester/config.py index a0fe969..4e7f504 100644 --- a/src/osmo_gsm_tester/config.py +++ b/src/osmo_gsm_tester/config.py @@ -277,13 +277,13 @@ def replicate_times(d): 'replicate items that have a "times" > 1' d = copy.deepcopy(d) for key, item_list in d.items(): - more_items = [] - for item in item_list: - times = int(item.pop('times')) - if times and times > 1: - for i in range(times - 1): - more_items.append(copy.deepcopy(item)) - item_list.extend(more_items) + idx = 0 + while idx < len(item_list): + item = item_list[idx] + times = int(item.pop('times', 1)) + for j in range(1, times): + item_list.insert(idx + j, copy.deepcopy(item)) + idx += times return d # vim: expandtab tabstop=4 shiftwidth=4 -- cgit v1.2.3