Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

@@ 1209-1237 (lines=29) @@
1206
        with self._links_lock:
1207
            self.handle_interruption_end(event)
1208
1209
    def handle_interruption_end(self, event: KytosEvent):
1210
        """Deals with the end of service interruption."""
1211
        interrupt_type = event.content['type']
1212
        switches = event.content.get('switches', [])
1213
        interfaces = event.content.get('interfaces', [])
1214
        links = event.content.get('links', [])
1215
        log.info(
1216
            'Received interruption end of type \'%s\' '
1217
            'affecting switches %s, interfaces %s, links %s',
1218
            interrupt_type,
1219
            switches,
1220
            interfaces,
1221
            links
1222
        )
1223
        # for switch_id in switches:
1224
        #     pass
1225
        # for interface_id in interfaces:
1226
        #     pass
1227
        for link_id in links:
1228
            link = self.links.get(link_id)
1229
            if link is None:
1230
                log.error(
1231
                    "Invalid link id '%s' for interruption of type '%s;",
1232
                    link_id,
1233
                    interrupt_type
1234
                )
1235
            else:
1236
                self.notify_link_status_change(link, interrupt_type)
1237
        self.notify_topology_update()
1238
@@ 1173-1201 (lines=29) @@
1170
        with self._links_lock:
1171
            self.handle_interruption_start(event)
1172
1173
    def handle_interruption_start(self, event: KytosEvent):
1174
        """Deals with the start of service interruption."""
1175
        interrupt_type = event.content['type']
1176
        switches = event.content.get('switches', [])
1177
        interfaces = event.content.get('interfaces', [])
1178
        links = event.content.get('links', [])
1179
        log.info(
1180
            'Received interruption start of type \'%s\' '
1181
            'affecting switches %s, interfaces %s, links %s',
1182
            interrupt_type,
1183
            switches,
1184
            interfaces,
1185
            links
1186
        )
1187
        # for switch_id in switches:
1188
        #     pass
1189
        # for interface_id in interfaces:
1190
        #     pass
1191
        for link_id in links:
1192
            link = self.links.get(link_id)
1193
            if link is None:
1194
                log.error(
1195
                    "Invalid link id '%s' for interruption of type '%s;",
1196
                    link_id,
1197
                    interrupt_type
1198
                )
1199
            else:
1200
                self.notify_link_status_change(link, interrupt_type)
1201
        self.notify_topology_update()
1202
1203
    @listen_to('topology.interruption.end')
1204
    def on_interruption_end(self, event: KytosEvent):