From: Daniel Arndt Date: Fri, 21 Apr 2023 19:23:33 +0000 (-0300) Subject: Call VNF workflows concurrently X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F60%2F13260%2F3;p=osm%2FLCM.git Call VNF workflows concurrently Change-Id: I798841c1368f45dc242f71fae52ef691c7e29c99 Signed-off-by: Daniel Arndt --- diff --git a/osm_lcm/temporal/ns_workflows.py b/osm_lcm/temporal/ns_workflows.py index f76e31f0..9a4e0ee1 100644 --- a/osm_lcm/temporal/ns_workflows.py +++ b/osm_lcm/temporal/ns_workflows.py @@ -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)