feat/fix(mgmt-cp): allows package creators to specify an external connection as ... 86/10386/3
authorbravof <fbravo@whitestack.com>
Wed, 24 Feb 2021 20:22:24 +0000 (17:22 -0300)
committerbravof <fbravo@whitestack.com>
Thu, 25 Feb 2021 17:45:58 +0000 (14:45 -0300)
Change-Id: I73cf116609e9e5e569db49d7469cbc9ebce50ab9
Signed-off-by: bravof <fbravo@whitestack.com>
osm_nbi/instance_topics.py
osm_nbi/utils.py

index cabfc1c..5088b24 100644 (file)
@@ -547,6 +547,21 @@ class NsrTopic(BaseTopic):
         vnfd_mgmt_cp = vnfd.get("mgmt-cp")
 
         for vdu in vnfd.get("vdu", ()):
+            vdu_mgmt_cp = []
+            try:
+                configs = vnfd.get("df")[0]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"]
+                vdu_config = utils.find_in_list(configs, lambda config: config["id"] == vdu["id"])
+            except Exception:
+                vdu_config = None
+            
+            if vdu_config:
+                external_connection_ee = utils.filter_in_list(
+                    vdu_config.get("execution-environment-list", []),
+                    lambda ee: "external-connection-point-ref" in ee
+                )
+                for ee in external_connection_ee:
+                    vdu_mgmt_cp.append(ee["external-connection-point-ref"])
+
             additional_params, vdu_params = self._format_additional_params(
                 ns_request, vnf_index, vdu_id=vdu["id"], descriptor=vnfd)
             vdur = {
@@ -598,7 +613,11 @@ class NsrTopic(BaseTopic):
 
                     if vnfd_mgmt_cp and vdu_iface.get("external-connection-point-ref") == vnfd_mgmt_cp:
                         vdu_iface["mgmt-vnf"] = True
-                        vdu_iface["mgmt-interface"] = True  # TODO change to mgmt-vdu
+                        vdu_iface["mgmt-interface"] = True
+
+                    for ecp in vdu_mgmt_cp:
+                        if vdu_iface.get("external-connection-point-ref") == ecp:
+                            vdu_iface["mgmt-interface"] = True
 
                     if iface.get("virtual-interface"):
                         vdu_iface.update(deepcopy(iface["virtual-interface"]))
index aac3d90..73fc40f 100644 (file)
@@ -31,6 +31,14 @@ def find_in_list(the_list, condition_lambda):
         return None
 
 
+def filter_in_list(the_list, condition_lambda):
+    ret = []
+    for item in the_list:
+        if condition_lambda(item):
+            ret.append(item)
+    return ret
+
+
 def find_index_in_list(the_list, condition_lambda):
     for index, item in enumerate(the_list):
         if condition_lambda(item):