OSMENG-987: Implement PrepareVnfWorkflow
Change-Id: Icf3ccfd44160fbc3f2f2d9ec64e360c07fc9bbfa
Signed-off-by: Dario Faccin <dario.faccin@canonical.com>
diff --git a/osm_lcm/temporal/ns_activities.py b/osm_lcm/temporal/ns_activities.py
index 6834eec..eee4325 100644
--- a/osm_lcm/temporal/ns_activities.py
+++ b/osm_lcm/temporal/ns_activities.py
@@ -21,7 +21,6 @@
ACTIVITY_CHECK_NS_INSTANTIATION_FINISHED,
ACTIVITY_DEPLOY_NS,
ACTIVITY_GET_MODEL_INFO,
- ACTIVITY_PREPARE_VNF_RECORDS,
ACTIVITY_UPDATE_NS_STATE,
)
from osm_common.dataclasses.temporal_dataclasses import (
@@ -84,30 +83,6 @@
self.db = db
self.logger = logging.getLogger(f"lcm.act.{self.__class__.__name__}")
- @activity.defn(name=ACTIVITY_PREPARE_VNF_RECORDS)
- async def prepare_vnf_records(
- self, ns_instantiate_input: NsInstantiateInput
- ) -> None:
- """Prepare VNFs to be deployed: Add namespace to the VNFr.
-
- Collaborators:
- DB Write: vnfrs
-
- 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
-
- """
- vnfrs = self.db.get_list("vnfrs", {"nsr-id-ref": ns_instantiate_input.ns_uuid})
- for vnfr in vnfrs:
- self._prepare_vnf_record(vnfr)
-
@activity.defn(name=ACTIVITY_GET_MODEL_INFO)
async def get_model_info(
self, ns_instantiate_input: NsInstantiateInput
@@ -134,18 +109,11 @@
model_name = self._get_namespace(ns_uuid, vim_uuid)
return ModelInfo(vim_uuid, model_name)
- def _get_namespace(self, ns_id: str, vim_id: str) -> str:
+ @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:]
- def _prepare_vnf_record(self, vnfr: dict) -> None:
- """Add namespace to the VNFr."""
- ns_id = vnfr["nsr-id-ref"]
- vim_id = vnfr["vim-account-id"]
- namespace = self._get_namespace(ns_id, vim_id)
- update_namespace = {"namespace": namespace}
- self.db.set_one("vnfrs", {"_id": vnfr["_id"]}, update_namespace)
-
@activity.defn(name=ACTIVITY_UPDATE_NS_STATE)
async def update_ns_state(self, data: UpdateNsStateInput) -> None:
"""