Code Duplication    Length = 22-25 lines in 2 locations

models/evc.py 2 locations

@@ 1082-1106 (lines=25) @@
1079
            return []
1080
        return response.json().get('result', [])
1081
1082
    @staticmethod
1083
    def run_bulk_sdntraces(uni_list):
1084
        """Run SDN traces on control plane starting from EVC UNIs."""
1085
        endpoint = f"{settings.SDN_TRACE_CP_URL}/traces"
1086
        data = []
1087
        for uni in uni_list:
1088
            data_uni = {
1089
                "trace": {
1090
                            "switch": {
1091
                                "dpid": uni.interface.switch.dpid,
1092
                                "in_port": uni.interface.port_number,
1093
                            }
1094
                        }
1095
                }
1096
            if uni.user_tag:
1097
                data_uni["trace"]["eth"] = {
1098
                                            "dl_type": 0x8100,
1099
                                            "dl_vlan": uni.user_tag.value,
1100
                                            }
1101
            data.append(data_uni)
1102
        response = requests.put(endpoint, json=data, timeout=30)
1103
        if response.status_code >= 400:
1104
            log.error(f"Failed to run sdntrace-cp: {response.text}")
1105
            return []
1106
        return response.json()
1107
1108
    @staticmethod
1109
    # pylint: disable=too-many-locals
@@ 1059-1080 (lines=22) @@
1056
        flow_mod["actions"].insert(0, new_action)
1057
        return flow_mod
1058
1059
    @staticmethod
1060
    def run_sdntrace(uni):
1061
        """Run SDN trace on control plane starting from EVC UNIs."""
1062
        endpoint = f"{settings.SDN_TRACE_CP_URL}/trace"
1063
        data_uni = {
1064
            "trace": {
1065
                "switch": {
1066
                    "dpid": uni.interface.switch.dpid,
1067
                    "in_port": uni.interface.port_number,
1068
                }
1069
            }
1070
        }
1071
        if uni.user_tag:
1072
            data_uni["trace"]["eth"] = {
1073
                "dl_type": 0x8100,
1074
                "dl_vlan": uni.user_tag.value,
1075
            }
1076
        response = requests.put(endpoint, json=data_uni)
1077
        if response.status_code >= 400:
1078
            log.error(f"Failed to run sdntrace-cp: {response.text}")
1079
            return []
1080
        return response.json().get('result', [])
1081
1082
    @staticmethod
1083
    def run_bulk_sdntraces(uni_list):