Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

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