Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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