VimUpdateWorkflowImpl,
)
from osm_lcm.temporal.vnf_activities import (
+ DeleteVnfRecordImpl,
GetTaskQueueImpl,
GetVnfDescriptorImpl,
GetVnfRecordImpl,
DeleteVimRecordImpl(self.db),
ChangeVnfStateImpl(self.db),
ChangeVnfInstantiationStateImpl(self.db),
+ DeleteVnfRecordImpl(self.db),
GetTaskQueueImpl(self.db),
GetVimCloudImpl(self.db),
GetVnfDescriptorImpl(self.db),
from typing import List, Any
from osm_common.temporal.activities.vnf import (
+ DeleteVnfRecord,
GetTaskQueue,
GetVimCloud,
GetVnfDescriptor,
self.logger.debug("Send notification for VNF not implemented.")
+@activity.defn(name=DeleteVnfRecord.__name__)
+class DeleteVnfRecordImpl(DeleteVnfRecord):
+ async def __call__(self, activity_input: DeleteVnfRecord.Input) -> None:
+ self.db.del_one("vnfrs", {"_id": activity_input.vnfr_uuid}, fail_on_empty=False)
+ self.logger.debug(f"VNF {activity_input.vnfr_uuid} record deleted from DB.")
+
+
@activity.defn(name=GetModelNames.__name__)
class GetModelNamesImpl(GetModelNames):
async def __call__(
from osm_common.dbbase import DbException
from osm_common.temporal_task_queues.task_queues_mappings import LCM_TASK_QUEUE
from osm_lcm.temporal.vnf_activities import (
+ DeleteVnfRecordImpl,
ChangeVnfInstantiationStateImpl,
ChangeVnfStateImpl,
GetModelNamesImpl,
)
+class TestDeleteVnfRecord(asynctest.TestCase):
+ async def setUp(self):
+ self.db = Mock()
+ self.delete_vnf_record = DeleteVnfRecordImpl(self.db)
+ self.env = ActivityEnvironment()
+
+ async def test_activity__succeeded__expected_record_is_deleted(self):
+ self.db.del_one.return_value = None
+ await self.env.run(
+ self.delete_vnf_record,
+ DeleteVnfRecordImpl.Input(vnfr_uuid=vnfr_uuid),
+ )
+ self.db.del_one.assert_called_with(
+ "vnfrs", {"_id": vnfr_uuid}, fail_on_empty=False
+ )
+
+ async def test_activity__failed__raise_db_exception(self):
+ self.db.del_one.side_effect = DbException("Can not connect to Database.")
+ with self.assertRaises(DbException):
+ await self.env.run(
+ self.delete_vnf_record,
+ DeleteVnfRecordImpl.Input(vnfr_uuid=vnfr_uuid),
+ )
+
+
class TestGetVimCloud(asynctest.TestCase):
async def setUp(self):
self.db = Mock()