Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

@@ 1462-1490 (lines=29) @@
1459
                self.notify_link_status_change(link, interrupt_type)
1460
        self.notify_topology_update()
1461
1462
    def handle_interruption_end(self, event: KytosEvent):
1463
        """Deals with the end of service interruption."""
1464
        interrupt_type = event.content['type']
1465
        switches = event.content.get('switches', [])
1466
        interfaces = event.content.get('interfaces', [])
1467
        links = event.content.get('links', [])
1468
        log.info(
1469
            'Received interruption end of type \'%s\' '
1470
            'affecting switches %s, interfaces %s, links %s',
1471
            interrupt_type,
1472
            switches,
1473
            interfaces,
1474
            links
1475
        )
1476
        # for switch_id in switches:
1477
        #     pass
1478
        # for interface_id in interfaces:
1479
        #     pass
1480
        for link_id in links:
1481
            link = self.links.get(link_id)
1482
            if link is None:
1483
                log.error(
1484
                    "Invalid link id '%s' for interruption of type '%s;",
1485
                    link_id,
1486
                    interrupt_type
1487
                )
1488
            else:
1489
                self.notify_link_status_change(link, interrupt_type)
1490
        self.notify_topology_update()
1491
@@ 1432-1460 (lines=29) @@
1429
            elif interrupt_type == "end":
1430
                self.handle_interruption_end(event)
1431
1432
    def handle_interruption_start(self, event: KytosEvent):
1433
        """Deals with the start of service interruption."""
1434
        interrupt_type = event.content['type']
1435
        switches = event.content.get('switches', [])
1436
        interfaces = event.content.get('interfaces', [])
1437
        links = event.content.get('links', [])
1438
        log.info(
1439
            'Received interruption start of type \'%s\' '
1440
            'affecting switches %s, interfaces %s, links %s',
1441
            interrupt_type,
1442
            switches,
1443
            interfaces,
1444
            links
1445
        )
1446
        # for switch_id in switches:
1447
        #     pass
1448
        # for interface_id in interfaces:
1449
        #     pass
1450
        for link_id in links:
1451
            link = self.links.get(link_id)
1452
            if link is None:
1453
                log.error(
1454
                    "Invalid link id '%s' for interruption of type '%s;",
1455
                    link_id,
1456
                    interrupt_type
1457
                )
1458
            else:
1459
                self.notify_link_status_change(link, interrupt_type)
1460
        self.notify_topology_update()
1461
1462
    def handle_interruption_end(self, event: KytosEvent):
1463
        """Deals with the end of service interruption."""