Code Duplication    Length = 30-30 lines in 2 locations

main.py 2 locations

@@ 1415-1444 (lines=30) @@
1412
                    self.notify_link_status_change(link, interrupt_type)
1413
        self.notify_topology_update()
1414
1415
    def handle_interruption_end(self, event: KytosEvent):
1416
        """Deals with the end of service interruption."""
1417
        interrupt_type = event.content['type']
1418
        switches = event.content.get('switches', [])
1419
        interfaces = event.content.get('interfaces', [])
1420
        links = event.content.get('links', [])
1421
        log.info(
1422
            'Received interruption end of type \'%s\' '
1423
            'affecting switches %s, interfaces %s, links %s',
1424
            interrupt_type,
1425
            switches,
1426
            interfaces,
1427
            links
1428
        )
1429
        # for switch_id in switches:
1430
        #     pass
1431
        # for interface_id in interfaces:
1432
        #     pass
1433
        for link_id in links:
1434
            link = self.controller.get_link(link_id)
1435
            if link is None:
1436
                log.error(
1437
                    "Invalid link id '%s' for interruption of type '%s;",
1438
                    link_id,
1439
                    interrupt_type
1440
                )
1441
            else:
1442
                with link.link_lock:
1443
                    self.notify_link_status_change(link, interrupt_type)
1444
        self.notify_topology_update()
1445
@@ 1384-1413 (lines=30) @@
1381
        elif interrupt_type == "end":
1382
            self.handle_interruption_end(event)
1383
1384
    def handle_interruption_start(self, event: KytosEvent):
1385
        """Deals with the start of service interruption."""
1386
        interrupt_type = event.content['type']
1387
        switches = event.content.get('switches', [])
1388
        interfaces = event.content.get('interfaces', [])
1389
        links = event.content.get('links', [])
1390
        log.info(
1391
            'Received interruption start of type \'%s\' '
1392
            'affecting switches %s, interfaces %s, links %s',
1393
            interrupt_type,
1394
            switches,
1395
            interfaces,
1396
            links
1397
        )
1398
        # for switch_id in switches:
1399
        #     pass
1400
        # for interface_id in interfaces:
1401
        #     pass
1402
        for link_id in links:
1403
            link = self.controller.get_link(link_id)
1404
            if link is None:
1405
                log.error(
1406
                    "Invalid link id '%s' for interruption of type '%s;",
1407
                    link_id,
1408
                    interrupt_type
1409
                )
1410
            else:
1411
                with link.link_lock:
1412
                    self.notify_link_status_change(link, interrupt_type)
1413
        self.notify_topology_update()
1414
1415
    def handle_interruption_end(self, event: KytosEvent):
1416
        """Deals with the end of service interruption."""