Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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