Bug 2038 fixed 81/12581/1 v12.0.4 v12.0.5 v12.0.6
authorPedro Escaleira <escaleira@av.it.pt>
Fri, 20 May 2022 14:29:20 +0000 (15:29 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 11 Oct 2022 15:59:15 +0000 (17:59 +0200)
The method _format_additional_params of the instance_topics.py was
changed in order to verify the target object (VNF|NS|VDU|KDU) where
we need to populate the params with the additional ones given by the
user

Change-Id: I599bb6320054e15917e11d81d6971b33f13f20fd
Signed-off-by: Pedro Escaleira <escaleira@av.it.pt>
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_nbi/instance_topics.py

index c60445f..b4c121e 100644 (file)
@@ -169,9 +169,14 @@ class NsrTopic(BaseTopic):
         ns_request, member_vnf_index=None, vdu_id=None, kdu_name=None, descriptor=None
     ):
         """
-        Get and format user additional params for NS or VNF
+        Get and format user additional params for NS or VNF.
+        The vdu_id and kdu_name params are mutually exclusive! If none of them are given, then the method will
+        exclusively search for the VNF/NS LCM additional params.
+
         :param ns_request: User instantiation additional parameters
         :param member_vnf_index: None for extract NS params, or member_vnf_index to extract VNF params
+        :vdu_id: VDU's ID against which we want to format the additional params
+        :kdu_name: KDU's name against which we want to format the additional params
         :param descriptor: If not None it check that needed parameters of descriptor are supplied
         :return: tuple with a formatted copy of additional params or None if not supplied, plus other parameters
         """
@@ -255,6 +260,9 @@ class NsrTopic(BaseTopic):
             if kdu_name:
                 additional_params = json.dumps(additional_params)
 
+        # Select the VDU ID, KDU name or NS/VNF ID, depending on the method's call intent
+        selector = vdu_id if vdu_id else kdu_name if kdu_name else descriptor.get("id")
+
         if descriptor:
             for df in descriptor.get("df", []):
                 # check that enough parameters are supplied for the initial-config-primitive
@@ -269,10 +277,13 @@ class NsrTopic(BaseTopic):
                         for config in df["lcm-operations-configuration"][
                             "operate-vnf-op-config"
                         ].get("day1-2", []):
-                            for primitive in get_iterable(
-                                config.get("initial-config-primitive")
-                            ):
-                                initial_primitives.append(primitive)
+                            # Verify the target object (VNF|NS|VDU|KDU) where we need to populate 
+                            # the params with the additional ones given by the user
+                            if config.get("id") == selector:
+                                for primitive in get_iterable(
+                                    config.get("initial-config-primitive")
+                                ):
+                                    initial_primitives.append(primitive)
                 else:
                     initial_primitives = deep_get(
                         descriptor, ("ns-configuration", "initial-config-primitive")