Fixes bug 2013 : Passing Anti-affinity group as additionalParamsForVnf 42/11942/5
authorAlexis Romero <garomero@indra.es>
Tue, 26 Apr 2022 17:24:40 +0000 (19:24 +0200)
committerAlexis Romero <garomero@indra.es>
Wed, 27 Apr 2022 13:45:14 +0000 (15:45 +0200)
Change-Id: I4c14ef26cd78547cb74a19cdd50dbec9b40a0a93
Signed-off-by: Alexis Romero <garomero@indra.es>
NG-RO/osm_ng_ro/ns.py
NG-RO/osm_ng_ro/ns_thread.py
releasenotes/notes/fix_bug_2013-92b58291461ecde5.yaml [new file with mode: 0644]

index e7291ea..9642a8c 100644 (file)
@@ -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,
         }
index 5c3bb5d..ab58a1f 100644 (file)
@@ -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 (file)
index 0000000..5bc8759
--- /dev/null
@@ -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.