From 123de18fe672551ac782aec4188150d3fe76c961 Mon Sep 17 00:00:00 2001 From: Alexis Romero Date: Tue, 26 Apr 2022 19:24:40 +0200 Subject: [PATCH] Fixes bug 2013 : Passing Anti-affinity group as additionalParamsForVnf Change-Id: I4c14ef26cd78547cb74a19cdd50dbec9b40a0a93 Signed-off-by: Alexis Romero --- NG-RO/osm_ng_ro/ns.py | 5 ++++ NG-RO/osm_ng_ro/ns_thread.py | 21 +++++++++++++++- .../notes/fix_bug_2013-92b58291461ecde5.yaml | 24 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix_bug_2013-92b58291461ecde5.yaml 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. -- 2.17.1