Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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