Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

@@ 1358-1386 (lines=29) @@
1355
        with self._links_lock:
1356
            self.handle_interruption_end(event)
1357
1358
    def handle_interruption_end(self, event: KytosEvent):
1359
        """Deals with the end of service interruption."""
1360
        interrupt_type = event.content['type']
1361
        switches = event.content.get('switches', [])
1362
        interfaces = event.content.get('interfaces', [])
1363
        links = event.content.get('links', [])
1364
        log.info(
1365
            'Received interruption end of type \'%s\' '
1366
            'affecting switches %s, interfaces %s, links %s',
1367
            interrupt_type,
1368
            switches,
1369
            interfaces,
1370
            links
1371
        )
1372
        # for switch_id in switches:
1373
        #     pass
1374
        # for interface_id in interfaces:
1375
        #     pass
1376
        for link_id in links:
1377
            link = self.links.get(link_id)
1378
            if link is None:
1379
                log.error(
1380
                    "Invalid link id '%s' for interruption of type '%s;",
1381
                    link_id,
1382
                    interrupt_type
1383
                )
1384
            else:
1385
                self.notify_link_status_change(link, interrupt_type)
1386
        self.notify_topology_update()
1387
@@ 1322-1350 (lines=29) @@
1319
        with self._links_lock:
1320
            self.handle_interruption_start(event)
1321
1322
    def handle_interruption_start(self, event: KytosEvent):
1323
        """Deals with the start of service interruption."""
1324
        interrupt_type = event.content['type']
1325
        switches = event.content.get('switches', [])
1326
        interfaces = event.content.get('interfaces', [])
1327
        links = event.content.get('links', [])
1328
        log.info(
1329
            'Received interruption start of type \'%s\' '
1330
            'affecting switches %s, interfaces %s, links %s',
1331
            interrupt_type,
1332
            switches,
1333
            interfaces,
1334
            links
1335
        )
1336
        # for switch_id in switches:
1337
        #     pass
1338
        # for interface_id in interfaces:
1339
        #     pass
1340
        for link_id in links:
1341
            link = self.links.get(link_id)
1342
            if link is None:
1343
                log.error(
1344
                    "Invalid link id '%s' for interruption of type '%s;",
1345
                    link_id,
1346
                    interrupt_type
1347
                )
1348
            else:
1349
                self.notify_link_status_change(link, interrupt_type)
1350
        self.notify_topology_update()
1351
1352
    @listen_to('topology.interruption.end')
1353
    def on_interruption_end(self, event: KytosEvent):