Code Duplication    Length = 32-32 lines in 2 locations

main.py 2 locations

@@ 1452-1483 (lines=32) @@
1449
                    self.notify_link_status_change(link, interrupt_type)
1450
        self.notify_topology_update()
1451
1452
    def handle_interruption_end(self, event: KytosEvent):
1453
        """Deals with the end of service interruption."""
1454
        interrupt_type = event.content['type']
1455
        switches = event.content.get('switches', [])
1456
        interfaces = event.content.get('interfaces', [])
1457
        links = event.content.get('links', [])
1458
        log.info(
1459
            'Received interruption end of type \'%s\' '
1460
            'affecting switches %s, interfaces %s, links %s',
1461
            interrupt_type,
1462
            switches,
1463
            interfaces,
1464
            links
1465
        )
1466
        # for switch_id in switches:
1467
        #     pass
1468
        for interface_id in interfaces:
1469
            interface = self.controller.get_interface_by_id(interface_id)
1470
            if interface:
1471
                self.notify_interface_status(interface, 'UP')
1472
        for link_id in links:
1473
            link = self.controller.get_link(link_id)
1474
            if link is None:
1475
                log.error(
1476
                    "Invalid link id '%s' for interruption of type '%s;",
1477
                    link_id,
1478
                    interrupt_type
1479
                )
1480
            else:
1481
                with link.link_lock:
1482
                    self.notify_link_status_change(link, interrupt_type)
1483
        self.notify_topology_update()
1484
1485
    def get_latest_topology(self):
1486
        """Get the latest topology."""
@@ 1419-1450 (lines=32) @@
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
            interface = self.controller.get_interface_by_id(interface_id)
1437
            if interface:
1438
                self.notify_interface_status(interface, 'DOWN')
1439
        for link_id in links:
1440
            link = self.controller.get_link(link_id)
1441
            if link is None:
1442
                log.error(
1443
                    "Invalid link id '%s' for interruption of type '%s;",
1444
                    link_id,
1445
                    interrupt_type
1446
                )
1447
            else:
1448
                with link.link_lock:
1449
                    self.notify_link_status_change(link, interrupt_type)
1450
        self.notify_topology_update()
1451
1452
    def handle_interruption_end(self, event: KytosEvent):
1453
        """Deals with the end of service interruption."""