Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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