From: Alexis Romero Date: Fri, 11 Mar 2022 14:29:18 +0000 (+0100) Subject: Feature 10906: Support for Anti-Affinity groups X-Git-Tag: v12.0.0rc1~26 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=305b5c4df29e2fe284957ae5f160896b35d34bc9;p=osm%2FLCM.git Feature 10906: Support for Anti-Affinity groups Change-Id: Ibea6072b6907815d8be80ccb532e17221503f71a Signed-off-by: Alexis Romero --- diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 33e5aa1..9800f9e 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -867,6 +867,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: @@ -1159,6 +1163,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: diff --git a/osm_lcm/tests/test_db_descriptors.py b/osm_lcm/tests/test_db_descriptors.py index cc4f828..34491a7 100644 --- a/osm_lcm/tests/test_db_descriptors.py +++ b/osm_lcm/tests/test_db_descriptors.py @@ -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