From c65901cf09cd9db9d52369247e9041fda0ee55b7 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 21 Aug 2019 04:03:42 +0200 Subject: [PATCH] fill_config.py: sort foreach items numerically, not alphabetically Make sure that BTS 11 doesn't get sorted between BTS 1 and 2, because osmo-bsc requires the BTS to be configured in numerical order. Also makes sense as foreach loop ordering in general. Change-Id: Ib06052fd71def3d4c869ee9b3dc4d02ba06267af --- net/fill_config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/fill_config.py b/net/fill_config.py index d99d9f6..557381f 100755 --- a/net/fill_config.py +++ b/net/fill_config.py @@ -166,19 +166,19 @@ def insert_foreach(tmpl, tmpl_dir, tmpl_src, match, local_config, arg): item_m = item_re.match(item) if not item_m: continue - items.add((item_m.group(1), item_m.group(2))) + items.add((int(item_m.group(2)), item_m.group(1))) items = sorted(list(items)) expanded = [before_block] - for item, nr in items: + for nr, item in items: expanded_block = foreach_block while True: expanded_block_was = expanded_block expanded_block = expanded_block.replace('${%sn_' % arg, '${%s_' % item) - expanded_block = expanded_block.replace('${%sn}' % arg, nr) + expanded_block = expanded_block.replace('${%sn}' % arg, str(nr)) expanded_block = replace_vars(expanded_block, tmpl_dir, tmpl_src, local_config) if expanded_block_was == expanded_block: