Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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