Call VNF workflows concurrently 60/13260/3
authorDaniel Arndt <daniel.arndt@canonical.com>
Fri, 21 Apr 2023 19:23:33 +0000 (16:23 -0300)
committerbeierlm <mark.beierl@canonical.com>
Tue, 25 Apr 2023 09:36:36 +0000 (11:36 +0200)
Change-Id: I798841c1368f45dc242f71fae52ef691c7e29c99
Signed-off-by: Daniel Arndt <daniel.arndt@canonical.com>
osm_lcm/temporal/ns_workflows.py

index f76e31f..9a4e0ee 100644 (file)
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import asyncio
+
 from osm_common.dataclasses.temporal_dataclasses import (
     GetVnfRecordIdsInput,
     GetVnfRecordIdsOutput,
@@ -72,13 +74,18 @@ class NsInstantiateWorkflow(LcmOperationWorkflow):
                     retry_policy=LcmOperationWorkflow.no_retry_policy,
                 ),
             )
-
-            for vnfr_uuid in vnf_record_ids_output.vnfr_ids:
-                await workflow.execute_child_workflow(
-                    workflow=WORKFLOW_VNF_INSTANTIATE,
-                    arg=VnfInstantiateInput(vnfr_uuid=vnfr_uuid, model_name=model_name),
-                    id=f"{WORKFLOW_VNF_INSTANTIATE}-{vnfr_uuid}",
+            await asyncio.gather(
+                *(
+                    workflow.execute_child_workflow(
+                        workflow=WORKFLOW_VNF_INSTANTIATE,
+                        arg=VnfInstantiateInput(
+                            vnfr_uuid=vnfr_uuid, model_name=model_name
+                        ),
+                        id=f"{WORKFLOW_VNF_INSTANTIATE}-{vnfr_uuid}",
+                    )
+                    for vnfr_uuid in vnf_record_ids_output.vnfr_ids
                 )
+            )
 
         except ActivityError as e:
             await self.update_ns_state(ns_uuid, NsState.INSTANTIATED, e.cause.message)