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