OSMENG-1048 Implement day1 configuration for VDU
Day1 config implementation, arranging existing unit tests and imports
adding task and execution timeout policy for workflows in tests.
Change-Id: Ie5a2626eec01176723d8130576facbf4934d5285
Signed-off-by: Gulsum Atici <gulsum.atici@canonical.com>
diff --git a/osm_lcm/temporal/ns_activities.py b/osm_lcm/temporal/ns_activities.py
index b937717..8c7c182 100644
--- a/osm_lcm/temporal/ns_activities.py
+++ b/osm_lcm/temporal/ns_activities.py
@@ -18,17 +18,19 @@
from time import time
from osm_common.dataclasses.temporal_dataclasses import (
- GetVnfRecordIdsInput,
- GetVnfRecordIdsOutput,
+ GetNsRecordInput,
+ GetNsRecordOutput,
+ GetVnfDetailsInput,
+ GetVnfDetailsOutput,
UpdateNsStateInput,
)
from osm_common.temporal_constants import (
- ACTIVITY_GET_VNF_RECORD_IDS,
+ ACTIVITY_GET_NS_RECORD,
+ ACTIVITY_GET_VNF_DETAILS,
ACTIVITY_UPDATE_NS_STATE,
)
-from temporalio import activity
-
from osm_lcm.data_utils.database.database import Database
+from temporalio import activity
class NsOperations:
@@ -36,12 +38,12 @@
self.db: Database = db
self.logger = logging.getLogger(f"lcm.act.{self.__class__.__name__}")
- @activity.defn(name=ACTIVITY_GET_VNF_RECORD_IDS)
- async def get_vnf_record_ids(
- self, get_vnf_record_ids_input: GetVnfRecordIdsInput
- ) -> GetVnfRecordIdsOutput:
+ @activity.defn(name=ACTIVITY_GET_VNF_DETAILS)
+ async def get_vnf_details(
+ self, get_vnf_details_input: GetVnfDetailsInput
+ ) -> GetVnfDetailsOutput:
"""
- Gets the list of VNF record IDs for a given NS record ID.
+ Gets the list of VNF record IDs, VNF member-index-refs for a given NS record ID.
Collaborators:
DB Read: vnfrs
@@ -55,10 +57,36 @@
Since this activity only reads from the DB, it is safe to retry, although
you may wish to have some back-off policy.
"""
- vnfrs = self.db.get_list(
- "vnfrs", {"nsr-id-ref": get_vnf_record_ids_input.ns_uuid}
+ vnfrs = self.db.get_list("vnfrs", {"nsr-id-ref": get_vnf_details_input.ns_uuid})
+ return GetVnfDetailsOutput(
+ vnf_details=[(vnfr["id"], vnfr["member-vnf-index-ref"]) for vnfr in vnfrs]
)
- return GetVnfRecordIdsOutput(vnfr_ids=[vnfr["id"] for vnfr in vnfrs])
+
+ @activity.defn(name=ACTIVITY_GET_NS_RECORD)
+ async def get_ns_record(
+ self, get_ns_record_input: GetNsRecordInput
+ ) -> GetNsRecordOutput:
+ """Gets the NS record from Database.
+
+ Collaborators:
+ DB Read: nsrs
+
+ Raises (retryable):
+ DbException: If DB read operations fail, the collection or DB record ID does not exist.
+
+ Activity Lifecycle:
+ This activity should complete relatively quickly (less than 10
+ second).
+
+ This activity will not report a heartbeat due to its
+ short-running nature.
+
+ This is an idempotent activity.
+
+ """
+ nsr = self.db.get_one("nsrs", {"_id": get_ns_record_input.nsr_uuid})
+ self.logger.debug("Got the nsr from Database for VNF operations.")
+ return GetNsRecordOutput(nsr=nsr)
class NsDbActivity: