Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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