Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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