Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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