Code Duplication    Length = 29-29 lines in 2 locations

main.py 2 locations

@@ 1111-1139 (lines=29) @@
1108
        with self._links_lock:
1109
            self.handle_interruption_end(event)
1110
1111
    def handle_interruption_end(self, event: KytosEvent):
1112
        """Deals with the end of service interruption."""
1113
        interrupt_type = event.content['type']
1114
        switches = event.content.get('switches', [])
1115
        interfaces = event.content.get('interfaces', [])
1116
        links = event.content.get('links', [])
1117
        log.info(
1118
            'Received interruption end of type \'%s\' '
1119
            'affecting switches %s, interfaces %s, links %s',
1120
            interrupt_type,
1121
            switches,
1122
            interfaces,
1123
            links
1124
        )
1125
        # for switch_id in switches:
1126
        #     pass
1127
        # for interface_id in interfaces:
1128
        #     pass
1129
        for link_id in links:
1130
            link = self.links.get(link_id)
1131
            if link is None:
1132
                log.error(
1133
                    "Invalid link id '%s' for interruption of type '%s;",
1134
                    link_id,
1135
                    interrupt_type
1136
                )
1137
            else:
1138
                self.notify_link_status_change(link, interrupt_type)
1139
        self.notify_topology_update()
1140
@@ 1075-1103 (lines=29) @@
1072
        with self._links_lock:
1073
            self.handle_interruption_start(event)
1074
1075
    def handle_interruption_start(self, event: KytosEvent):
1076
        """Deals with the start of service interruption."""
1077
        interrupt_type = event.content['type']
1078
        switches = event.content.get('switches', [])
1079
        interfaces = event.content.get('interfaces', [])
1080
        links = event.content.get('links', [])
1081
        log.info(
1082
            'Received interruption start of type \'%s\' '
1083
            'affecting switches %s, interfaces %s, links %s',
1084
            interrupt_type,
1085
            switches,
1086
            interfaces,
1087
            links
1088
        )
1089
        # for switch_id in switches:
1090
        #     pass
1091
        # for interface_id in interfaces:
1092
        #     pass
1093
        for link_id in links:
1094
            link = self.links.get(link_id)
1095
            if link is None:
1096
                log.error(
1097
                    "Invalid link id '%s' for interruption of type '%s;",
1098
                    link_id,
1099
                    interrupt_type
1100
                )
1101
            else:
1102
                self.notify_link_status_change(link, interrupt_type)
1103
        self.notify_topology_update()
1104
1105
    @listen_to('topology.interruption.end')
1106
    def on_interruption_end(self, event: KytosEvent):