Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

@@ 1250-1278 (lines=29) @@
1247
        with self._links_lock:
1248
            self.handle_interruption_end(event)
1249
1250
    def handle_interruption_end(self, event: KytosEvent):
1251
        """Deals with the end of service interruption."""
1252
        interrupt_type = event.content['type']
1253
        switches = event.content.get('switches', [])
1254
        interfaces = event.content.get('interfaces', [])
1255
        links = event.content.get('links', [])
1256
        log.info(
1257
            'Received interruption end of type \'%s\' '
1258
            'affecting switches %s, interfaces %s, links %s',
1259
            interrupt_type,
1260
            switches,
1261
            interfaces,
1262
            links
1263
        )
1264
        # for switch_id in switches:
1265
        #     pass
1266
        # for interface_id in interfaces:
1267
        #     pass
1268
        for link_id in links:
1269
            link = self.links.get(link_id)
1270
            if link is None:
1271
                log.error(
1272
                    "Invalid link id '%s' for interruption of type '%s;",
1273
                    link_id,
1274
                    interrupt_type
1275
                )
1276
            else:
1277
                self.notify_link_status_change(link, interrupt_type)
1278
        self.notify_topology_update()
1279
@@ 1214-1242 (lines=29) @@
1211
        with self._links_lock:
1212
            self.handle_interruption_start(event)
1213
1214
    def handle_interruption_start(self, event: KytosEvent):
1215
        """Deals with the start of service interruption."""
1216
        interrupt_type = event.content['type']
1217
        switches = event.content.get('switches', [])
1218
        interfaces = event.content.get('interfaces', [])
1219
        links = event.content.get('links', [])
1220
        log.info(
1221
            'Received interruption start of type \'%s\' '
1222
            'affecting switches %s, interfaces %s, links %s',
1223
            interrupt_type,
1224
            switches,
1225
            interfaces,
1226
            links
1227
        )
1228
        # for switch_id in switches:
1229
        #     pass
1230
        # for interface_id in interfaces:
1231
        #     pass
1232
        for link_id in links:
1233
            link = self.links.get(link_id)
1234
            if link is None:
1235
                log.error(
1236
                    "Invalid link id '%s' for interruption of type '%s;",
1237
                    link_id,
1238
                    interrupt_type
1239
                )
1240
            else:
1241
                self.notify_link_status_change(link, interrupt_type)
1242
        self.notify_topology_update()
1243
1244
    @listen_to('topology.interruption.end')
1245
    def on_interruption_end(self, event: KytosEvent):