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