From: aticig Date: Mon, 11 Jul 2022 19:28:06 +0000 (+0300) Subject: Fix Bug 1607 Interface position is not taken into account and X-Git-Tag: v10.1.2~1 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FRO.git;a=commitdiff_plain;h=25d668fbf53c69e3d88cddf04fb0ab2554c52e7d Fix Bug 1607 Interface position is not taken into account and remove vim_gcp from stage-build.sh This fix provides to attach interfaces to VNF according to the position order which is defined in the VNFD. Change-Id: Id0345dc66c3bba8acb0c4c62d9ec21b875c4af72 Signed-off-by: aticig --- diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index 18503531..5e5cd9cc 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -812,6 +812,45 @@ class Ns(object): extra_dict = {"depends_on": [image_text, flavor_text]} net_list = [] + # If the position info is provided for all the interfaces, it will be sorted + # according to position number ascendingly. + 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")), + ) + target_vdu["interfaces"] = sorted_interfaces + + # 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") + 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 + while k < n: + if target_vdu["interfaces"][k].get("position"): + idx = target_vdu["interfaces"][k]["position"] + sorted_interfaces[idx - 1] = target_vdu["interfaces"][k] + k += 1 + while m < n: + if not target_vdu["interfaces"][m].get("position"): + idy = sorted_interfaces.index(-1) + sorted_interfaces[idy] = target_vdu["interfaces"][m] + m += 1 + + target_vdu["interfaces"] = sorted_interfaces + + # If the position info is not provided for the interfaces, interfaces will be attached + # according to the order in the VNFD. for iface_index, interface in enumerate(target_vdu["interfaces"]): if interface.get("ns-vld-id"): net_text = ns_preffix + ":vld." + interface["ns-vld-id"] diff --git a/devops-stages/stage-build.sh b/devops-stages/stage-build.sh index 5bc8cd51..00b5ae90 100755 --- a/devops-stages/stage-build.sh +++ b/devops-stages/stage-build.sh @@ -33,8 +33,7 @@ dist_ro_vim_aws dist_ro_vim_azure dist_ro_vim_openstack dist_ro_vim_openvim -dist_ro_vim_vmware -dist_ro_vim_gcp" +dist_ro_vim_vmware" TOX_ENV_LIST="$(echo $PACKAGES | sed "s/ /,/g")" PROCESSES=$(expr `nproc --a` / 2) diff --git a/releasenotes/notes/fixing_bug_1607-46eb0662b87778b6.yaml b/releasenotes/notes/fixing_bug_1607-46eb0662b87778b6.yaml new file mode 100644 index 00000000..d6139b54 --- /dev/null +++ b/releasenotes/notes/fixing_bug_1607-46eb0662b87778b6.yaml @@ -0,0 +1,22 @@ +####################################################################################### +# 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: + - | + Fix Bug 1607 Interface position is not taken into account + This fix provides to attach interfaces to VNF according to the position order + which is defined in the VNFD.