Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

@@ 1214-1242 (lines=29) @@
1211
        with self._links_lock:
1212
            self.handle_interruption_end(event)
1213
1214
    def handle_interruption_end(self, event: KytosEvent):
1215
        """Deals with the end 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 end 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
@@ 1178-1206 (lines=29) @@
1175
        with self._links_lock:
1176
            self.handle_interruption_start(event)
1177
1178
    def handle_interruption_start(self, event: KytosEvent):
1179
        """Deals with the start of service interruption."""
1180
        interrupt_type = event.content['type']
1181
        switches = event.content.get('switches', [])
1182
        interfaces = event.content.get('interfaces', [])
1183
        links = event.content.get('links', [])
1184
        log.info(
1185
            'Received interruption start of type \'%s\' '
1186
            'affecting switches %s, interfaces %s, links %s',
1187
            interrupt_type,
1188
            switches,
1189
            interfaces,
1190
            links
1191
        )
1192
        # for switch_id in switches:
1193
        #     pass
1194
        # for interface_id in interfaces:
1195
        #     pass
1196
        for link_id in links:
1197
            link = self.links.get(link_id)
1198
            if link is None:
1199
                log.error(
1200
                    "Invalid link id '%s' for interruption of type '%s;",
1201
                    link_id,
1202
                    interrupt_type
1203
                )
1204
            else:
1205
                self.notify_link_status_change(link, interrupt_type)
1206
        self.notify_topology_update()
1207
1208
    @listen_to('topology.interruption.end')
1209
    def on_interruption_end(self, event: KytosEvent):