Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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