Code Duplication    Length = 24-27 lines in 2 locations

main.py 2 locations

@@ 404-430 (lines=27) @@
401
                    f"Analyze the error and you'll need to redeploy EVC {evc_id} later"
402
                )
403
404
    @alisten_to("kytos/mef_eline.error_redeploy_link_down")
405
    async def on_evc_error_redeployed_link_down(self, event: KytosEvent) -> None:
406
        """On EVC error_redeploy_link_down, this is supposed to happen when
407
        a path isn't when mef_eline handles a link down."""
408
        content = event.content
409
        if (
410
            content["enabled"]
411
            and "metadata" in content
412
            and "telemetry" in content["metadata"]
413
            and content["metadata"]["telemetry"]["enabled"]
414
        ):
415
            metadata = {
416
                "telemetry": {
417
                    "enabled": True,
418
                    "status": "DOWN",
419
                    "status_reason": ["redeployed_link_down_no_path"],
420
                    "status_updated_at": datetime.utcnow().strftime(
421
                        "%Y-%m-%dT%H:%M:%S"
422
                    ),
423
                }
424
            }
425
            evc_id = content["id"]
426
            evcs = {evc_id: content}
427
            log.info(
428
                f"Handling mef_eline.redeployed_link_down_no_path on EVC id: {evc_id}"
429
            )
430
            await self.int_manager.remove_int_flows(evcs, metadata, force=True)
431
432
    @alisten_to("kytos/mef_eline.failover_link_down")
433
    async def on_failover_link_down(self, event: KytosEvent):
@@ 358-381 (lines=24) @@
355
                f"and you'll need to enable or redeploy EVC {evc_id} later"
356
            )
357
358
    @alisten_to("kytos/mef_eline.undeployed")
359
    async def on_evc_undeployed(self, event: KytosEvent) -> None:
360
        """On EVC undeployed."""
361
        content = event.content
362
        if (
363
            not content["enabled"]
364
            and "metadata" in content
365
            and "telemetry" in content["metadata"]
366
            and content["metadata"]["telemetry"]["enabled"]
367
        ):
368
            metadata = {
369
                "telemetry": {
370
                    "enabled": True,
371
                    "status": "DOWN",
372
                    "status_reason": ["undeployed"],
373
                    "status_updated_at": datetime.utcnow().strftime(
374
                        "%Y-%m-%dT%H:%M:%S"
375
                    ),
376
                }
377
            }
378
            evc_id = content["id"]
379
            evcs = {evc_id: content}
380
            log.info(f"Handling mef_eline.undeployed on EVC id: {evc_id}")
381
            await self.int_manager.remove_int_flows(evcs, metadata, force=True)
382
383
    @alisten_to("kytos/mef_eline.(redeployed_link_down|redeployed_link_up)")
384
    async def on_evc_redeployed_link(self, event: KytosEvent) -> None: