JSON: ensure that node constraints use correct indexing

The program currently ignores the explicit `index` and reads the
constraints in the JSON order of the list. However in general, it is not
guaranteed that constraints are listed in order.

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
Change-Id: Icefe271f5801cf9f7b43311c6666556564587c65
Signed-off-by: Jan Kundrát <jan.kundrat@telecominfraproject.com>
This commit is contained in:
EstherLerouzic
2022-02-14 15:19:34 +01:00
committed by Jan Kundrát
parent e381138320
commit 1bcb3ce25c
2 changed files with 69 additions and 1 deletions

View File

@@ -547,7 +547,7 @@ def requests_from_json(json_data, equipment):
params['format'] = params['trx_mode']
params['spacing'] = req['path-constraints']['te-bandwidth']['spacing']
try:
nd_list = req['explicit-route-objects']['route-object-include-exclude']
nd_list = sorted(req['explicit-route-objects']['route-object-include-exclude'], key=lambda x: x['index'])
except KeyError:
nd_list = []
params['nodes_list'] = [n['num-unnum-hop']['node-id'] for n in nd_list]