Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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