Code Duplication    Length = 30-30 lines in 2 locations

main.py 2 locations

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