diff --git a/02-Keyword/tsg_bfapi/PolicyObject.robot b/02-Keyword/tsg_bfapi/PolicyObject.robot index bc200fd..6fe21c0 100644 --- a/02-Keyword/tsg_bfapi/PolicyObject.robot +++ b/02-Keyword/tsg_bfapi/PolicyObject.robot @@ -135,6 +135,33 @@ DeleteWanIpPood ${response} Convert to String ${response} log ${response} +Add&Edit_PacketCapture + [Arguments] ${PacketCapture_data} + ${body} PacketCapture ${PacketCapture_data} + log ${body} + # ${body1} Set Variable {"refuseCode":true,"opAction":"add","returnData":0,"list":[{"ipList":[{"flag":"add","ip":"192.168.50.60","status":1597124967143,"isError":false,"testIp":"192.168.50.60","testIpRelativeLocation":"internal","testResult":[{"serverIp":"192.168.32.92","serverRelativeLocation":"external","serverGeoLocation":"UA","reachable":"pass"},{"serverIp":"192.168.32.91","serverRelativeLocation":"internal","serverGeoLocation":"Hongkang","reachable":"pass"}],"linkInfo":{"todo1":"fake-result","todo2":"test-API-only","todo3":"not-get-from-galaxy"},"relative_location":"internal","reachableCollect":"success"}],"profileName":"12313123123"}]} + ${response} run keyword if '${PacketCapture_data}[profileId]'=="" BasePostRequest /${version}/troubleshooting/packetcapture/policy ${body} + ... ELSE BaseEditRequestOK /${version}/troubleshooting/packetcapture/policy ${body} + log ${response} + ${response_code} Set Variable ${response['code']} + ${response_id} Set Variable ${response['data']['list'][0]['profileId']} + # log 11111111111111111111222222222222222 + # log ${response_id} + Should Be Equal As Strings ${response_code} 200 + ${response} Convert to String ${response} + log ${response} + [Return] ${response_id} + +DeletePacketCapture + [Arguments] ${vpnlist} + #删除Vpn + ${body} Create Dictionary profileIds=${vpnlist} + log 删除vpn + ${response} BaseDeleteRequest /${version}/troubleshooting/packetcapture/policy ${body} + ${response_code} Get From Dictionary ${response} code + Should Be Equal As Strings ${response_code} 200 + ${response} Convert to String ${response} + log ${response} diff --git a/02-Keyword/tsg_common/ManageObjectBody.robot b/02-Keyword/tsg_common/ManageObjectBody.robot index 7e734b2..3baff6a 100644 --- a/02-Keyword/tsg_common/ManageObjectBody.robot +++ b/02-Keyword/tsg_common/ManageObjectBody.robot @@ -246,10 +246,27 @@ WanVpn ${data} Set Variable "opAction":"add","returnData":1 ${dict}= Evaluate eval ('{${data}}') ${data2} set to dictionary ${dict} list=${wanvpnlist} - [Return] ${data2} + ${json} json.Dumps ${data2} ensure_ascii=False + [Return] ${json} +IP_list + [Arguments] ${Iplist} + ${list} Create List + FOR ${k} ${v} IN ENUMERATE @{Iplist} + Append To List ${list} ${v} + END + ${list2} Set Variable ${list}[2] + ${list3} Set Variable ${list}[3] + ${link_id} evaluate int(${Iplist}[${list2}]) + ${src_mac} evaluate int(${Iplist}[${list3}]) + ${list_info} Create Dictionary ${list}[2]=${link_id} ${list}[3]=${src_mac} + ${Ip_list} Create Dictionary ip=${Iplist}[ip] relative_location=${Iplist}[relative_location] link_info=${list_info} + log 123213213213213123 + log ${Ip_list} + # log ${link_info} + [Return] ${Ip_list} WanNatIpPood - [Arguments] ${must_parameter} ${wan_nat_ip_iplist} + [Arguments] ${must_parameter} ${wan_nat_ip_iplist} # 编写iplist json格式 ${wan_nat_ip_iplist} Create Dictionary profileId=${must_parameter}[profileId] profileName=${must_parameter}[profileName] ipList=${wan_nat_ip_iplist} isValid=1 #编写二层list内地格式 @@ -261,4 +278,40 @@ WanNatIpPood ${wan_nat_ip_pood_data} Create Dictionary opAction=${opAction} returnData=1 list=${wan_nat_ip_list} # 返回请求json log ${wan_nat_ip_pood_data} - [Return] ${wan_nat_ip_pood_data} + ${json} json.Dumps ${wan_nat_ip_pood_data} ensure_ascii=False + log ${json} + [Return] ${json} + +PacketCapture + [Arguments] ${PacketCapturedata} + # 编写iplist json格式 + log ${PacketCapturedata} + # 替换指定键值对的值为 int + ${addrType} evaluate int(${PacketCapturedata}[addrType]) + ${protocol} evaluate int(${PacketCapturedata}[protocol]) + ${captureDuration} evaluate int(${PacketCapturedata}[captureDuration]) + Set To Dictionary ${PacketCapturedata}# + ... policyId=${PacketCapturedata}[policyId] + ... policyName=${PacketCapturedata}[policyName] + ... addrType=${PacketCapturedata}[addrType] + ... protocol=${PacketCapturedata}[protocol] + ... clientIp=${PacketCapturedata}[clientIp] + ... clientPort=${PacketCapturedata}[clientPort] + ... serverIp=${PacketCapturedata}[serverIp] + ... serverPort=${PacketCapturedata}[serverPort] + ... maxPacket=${PacketCapturedata}[maxPacket] + ... captureDuration=${PacketCapturedata}[captureDuration] + log 111111111111111111111111111111111111111111111111111111111 + log ${PacketCapturedata} + ${wan_nat_ip_iplist} Create Dictionary profileId=${must_parameter}[profileId] profileName=${must_parameter}[profileName] ipList=${wan_nat_ip_iplist} isValid=1 + #编写二层list内地格式 + ${wan_nat_ip_list} Create List ${wan_nat_ip_iplist} + # 判断sjon是用于修改还是新增 + ${opAction} run keyword if '${must_parameter}[profileId]'=="" Set Variable add + ... ELSE Set Variable update + #编写最外面的格式 + ${wan_nat_ip_pood_data} Create Dictionary opAction=${opAction} returnData=1 policyList=${wan_nat_ip_list} + # 返回请求json + log ${wan_nat_ip_pood_data} + ${json} json.Dumps ${wan_nat_ip_pood_data} ensure_ascii=False + [Return] ${json} \ No newline at end of file