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