OSM-989 Fetch vnfrs and vnfds using activity
Change-Id: Iabcf10a36b8690ab5952ae46891c8dcc218a2a86
Signed-off-by: Gulsum Atici <gulsum.atici@canonical.com>
diff --git a/osm_lcm/temporal/vnf_activities.py b/osm_lcm/temporal/vnf_activities.py
index 6e5abcb..16cc93c 100644
--- a/osm_lcm/temporal/vnf_activities.py
+++ b/osm_lcm/temporal/vnf_activities.py
@@ -19,16 +19,19 @@
from osm_common.temporal_constants import (
ACTIVITY_CHANGE_VNF_STATE,
ACTIVITY_CHANGE_VNF_INSTANTIATION_STATE,
- ACTIVITY_SEND_NOTIFICATION_FOR_VNF,
ACTIVITY_GET_TASK_QUEUE,
- VIM_TYPE_TASK_QUEUE_MAPPINGS,
+ ACTIVITY_GET_VNF_DETAILS,
+ ACTIVITY_SEND_NOTIFICATION_FOR_VNF,
ACTIVITY_SET_VNF_MODEL,
+ VIM_TYPE_TASK_QUEUE_MAPPINGS,
)
from osm_common.dataclasses.temporal_dataclasses import (
ChangeVnfInstantiationStateInput,
ChangeVnfStateInput,
GetTaskQueueInput,
GetTaskQueueOutput,
+ GetVnfDetailsInput,
+ GetVnfDetailsOutput,
VnfInstantiateInput,
)
@@ -48,7 +51,7 @@
DB Access Object
Raises (retryable):
- DbException: If DB read operations fail
+ 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 a
@@ -62,12 +65,39 @@
activity, the operation is idempotent.
"""
- vnfrs = self.db.get_list("vnfrs", {"_id": get_task_queue_input.vnfr_uuid})
- vim_record = self.db.get_list("vim_accounts", {"_id": vnfrs["vim-account-id"]})
+ vnfr = self.db.get_one("vnfrs", {"_id": get_task_queue_input.vnfr_uuid})
+ vim_record = self.db.get_one("vim_accounts", {"_id": vnfr["vim-account-id"]})
task_queue = VIM_TYPE_TASK_QUEUE_MAPPINGS[vim_record["vim-type"]]
self.logger.debug(f"Got the task queue {task_queue} for VNF operations.")
return GetTaskQueueOutput(task_queue)
+ @activity.defn(name=ACTIVITY_GET_VNF_DETAILS)
+ async def get_vnf_details(
+ self, get_vnf_details_input: GetVnfDetailsInput
+ ) -> GetVnfDetailsOutput:
+ """Gets the VNF record and VNF descriptor from Database.
+
+ Collaborators:
+ DB Access Object
+
+ 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.
+
+ """
+ vnfr = self.db.get_one("vnfrs", {"_id": get_vnf_details_input.vnfr_uuid})
+ vnfd = self.db.get_one("vnfds", {"_id": vnfr["vnfd-id"]})
+ self.logger.debug("Got the vnfr and vnfd from Database for VNF operations.")
+ return GetVnfDetailsOutput(vnfr=vnfr, vnfd=vnfd)
+
class VnfDbActivity:
@@ -119,7 +149,7 @@
DB Access Object
Raises (retryable):
- DbException: If DB access or update fails
+ DbException: If DB access or update fails, the collection or DB record ID does not exist.
Activity Lifecycle:
This activity should complete relatively quickly (less than a
@@ -134,7 +164,7 @@
"""
update_vnf_instantiation_state = {
- "vnfState": vnf_instantiation_state_input.state
+ "instantiationState": vnf_instantiation_state_input.state
}
self.db.set_one(
"vnfrs",