X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FPOL.git;a=blobdiff_plain;f=osm_policy_module%2Fcore%2Fagent.py;h=777723bfd25f57c6a5ad7d2d99f6e9fc2fb798b9;hp=a73cd5b6a560a47650c4255701050b029b4d050b;hb=cb5642a2af495af4319beb1dba2d417b78f3200a;hpb=1d7fa33ffdd43fe36f8a83088b5b51bc0d875925 diff --git a/osm_policy_module/core/agent.py b/osm_policy_module/core/agent.py index a73cd5b..777723b 100644 --- a/osm_policy_module/core/agent.py +++ b/osm_policy_module/core/agent.py @@ -36,7 +36,7 @@ from osm_policy_module.core.config import Config log = logging.getLogger(__name__) -ALLOWED_KAFKA_KEYS = ["instantiated", "scaled", "terminated", "notify_alarm", "vnf_terminated"] +ALLOWED_KAFKA_KEYS = ["instantiated", "scaled", "terminated", "notify_alarm", "policy_updated", "vnf_terminated"] class PolicyModuleAgent: @@ -79,6 +79,9 @@ class PolicyModuleAgent: if key == "notify_alarm": await self._handle_alarm_notification(msg) + if key == "policy_updated": + await self._handle_policy_update(msg) + if key == "vnf_terminated": await self._handle_vnf_terminated(msg) else: @@ -155,6 +158,27 @@ class PolicyModuleAgent: content["operationState"], ) + async def _handle_policy_update(self, content): + log.info("_handle_policy_update: %s", content) + nsr_id = content['nsr_id'] + vnf_member_index = content['vnf_member_index'] + if ( + content["operationState"] == "COMPLETED" + or content["operationState"] == "PARTIALLY_COMPLETED" + ): + log.info( + "Updating policies of VNF with nsr_id: %s and vnf-member-index: %s" + % (nsr_id, vnf_member_index)) + await self.autoscaling_service.delete_scaling_groups(nsr_id, vnf_member_index) + await self.alarming_service.delete_vnf_alarms(nsr_id, vnf_member_index) + await self.autoscaling_service.configure_scaling_groups(nsr_id, vnf_member_index) + await self.alarming_service.configure_vnf_alarms(nsr_id, vnf_member_index) + else: + log.info( + "Network service is not in COMPLETED or PARTIALLY_COMPLETED state. " + "Current state is %s. Skipping...", + content['operationState']) + async def _handle_vnf_terminated(self, content): nsr_id = content['nsr_id'] vnf_member_index = content['vnf_member_index']