From: Alexis Romero Date: Tue, 26 Apr 2022 17:24:40 +0000 (+0200) Subject: Fixes bug 2013 : Passing Anti-affinity group as additionalParamsForVnf X-Git-Tag: v12.0.0rc1~24 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F42%2F11942%2F5;p=osm%2FRO.git Fixes bug 2013 : Passing Anti-affinity group as additionalParamsForVnf Change-Id: I4c14ef26cd78547cb74a19cdd50dbec9b40a0a93 Signed-off-by: Alexis Romero --- diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index e7291ea7..9642a8c3 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -1159,6 +1159,11 @@ class Ns(object): "scope": target_affinity_group["scope"], } + if target_affinity_group.get("vim-affinity-group-id"): + affinity_group_data["vim-affinity-group-id"] = target_affinity_group[ + "vim-affinity-group-id" + ] + extra_dict["params"] = { "affinity_group_data": affinity_group_data, } diff --git a/NG-RO/osm_ng_ro/ns_thread.py b/NG-RO/osm_ng_ro/ns_thread.py index 5c3bb5d5..ab58a1f2 100644 --- a/NG-RO/osm_ng_ro/ns_thread.py +++ b/NG-RO/osm_ng_ro/ns_thread.py @@ -812,9 +812,28 @@ class VimInteractionAffinityGroup(VimInteractionBase): try: affinity_group_vim_id = None + affinity_group_data = None if task.get("params"): - affinity_group_data = task["params"]["affinity_group_data"] + affinity_group_data = task["params"].get("affinity_group_data") + + if affinity_group_data and affinity_group_data.get("vim-affinity-group-id"): + try: + param_affinity_group_id = task["params"]["affinity_group_data"].get( + "vim-affinity-group-id" + ) + affinity_group_vim_id = target_vim.get_affinity_group( + param_affinity_group_id + ).get("id") + except vimconn.VimConnNotFoundException: + self.logger.error( + "task={} {} new-affinity-or-anti-affinity-group. Provided VIM Affinity Group ID {}" + "could not be found at VIM. Creating a new one.".format( + task_id, ro_task["target_id"], param_affinity_group_id + ) + ) + + if not affinity_group_vim_id and affinity_group_data: affinity_group_vim_id = target_vim.new_affinity_group( affinity_group_data ) diff --git a/releasenotes/notes/fix_bug_2013-92b58291461ecde5.yaml b/releasenotes/notes/fix_bug_2013-92b58291461ecde5.yaml new file mode 100644 index 00000000..5bc8759b --- /dev/null +++ b/releasenotes/notes/fix_bug_2013-92b58291461ecde5.yaml @@ -0,0 +1,24 @@ +####################################################################################### +# 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 fixes the bug 2013 Anti-affinity group cannot be passed as instantiation + parameter. NBI and RO are affected. For RO, if the attribute vim-affinity-group-id + is present if the affinity group info, it is checked that it exists at the VIM + and then is used. If it does not exist, an error message is shown in the RO logs, + the atribute is ignored and a new new server group is created.