Implement instantiate NS workflow
Change-Id: I61defdc64865396cd6af4a20ffb67443450bd742
Signed-off-by: Daniel Arndt <daniel.arndt@canonical.com>
Signed-off-by: Mark Beierl <mark.beierl@canonical.com>
diff --git a/osm_lcm/temporal/ns_activities.py b/osm_lcm/temporal/ns_activities.py
index eee4325..3ea7dcf 100644
--- a/osm_lcm/temporal/ns_activities.py
+++ b/osm_lcm/temporal/ns_activities.py
@@ -16,20 +16,17 @@
import logging
from time import time
-from temporalio import activity
+
+from osm_common.dataclasses.temporal_dataclasses import (
+ GetVnfRecordIdsInput,
+ GetVnfRecordIdsOutput,
+ UpdateNsStateInput,
+)
from osm_common.temporal_constants import (
- ACTIVITY_CHECK_NS_INSTANTIATION_FINISHED,
- ACTIVITY_DEPLOY_NS,
- ACTIVITY_GET_MODEL_INFO,
+ ACTIVITY_GET_VNF_RECORD_IDS,
ACTIVITY_UPDATE_NS_STATE,
)
-from osm_common.dataclasses.temporal_dataclasses import (
- ModelInfo,
- NsInstantiateInput,
- UpdateNsStateInput,
- VduInstantiateInput,
-)
-from osm_lcm.temporal.juju_paas_activities import CharmInfoUtils
+from temporalio import activity
class NsOperations:
@@ -37,38 +34,12 @@
self.db = db
self.logger = logging.getLogger(f"lcm.act.{self.__class__.__name__}")
- # TODO: Change to a workflow OSM-990
- @activity.defn(name=ACTIVITY_DEPLOY_NS)
- async def deploy_ns(self, ns_instantiate_input: NsInstantiateInput) -> None:
- vnfrs = self.db.get_list("vnfrs", {"nsr-id-ref": ns_instantiate_input.ns_uuid})
- for vnfr in vnfrs:
- await self.deploy_vnf(vnfr)
-
- async def deploy_vnf(self, vnfr: dict):
- vim_id = vnfr.get("vim-account-id")
- model_name = "model-name"
- vnfd_id = vnfr["vnfd-id"]
- vnfd = self.db.get_one("vnfds", {"_id": vnfd_id})
- sw_image_descs = vnfd.get("sw-image-desc")
- for vdu in vnfd.get("vdu"):
- await self.deploy_vdu(vdu, sw_image_descs, vim_id, model_name)
-
- async def deploy_vdu(
- self, vdu: dict, sw_image_descs: str, vim_id: str, model_name: str
- ) -> None:
- vdu_info = CharmInfoUtils.get_charm_info(vdu, sw_image_descs)
- vdu_instantiate_input = VduInstantiateInput(vim_id, model_name, vdu_info)
- workflow_id = (
- vdu_instantiate_input.model_name + vdu_instantiate_input.charm_info.app_name
- )
- self.logger.info(f"TODO: Start VDU Workflow {workflow_id}")
-
- @activity.defn(name=ACTIVITY_CHECK_NS_INSTANTIATION_FINISHED)
- async def check_ns_instantiate_finished(
- self, ns_instantiate: NsInstantiateInput
- ) -> None:
- # TODO: Implement OSM-993
- pass
+ @activity.defn(name=ACTIVITY_GET_VNF_RECORD_IDS)
+ async def get_vnf_records(
+ self, get_vnf_records_input: GetVnfRecordIdsInput
+ ) -> GetVnfRecordIdsOutput:
+ # TODO: [OSMENG-1043] Implement Get VNF Records
+ return GetVnfRecordIdsOutput(vnfr_ids=[""])
class NsDbActivity:
@@ -83,37 +54,6 @@
self.db = db
self.logger = logging.getLogger(f"lcm.act.{self.__class__.__name__}")
- @activity.defn(name=ACTIVITY_GET_MODEL_INFO)
- async def get_model_info(
- self, ns_instantiate_input: NsInstantiateInput
- ) -> ModelInfo:
- """Returns a ModelInfo. Contains VIM ID and model name.
-
- Collaborators:
- DB Read: nsrs
-
- Raises (Retryable):
- DbException If the target DB record does not exist or DB is not reachable.
-
- Activity Lifecycle:
- This activity will not report a heartbeat due to its
- short-running nature.
-
- As this is a direct DB update, it is not recommended to have
- any specific retry policy
-
- """
- ns_uuid = ns_instantiate_input.ns_uuid
- nsr = self.db.get_one("nsrs", {"_id": ns_uuid})
- vim_uuid = nsr.get("datacenter")
- model_name = self._get_namespace(ns_uuid, vim_uuid)
- return ModelInfo(vim_uuid, model_name)
-
- @staticmethod
- def _get_namespace(ns_id: str, vim_id: str) -> str:
- """The NS namespace is the combination if the NS ID and the VIM ID."""
- return ns_id[-12:] + "-" + vim_id[-12:]
-
@activity.defn(name=ACTIVITY_UPDATE_NS_STATE)
async def update_ns_state(self, data: UpdateNsStateInput) -> None:
"""