Code Duplication    Length = 30-30 lines in 2 locations

main.py 2 locations

@@ 1450-1479 (lines=30) @@
1447
                    self.notify_link_status_change(link, interrupt_type)
1448
        self.notify_topology_update()
1449
1450
    def handle_interruption_end(self, event: KytosEvent):
1451
        """Deals with the end of service interruption."""
1452
        interrupt_type = event.content['type']
1453
        switches = event.content.get('switches', [])
1454
        interfaces = event.content.get('interfaces', [])
1455
        links = event.content.get('links', [])
1456
        log.info(
1457
            'Received interruption end of type \'%s\' '
1458
            'affecting switches %s, interfaces %s, links %s',
1459
            interrupt_type,
1460
            switches,
1461
            interfaces,
1462
            links
1463
        )
1464
        # for switch_id in switches:
1465
        #     pass
1466
        # for interface_id in interfaces:
1467
        #     pass
1468
        for link_id in links:
1469
            link = self.controller.get_link(link_id)
1470
            if link is None:
1471
                log.error(
1472
                    "Invalid link id '%s' for interruption of type '%s;",
1473
                    link_id,
1474
                    interrupt_type
1475
                )
1476
            else:
1477
                with link.link_lock:
1478
                    self.notify_link_status_change(link, interrupt_type)
1479
        self.notify_topology_update()
1480
1481
    def get_latest_topology(self):
1482
        """Get the latest topology."""
@@ 1419-1448 (lines=30) @@
1416
        elif interrupt_type == "end":
1417
            self.handle_interruption_end(event)
1418
1419
    def handle_interruption_start(self, event: KytosEvent):
1420
        """Deals with the start of service interruption."""
1421
        interrupt_type = event.content['type']
1422
        switches = event.content.get('switches', [])
1423
        interfaces = event.content.get('interfaces', [])
1424
        links = event.content.get('links', [])
1425
        log.info(
1426
            'Received interruption start of type \'%s\' '
1427
            'affecting switches %s, interfaces %s, links %s',
1428
            interrupt_type,
1429
            switches,
1430
            interfaces,
1431
            links
1432
        )
1433
        # for switch_id in switches:
1434
        #     pass
1435
        # for interface_id in interfaces:
1436
        #     pass
1437
        for link_id in links:
1438
            link = self.controller.get_link(link_id)
1439
            if link is None:
1440
                log.error(
1441
                    "Invalid link id '%s' for interruption of type '%s;",
1442
                    link_id,
1443
                    interrupt_type
1444
                )
1445
            else:
1446
                with link.link_lock:
1447
                    self.notify_link_status_change(link, interrupt_type)
1448
        self.notify_topology_update()
1449
1450
    def handle_interruption_end(self, event: KytosEvent):
1451
        """Deals with the end of service interruption."""