-ALLOWED_KAFKA_KEYS = ['instantiated', 'scaled', 'terminated', 'notify_alarm']
+ALLOWED_KAFKA_KEYS = ["instantiated", "scaled", "terminated", "notify_alarm"]
await self.msg_bus.aioread(topics, self._process_msg)
log.critical("Exiting...")
await self.msg_bus.aioread(topics, self._process_msg)
log.critical("Exiting...")
async def _process_msg(self, topic, key, msg):
async def _process_msg(self, topic, key, msg):
log.debug("_process_msg topic=%s key=%s msg=%s", topic, key, msg)
try:
if key in ALLOWED_KAFKA_KEYS:
log.debug("_process_msg topic=%s key=%s msg=%s", topic, key, msg)
try:
if key in ALLOWED_KAFKA_KEYS:
await self._handle_alarm_notification(msg)
else:
log.debug("Key %s is not in ALLOWED_KAFKA_KEYS", key)
await self._handle_alarm_notification(msg)
else:
log.debug("Key %s is not in ALLOWED_KAFKA_KEYS", key)
async def _handle_alarm_notification(self, content):
log.debug("_handle_alarm_notification: %s", content)
async def _handle_alarm_notification(self, content):
log.debug("_handle_alarm_notification: %s", content)
- alarm_uuid = content['notify_details']['alarm_uuid']
- status = content['notify_details']['status']
+ alarm_uuid = content["notify_details"]["alarm_uuid"]
+ status = content["notify_details"]["status"]
await self.autoscaling_service.handle_alarm(alarm_uuid, status)
await self.alarming_service.handle_alarm(alarm_uuid, status, content)
async def _handle_instantiated(self, content):
log.debug("_handle_instantiated: %s", content)
await self.autoscaling_service.handle_alarm(alarm_uuid, status)
await self.alarming_service.handle_alarm(alarm_uuid, status, content)
async def _handle_instantiated(self, content):
log.debug("_handle_instantiated: %s", content)
- if nslcmop['operationState'] == 'COMPLETED' or nslcmop['operationState'] == 'PARTIALLY_COMPLETED':
- nsr_id = nslcmop['nsInstanceId']
+ if (
+ nslcmop["operationState"] == "COMPLETED"
+ or nslcmop["operationState"] == "PARTIALLY_COMPLETED"
+ ):
+ nsr_id = nslcmop["nsInstanceId"]
log.info("Configuring nsr_id: %s", nsr_id)
await self.autoscaling_service.configure_scaling_groups(nsr_id)
await self.alarming_service.configure_vnf_alarms(nsr_id)
log.info("Configuring nsr_id: %s", nsr_id)
await self.autoscaling_service.configure_scaling_groups(nsr_id)
await self.alarming_service.configure_vnf_alarms(nsr_id)
log.info(
"Network_service is not in COMPLETED or PARTIALLY_COMPLETED state. "
"Current state is %s. Skipping...",
log.info(
"Network_service is not in COMPLETED or PARTIALLY_COMPLETED state. "
"Current state is %s. Skipping...",
async def _handle_scaled(self, content):
log.debug("_handle_scaled: %s", content)
async def _handle_scaled(self, content):
log.debug("_handle_scaled: %s", content)
- if nslcmop['operationState'] == 'COMPLETED' or nslcmop['operationState'] == 'PARTIALLY_COMPLETED':
- nsr_id = nslcmop['nsInstanceId']
+ if (
+ nslcmop["operationState"] == "COMPLETED"
+ or nslcmop["operationState"] == "PARTIALLY_COMPLETED"
+ ):
+ nsr_id = nslcmop["nsInstanceId"]
log.info("Configuring scaled service with nsr_id: %s", nsr_id)
await self.autoscaling_service.configure_scaling_groups(nsr_id)
await self.autoscaling_service.delete_orphaned_alarms(nsr_id)
log.info("Configuring scaled service with nsr_id: %s", nsr_id)
await self.autoscaling_service.configure_scaling_groups(nsr_id)
await self.autoscaling_service.delete_orphaned_alarms(nsr_id)
log.debug(
"Network service is not in COMPLETED or PARTIALLY_COMPLETED state. "
"Current state is %s. Skipping...",
log.debug(
"Network service is not in COMPLETED or PARTIALLY_COMPLETED state. "
"Current state is %s. Skipping...",
async def _handle_terminated(self, content):
log.debug("_handle_deleted: %s", content)
async def _handle_terminated(self, content):
log.debug("_handle_deleted: %s", content)
- nsr_id = content['nsr_id']
- if content['operationState'] == 'COMPLETED' or content['operationState'] == 'PARTIALLY_COMPLETED':
- log.info("Deleting scaling groups and alarms for network autoscaling_service with nsr_id: %s", nsr_id)
+ nsr_id = content["nsr_id"]
+ if (
+ content["operationState"] == "COMPLETED"
+ or content["operationState"] == "PARTIALLY_COMPLETED"
+ ):
+ log.info(
+ "Deleting scaling groups and alarms for network autoscaling_service with nsr_id: %s",
+ nsr_id,
+ )
await self.autoscaling_service.delete_scaling_groups(nsr_id)
await self.alarming_service.delete_vnf_alarms(nsr_id)
else:
log.info(
"Network service is not in COMPLETED or PARTIALLY_COMPLETED state. "
"Current state is %s. Skipping...",
await self.autoscaling_service.delete_scaling_groups(nsr_id)
await self.alarming_service.delete_vnf_alarms(nsr_id)
else:
log.info(
"Network service is not in COMPLETED or PARTIALLY_COMPLETED state. "
"Current state is %s. Skipping...",