Feature 10906: Support for Anti-Affinity groups 87/11887/1
authorAlexis Romero <garomero@indra.es>
Fri, 11 Mar 2022 14:29:18 +0000 (15:29 +0100)
committerAlexis Romero <garomero@indra.es>
Wed, 13 Apr 2022 16:47:22 +0000 (18:47 +0200)
Change-Id: Ibea6072b6907815d8be80ccb532e17221503f71a
Signed-off-by: Alexis Romero <garomero@indra.es>
osm_lcm/ns.py
osm_lcm/tests/test_db_descriptors.py

index 7a23508..69f2d07 100644 (file)
@@ -865,6 +865,10 @@ class NsLcm(LcmBase):
             image["vim_info"] = {}
         for flavor in target["flavor"]:
             flavor["vim_info"] = {}
+        if db_nsr.get("affinity-or-anti-affinity-group"):
+            target["affinity-or-anti-affinity-group"] = deepcopy(db_nsr["affinity-or-anti-affinity-group"])
+            for affinity_or_anti_affinity_group in target["affinity-or-anti-affinity-group"]:
+                affinity_or_anti_affinity_group["vim_info"] = {}
 
         if db_nslcmop.get("lcmOperationType") != "instantiate":
             # get parameters of instantiation:
@@ -1151,6 +1155,13 @@ class NsLcm(LcmBase):
                 if target_vim not in ns_image["vim_info"]:
                     ns_image["vim_info"][target_vim] = {}
 
+                # Affinity groups
+                if vdur.get("affinity-or-anti-affinity-group-id"):
+                    for ags_id in vdur["affinity-or-anti-affinity-group-id"]:
+                        ns_ags = target["affinity-or-anti-affinity-group"][int(ags_id)]
+                        if target_vim not in ns_ags["vim_info"]:
+                            ns_ags["vim_info"][target_vim] = {}
+
                 vdur["vim_info"] = {target_vim: {}}
                 # instantiation parameters
                 # if vnf_params:
index cc4f828..34491a7 100644 (file)
@@ -867,6 +867,7 @@ db_nsrs_text = """
     short-name: ALF
     ssh-authorized-key: null
     flavor : [{"vcpu-count":1,"memory-mb":1024,"storage-gb":"10","vim_info":[],"name":"mgmtVM-flv","id":"0"}]
+    affinity-or-anti-affinity-group : []
     image : [ { "image" : "ubuntu16.04", "vim_info" : [ ], "id" : "0" } ]
     vld:
     -   id: mgmt
@@ -1775,6 +1776,7 @@ db_vnfrs_text = """
         vim-id: c2538499-4c30-41c0-acd5-80cb92f48061
         ns-image-id: 0
         ns-flavor-id: 0
+        affinity-or-anti-affinity-group-id : []
     -   _id: ab453219-2d9a-45c2-864d-2c0788385028
         count-index: 0
         interfaces:
@@ -1798,6 +1800,7 @@ db_vnfrs_text = """
         vim-id: 87973c3f-365d-4227-95c2-7a8abc74349c
         ns-image-id: 0
         ns-flavor-id: 0
+        affinity-or-anti-affinity-group-id : []
     vim-account-id: ea958ba5-4e58-4405-bf42-6e3be15d4c3a
     vld:
     -   id: internal
@@ -1856,6 +1859,7 @@ db_vnfrs_text = """
         vim-id: 248077b2-e3b8-4a37-8b72-575abb8ed912
         ns-image-id: 0
         ns-flavor-id: 0
+        affinity-or-anti-affinity-group-id : []
     -   _id: 889b874d-e1c3-4e75-aa45-53a9b0ddabd9
         count-index: 0
         interfaces:
@@ -1879,6 +1883,7 @@ db_vnfrs_text = """
         vim-id: a4ce4372-e0ad-4ae3-8f9f-1c969f32e77b
         ns-image-id: 0
         ns-flavor-id: 0
+        affinity-or-anti-affinity-group-id : []
     vim-account-id: ea958ba5-4e58-4405-bf42-6e3be15d4c3a
     vld:
     -   id: internal