Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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