From: aticig Date: Fri, 24 Jun 2022 13:01:05 +0000 (+0300) Subject: Match the correct clause when interface position is zero X-Git-Tag: v12.0.0rc1~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F42%2F12242%2F2;p=osm%2FRO.git Match the correct clause when interface position is zero Change-Id: I6eacc818c1596442295d39ff704fe56dea319c11 Signed-off-by: aticig --- diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index 096d4dfd..a7c15628 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -1087,7 +1087,11 @@ class Ns(object): # If the position info is provided for all the interfaces, it will be sorted # according to position number ascendingly. - if all(i.get("position") for i in target_vdu["interfaces"]): + if all( + i.get("position") + 1 + for i in target_vdu["interfaces"] + if i.get("position") is not None + ): sorted_interfaces = sorted( target_vdu["interfaces"], key=lambda x: (x.get("position") is None, x.get("position")), @@ -1097,7 +1101,11 @@ class Ns(object): # If the position info is provided for some interfaces but not all of them, the interfaces # which has specific position numbers will be placed and others' positions will not be taken care. else: - if any(i.get("position") for i in target_vdu["interfaces"]): + if any( + i.get("position") + 1 + for i in target_vdu["interfaces"] + if i.get("position") is not None + ): n = len(target_vdu["interfaces"]) sorted_interfaces = [-1] * n k, m = 0, 0 diff --git a/releasenotes/notes/Fix_for_interface_position_zero-2fd0b47297c46dbb.yaml b/releasenotes/notes/Fix_for_interface_position_zero-2fd0b47297c46dbb.yaml new file mode 100644 index 00000000..de16ebcc --- /dev/null +++ b/releasenotes/notes/Fix_for_interface_position_zero-2fd0b47297c46dbb.yaml @@ -0,0 +1,21 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +fixes: + - | + This patch will provide the match the correct if/else clause when the interface + position 0.