Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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