X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_policy_module%2Fcore%2Fagent.py;h=2daebdeab0880d3340dd6cfdb56a3789cf35b6d4;hb=9ed429081842d22521c7be333e2ab25712316aab;hp=9867c0ccf147edb472e3f72a9c4caa5043bf56a9;hpb=1a553c6fc58c5e0a0c888c9c6362be1189163640;p=osm%2FPOL.git diff --git a/osm_policy_module/core/agent.py b/osm_policy_module/core/agent.py index 9867c0c..2daebde 100644 --- a/osm_policy_module/core/agent.py +++ b/osm_policy_module/core/agent.py @@ -37,7 +37,14 @@ from osm_policy_module.core.config import Config log = logging.getLogger(__name__) -ALLOWED_KAFKA_KEYS = ["instantiated", "scaled", "terminated", "notify_alarm", "policy_updated", "vnf_terminated"] +ALLOWED_KAFKA_KEYS = [ + "instantiated", + "scaled", + "terminated", + "notify_alarm", + "policy_updated", + "vnf_terminated", +] class PolicyModuleAgent: @@ -68,7 +75,6 @@ class PolicyModuleAgent: log.debug("_process_msg topic=%s key=%s msg=%s", topic, key, msg) try: if key in ALLOWED_KAFKA_KEYS: - if key == "instantiated": await self._handle_instantiated(msg) @@ -167,39 +173,49 @@ class PolicyModuleAgent: 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'] + 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) + % (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.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']) + content["operationState"], + ) async def _handle_vnf_terminated(self, content): - nsr_id = content['nsr_id'] - vnf_member_index = content['vnf_member_index'] + nsr_id = content["nsr_id"] + vnf_member_index = content["vnf_member_index"] if ( content["operationState"] == "COMPLETED" or content["operationState"] == "PARTIALLY_COMPLETED" ): log.info( "Deleting 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) + % (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) else: log.info( "Network service is not in COMPLETED or PARTIALLY_COMPLETED state. " "Current state is %s. Skipping...", - content['operationState']) + content["operationState"], + )