Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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