summaryrefslogtreecommitdiff
path: root/keyword/objects/manage_object_body.robot
blob: dc57ae4623999308f4e916d281e8e2806906df9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
*** Settings ***
Library           json
Library           Collections
Resource          ../../variable/common_variable.txt
Resource          ../../variable/policy_object_default.txt
Resource          Object.robot

*** Keywords ***
ObjectParamsOpertion
    [Documentation]
    ...    描述:入口,opAction参数固定为'add'
    ...    其它参数默认值见/03-Variable/PolicyObjectDefault.txt
        
    [Arguments]    ${returnData}    ${objectList}    ${opAction}        
    ${emptyList}    Create List
    ${returnDict}    Create Dictionary
    # 断言必传参数
    # Should Not Be Empty    ${objectList}[objectType]
    # Set To Dictionary    ${returnDict}    objectType=${objectList}[objectType]
    Should Not Be Empty    ${objectList}[addItemList]
    # 取可选参数,为传入设置默认值
    ${return}    ${objectType}    Run Keyword And Ignore Error    Set Variable    ${objectList}[objectType]
    ${objectTypeV}    Run Keyword If    "${return}"!="FAIL" and "${objectType}"!="${EMPTY}"    Evaluate    '${objectType}'.lower()
                      ...    ELSE    Evaluate    '${Default_ObjectType}'.lower()
    Set To Dictionary    ${objectList}    objectType=${objectTypeV}
    Set To Dictionary    ${returnDict}    objectType=${objectTypeV}
    ${return}    ${objectSubType}    Run Keyword And Ignore Error    Set Variable    ${objectList}[objectSubType]
    Run Keyword If    "${return}"!="FAIL" and "${objectSubType}"!="${EMPTY}"    Set To Dictionary    ${returnDict}    objectSubType=${objectSubType}
    ...    ELSE    Set To Dictionary    ${returnDict}    objectSubType=${Default_ObjectSubType}
    ${return}    ${isValid}    Run Keyword And Ignore Error    Set Variable    ${objectList}[isValid]
    Run Keyword If    "${return}"=="FAIL" or "${isValid}"=="${EMPTY}"    Set To Dictionary    ${returnDict}    isValid=${Default_IsValid}
    ...    ELSE    Set To Dictionary    ${returnDict}    isValid=${isValid}    
    ${return}    ${isInitialize}    Run Keyword And Ignore Error    Set Variable    ${objectList}[isInitialize]
    Run Keyword If    "${return}"=="FAIL" or "${isInitialize}"=="${EMPTY}"    Set To Dictionary    ${returnDict}    isInitialize=${Default_IsInitialize}
    ...    ELSE    Set To Dictionary    ${returnDict}    isInitialize=${isInitialize}
    ${return}    ${isExclusion}    Run Keyword And Ignore Error    Set Variable    ${objectList}[isExclusion]
    Run Keyword If    "${return}"=="FAIL" or "${isExclusion}"=="${EMPTY}"    Set To Dictionary    ${returnDict}    isExclusion=${Default_IsExclusion}
    ...    ELSE    Set To Dictionary    ${returnDict}    isExclusion=${isExclusion}
    ${return}    ${objectName}    Run Keyword And Ignore Error    Set Variable    ${objectList}[objectName]
    Run Keyword If    "${return}"=="FAIL" or "${objectName}"=="${EMPTY}"    Set To Dictionary    ${returnDict}    objectName=${Default_ObjectName}
    ...    ELSE    Set To Dictionary    ${returnDict}    objectName=${objectName}
    ${return}    ${objectDesc}    Run Keyword And Ignore Error    Set Variable    ${objectList}[objectDesc]
    Run Keyword If    "${return}"!="FAIL" and "${objectDesc}"!="${EMPTY}"    Set To Dictionary    ${returnDict}    objectDesc=${objectDesc}
    ...    ELSE    Set To Dictionary    ${returnDict}    objectDesc=${Default_ObjectDesc}
    ${return}    ${subObjectIds}    Run Keyword And Ignore Error    Set Variable    ${objectList}[subObjectIds]
    ${subObjectIdsV}    Run Keyword If    "${return}"!="FAIL" and "${subObjectIds}"!="${EMPTY}" and "${subObjectIds}"!="${None}"    Evaluate    list(map(int, re.split('[,]', '${subObjectIds}')))    re
                       ...    ELSE    Set Variable    ${emptyList}   
    ${return}    ${objectId}    Run Keyword And Ignore Error    Set Variable    ${objectList}[objectId]
    Run Keyword If    "${return}"=="FAIL" or "${objectId}"=="${EMPTY}"    Set To Dictionary    ${returnDict}    objectId=${EMPTY}
    ...    ELSE    Set To Dictionary    ${returnDict}    objectId=${objectId}
    Set To Dictionary    ${returnDict}    subObjectIds=${subObjectIdsV}
    
    # 处理AddItemList
    ManageAddItemList    ${objectList}    ${returnDict}      
    
    # 转为json结构并返回
    ${dict}    Create Dictionary    opAction=${opAction}    returnData=${returnData}    objectList=${returnDict}    
    ${json}    json.Dumps    ${dict}    ensure_ascii=False
    Log    Object_Request_Body-${json}
    [Return]    ${json}

ManageAddItemList
    # 处理addItemList数组
    [Arguments]    ${objectList}    ${returnDict}    
    ${itemList}    Run Keyword If    '${objectList}[objectType]'=='ip'    ManageIpItemList    ${objectList}[addItemList]        
                   ...    ELSE IF    '${objectList}[objectType]'=='http_signature'    ManageStrItemList    ${objectList}[addItemList]    ${True}    
                   ...    ELSE    ManageStrItemList    ${objectList}[addItemList]    ${False}
    Set To Dictionary    ${returnDict}    addItemList=${itemList}    

ManageIpItemList
    # 处理IP对象
    [Arguments]    ${str}
    ${returnList}    Create List
     # ${list}    Evaluate    re.split('[,]', '${str}')    re
    log   ${str}
    FOR    ${var}    IN    @{str}
       # Continue For Loop If    '${var}' == '${EMPTY}'
     # 区分入参的类型,分别处理
     Append To List    ${returnList}    ${var}
    END
    [Return]    ${returnList}   

ManageStrItemList
    # 处理除IP外其它字符串对象
    [Arguments]    ${str}    ${flag}
    ${returnList}    Create List
    ${list}    Evaluate    re.split('[,]', '${str}')    re 
    FOR    ${var}    IN    @{list}    
        Continue For Loop If    '${var}' == '${EMPTY}'       
        ${obj}    AnalysisStrItem    ${var}    ${flag}        
        Append To List    ${returnList}    ${obj}
    END
    [Return]    ${returnList}
IpItemType11
    [Arguments]    ${str}
   ${obj}    Create Dictionary
   ${values}    Evaluate    re.split('[|]', '${str}')    re
   ${isSession}   Convert To Integer    ${values}[0]
   ${ip}    Convert To Integer    ${values}[1]
   ${port}    Convert To Integer    ${values}[2]
   ${direction}    Convert To Integer    ${values}[3]
   ${protocol}    Convert To Integer    ${values}[4]
   ${return}    ${isInitialize}    Run Keyword And Ignore Error    Convert To Integer    ${list}[${index+1}]
    Run Keyword If    "${return}"!="FAIL" and "${isInitialize}"!="${EMPTY}"    Set To Dictionary    ${obj}    isInitialize=${isInitialize}
IpItemType1
    # IP类型1:4|0|0|endpoint#range|192.168.40.1|192.168.40.50|80/88&range|192.168.40.1|192.168.40.50|80/88|1|itemName|itemDesc,...
    [Arguments]    ${str}
    ${obj}    Create Dictionary
    ${left}    Evaluate    '${str}'[0:'${str}'.find('#')]
    ${right}    Evaluate    '${str}'['${str}'.find('#')+1:]
    ${values}    Evaluate    re.split('[|]', '${left}')    re
    ${addrType}    Convert To Integer    ${values}[0]   
    ${protocol}    Convert To Integer    ${values}[1]   
    ${direction}    Convert To Integer    ${values}[2]   
    Set To Dictionary    ${obj}    addrType=${addrType}    protocol=${protocol}    direction=${direction}    isSession=${values}[3]    
    
    ${cfgs}    Evaluate    re.split('[&]', '${right}')    re
    ${client}    Set Variable    ${cfgs}[0]    
    ${server}    Set Variable    ${cfgs}[1]    
    
    ${cValues}    Evaluate    re.split('[|]', '${client}')    re
    ${sValues}    Evaluate    re.split('[|]', '${server}')    re
    ${clientPort1}    Evaluate    int(re.split('[/]', '${cValues}[3]')[0])    re
    ${clientPort2}    Evaluate    int(re.split('[/]', '${cValues}[3]')[1])    re
    ${serverPort1}    Evaluate    int(re.split('[/]', '${sValues}[3]')[0])    re
    ${serverPort2}    Evaluate    int(re.split('[/]', '${sValues}[3]')[1])    re
    Set To Dictionary    ${obj}    clientIpFormat=${cValues}[0]    clientIp1=${cValues}[1]    clientIp2=${cValues}[2]    clientPortFormat=range    clientPort1=${clientPort1}    clientPort2=${clientPort2}                    
    Set To Dictionary    ${obj}    serverIpFormat=${sValues}[0]    serverIp1=${sValues}[1]    serverIp2=${sValues}[2]    serverPortFormat=range    serverPort1=${serverPort1}    serverPort2=${serverPort2}                   
    
    OtherParams    ${sValues}    ${obj}
    [Return]    ${obj}

IpItemType2
    # IP类型2:4|0|0|endpoint#range|192.168.40.1|192.168.40.50|80/88|1|itemName|itemDesc,...
    [Arguments]    ${str}
    ${obj}    Create Dictionary
    ${left}    Evaluate    '${str}'[0:'${str}'.find('#')]
    ${client}    Evaluate    '${str}'['${str}'.find('#')+1:]
    ${values}    Evaluate    re.split('[|]', '${left}')    re
    ${addrType}    Convert To Integer    ${values}[0]   
    ${protocol}    Convert To Integer    ${values}[1]   
    ${direction}    Convert To Integer    ${values}[2]   
    Set To Dictionary    ${obj}    addrType=${addrType}    protocol=${protocol}    direction=${direction}    isSession=${values}[3]    
    
    ${cValues}    Evaluate    re.split('[|]', '${client}')    re
    ${clientPort1}    Evaluate    int(re.split('[/]', '${cValues}[3]')[0])    re
    ${clientPort2}    Evaluate    int(re.split('[/]', '${cValues}[3]')[1])    re
    Set To Dictionary    ${obj}    clientIpFormat=${cValues}[0]    clientIp1=${cValues}[1]    clientIp2=${cValues}[2]    clientPortFormat=range    clientPort1=${clientPort1}    clientPort2=${clientPort2}                    
    # 设置默认值
    Set To Dictionary    ${obj}    serverIpFormat=range    serverIp1=    serverIp2=    serverPortFormat=range    serverPort1=${0}    serverPort2=${0}
    OtherParams    ${cValues}    ${obj}
    [Return]    ${obj}
    
IpItemType3
    # IP类型3:range|192.168.40.1|192.168.40.50|80/88&range|192.168.40.1|192.168.40.50|80/88|1|itemName|itemDesc,...
    [Arguments]    ${str}
    ${obj}    Create Dictionary
    # 设置默认值
    Run Keyword If    ':' in '${str}'    Set To Dictionary    ${obj}    addrType=${6}
    ...    ELSE    Set To Dictionary    ${obj}    addrType=${Default_AddItem_AddrType}     
    Set To Dictionary    ${obj}    protocol=${Default_AddItem_Protocol}    direction=${Default_AddItem_Direction}    isSession=${Default_AddItem_IsSession}    
    
    ${cfgs}    Evaluate    re.split('[&]', '${str}')    re
    ${client}    Set Variable    ${cfgs}[0]    
    ${server}    Set Variable    ${cfgs}[1]    
    
    ${cValues}    Evaluate    re.split('[|]', '${client}')    re
    ${sValues}    Evaluate    re.split('[|]', '${server}')    re
    ${clientPort1}    Evaluate    int(re.split('[/]', '${cValues}[3]')[0])    re
    ${clientPort2}    Evaluate    int(re.split('[/]', '${cValues}[3]')[1])    re
    ${serverPort1}    Evaluate    int(re.split('[/]', '${sValues}[3]')[0])    re
    ${serverPort2}    Evaluate    int(re.split('[/]', '${sValues}[3]')[1])    re
    Set To Dictionary    ${obj}    clientIpFormat=${cValues}[0]    clientIp1=${cValues}[1]    clientIp2=${cValues}[2]    clientPortFormat=range    clientPort1=${clientPort1}    clientPort2=${clientPort2}                    
    Set To Dictionary    ${obj}    serverIpFormat=${sValues}[0]    serverIp1=${sValues}[1]    serverIp2=${sValues}[2]    serverPortFormat=range    serverPort1=${serverPort1}    serverPort2=${serverPort2}                   
    
    OtherParams    ${sValues}    ${obj}
    [Return]    ${obj}
    
IpItemType4
    # IP类型4:range|192.168.40.1|192.168.40.50|80/88|1|itemName|itemDesc,...
    [Arguments]    ${str}
    ${obj}    Create Dictionary
    # 设置默认值
    Run Keyword If    ':' in '${str}'    Set To Dictionary    ${obj}    addrType=${6}
    ...    ELSE    Set To Dictionary    ${obj}    addrType=${4}     
    Set To Dictionary    ${obj}    protocol=${0}    direction=${0}    isSession=endpoint    
    
    ${cValues}    Evaluate    re.split('[|]', '${str}')    re
    ${clientPort1}    Evaluate    int(re.split('[/]', '${cValues}[3]')[0])    re
    ${clientPort2}    Evaluate    int(re.split('[/]', '${cValues}[3]')[1])    re
    Set To Dictionary    ${obj}    clientIpFormat=${cValues}[0]    clientIp1=${cValues}[1]    clientIp2=${cValues}[2]    clientPortFormat=range    clientPort1=${clientPort1}    clientPort2=${clientPort2}                    
    # 设置默认值
    Set To Dictionary    ${obj}    serverIpFormat=range    serverIp1=    serverIp2=    serverPortFormat=range    serverPort1=${0}    serverPort2=${0}
    
    OtherParams    ${cValues}    ${obj}
    [Return]    ${obj}

AnalysisStrItem
    [Arguments]    ${str}    ${flag}
    ${obj}    Create Dictionary        
    ${list}    Evaluate    re.split('[|]', '${str}')    re
    # keywordArray
    ${keywords}    KeywordsForEach    ${list}[0]
    Set To Dictionary    ${obj}    keywordArray=${keywords}
    # district
    Run Keyword If    '${flag}'=='${True}'    Set To Dictionary    ${obj}    district=${list}[1]
    ${index}    Run Keyword If    '${flag}'=='${True}'    Set Variable    ${2}
                ...    ELSE    Set Variable    ${1}           
    # isHexbin
    ${return}    ${isHexBin}    Run Keyword And Ignore Error    Convert To Integer    ${list}[${index}] 
    Run Keyword If    "${return}"!="FAIL" and "${isHexBin}"!="${EMPTY}"    Set To Dictionary    ${obj}    isHexbin=${isHexBin}    
    ...    ELSE    Set To Dictionary    ${obj}    isHexbin=${0}
    
    # isInitialize、itemName、itemDesc
    ${return}    ${isInitialize}    Run Keyword And Ignore Error    Convert To Integer    ${list}[${index+1}] 
    Run Keyword If    "${return}"!="FAIL" and "${isInitialize}"!="${EMPTY}"    Set To Dictionary    ${obj}    isInitialize=${isInitialize}
    ${return}    ${itemName}    Run Keyword And Ignore Error    Set Variable    ${list}[${index+2}]
    Run Keyword If    "${return}"!="FAIL" and "${itemName}"!="${EMPTY}"    Set To Dictionary    ${obj}    itemName=${itemName}
    ${return}    ${itemDesc}    Run Keyword And Ignore Error    Set Variable    ${list}[${index+3}]
    Run Keyword If    "${return}"!="FAIL" and "${itemDesc}"!="${EMPTY}"    Set To Dictionary    ${obj}    itemDesc=${itemDesc}
    [Return]    ${obj}

KeywordsForEach
    # 处理多关键字keyword1&keyword2&...
    [Arguments]    ${str}
    ${returnList}    Create List    
    ${list}    Evaluate    re.split('[&]', '${str}')    re
    FOR    ${var}    IN    @{list}
       Append To List     ${returnList}    ${var}
    END
    [Return]    ${returnList}

OtherParams
    [Documentation]
    ...    处理isInitialize、itemName、itemDesc参数
    [Arguments]    ${values}    ${obj}
    ${return}    ${isInitialize}    Run Keyword And Ignore Error    Convert To Integer    ${values}[4] 
    Run Keyword If    "${return}"!="FAIL" and "${isInitialize}"!="${EMPTY}"    Set To Dictionary    ${obj}    isInitialize=${isInitialize}
    ${return}    ${itemName}    Run Keyword And Ignore Error    Set Variable    ${values}[5]
    Run Keyword If    "${return}"!="FAIL" and "${itemName}"!="${EMPTY}"    Set To Dictionary    ${obj}    itemName=${itemName}
    ${return}    ${itemDesc}    Run Keyword And Ignore Error    Set Variable    ${values}[6]
    Run Keyword If    "${return}"!="FAIL" and "${itemDesc}"!="${EMPTY}"    Set To Dictionary    ${obj}    itemDesc=${itemDesc}
    
WanVpn
    [Arguments]    ${wanvpnlist}
    ${data}    Set Variable    "opAction":"add","returnData":1
    ${dict}=    Evaluate    eval ('{${data}}')
    ${data2}    set to dictionary    ${dict}    list=${wanvpnlist}
    ${json}    json.Dumps    ${data2}    ensure_ascii=False
    [Return]    ${json}

IpList
    [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}      
    # 编写iplist  json格式
    ${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
    #编写最外面的格式
    ${returnData}    evaluate    int(1)
    ${wan_nat_ip_pood_data}    Create Dictionary    opAction=${opAction}    returnData=${returnData}    list=${wan_nat_ip_list}
    # 返回请求json
    log    ${wan_nat_ip_pood_data}
    ${json}    json.Dumps    ${wan_nat_ip_pood_data}    ensure_ascii=False
    log    ${json}
    [Return]    ${json}


Index
    [Arguments]    ${list}    ${value}
    ${index}    evaluate    int(0)
    ${1}    evaluate    int(1)
    FOR    ${a}    IN    @{list}
        #${a}    Set Variable    ${a}
        log    ${a}
        ${index}    run Keyword if    '${a}'=='${value}'    log    ${index}
        ...    ELSE    Evaluate    ${index}+${1}   
        log    ${a}
    END

abcd
    [Arguments]    ${effectiveRange_list}    ${DataCenter}
    ${ab}    create list
    FOR    ${a}    IN    @{DataCenter}
        ${i}    index    ${effectiveRange_list}    ${a}
        Append To List    ${ab}    ${i}
    END
    [Return]    ${ab}  

IspJson    
    [Arguments]    ${isp_json}
    ${1}    Create List    ${isp_json}
    [Return]    ${1}  
    
LocationJson
    [Arguments]    ${location_json}
    ${2}    Create List    ${location_json}
    [Return]    ${2}  

LoccationAndIspJson   
    [Arguments]    ${location_json}     ${isp_json}
    ${3}    Create List    ${location_json}    ${isp_json}
    [Return]    ${3}
    

    
PacketCapture
    [Arguments]    ${PacketCapturedata}    ${DataCenter}    
    # 构建effectiveRange_tsg_sets
    ${effectiveRange_list_manu}    Create List        Almaty     
    ${DataCenter_length} =     Get Length    ${DataCenter}
    # ${isp_length} =     Get Length    ${isp}
    
    ${DataCenter_ids}    run keyword if    ${DataCenter_length}==0    abcd    ${effectiveRange_list_manu}    ${DataCenter}  
    ...    ELSE   abcd    ${effectiveRange_list_manu}    ${DataCenter}
    log    ${DataCenter_ids}   
    ${DataCenter_json}    Create Dictionary    tag=data_center    value=${DataCenter}    ids=${DataCenter_ids}
    
    # ${isp_ids}    run keyword if    ${isp_length}==0    abcd    ${effectiveRange_list_manu}    ${isp}    
    # ...    ELSE   abcd    ${effectiveRange_list_manu}    ${isp}
    # log    ${isp}    
    # ${isp_json}    Create Dictionary    tag=isp    value=${isp}    ids=${isp_ids}

    ${tag_sets_2}    Create List    ${DataCenter_json}  
    ${tag_sets}    Create List    ${tag_sets_2}  
    ${effectiveRange}    Create Dictionary    tag_sets=${tag_sets}
    # 编写iplist  json格式
    log    ${PacketCapturedata}
    # 构建PolicyList
    ${addrType}    evaluate    int(${PacketCapturedata}[addrType])
    ${protocol}    evaluate    int(${PacketCapturedata}[protocol])
    ${second}    Set Variable    ${3600}   
    ${captureDuration1}    evaluate    int(${PacketCapturedata}[captureDuration])
    ${captureDuration}    evaluate    ${captureDuration1}*${second}
    log    ${captureDuration}
    ${policyListDict}    Create Dictionary
    ...    policyId=${PacketCapturedata}[policyId]
    ...    policyName=${PacketCapturedata}[policyName]
    ...    addrType=${addrType}
    ...    protocol=${protocol}
    ...    clientIp=${PacketCapturedata}[clientIp]
    ...    clientPort=${PacketCapturedata}[clientPort]
    ...    serverIp=${PacketCapturedata}[serverIp]
    ...    serverPort=${PacketCapturedata}[serverPort]
    ...    maxPacket=${PacketCapturedata}[maxPacket]
    ...    captureDuration=${captureDuration}
    ...    effectiveRange=${effectiveRange}
    log    ${policyListDict}
    ${policyList}    Create List    ${policyListDict}
    # 判断json是用于修改还是新增
    ${opAction}    run keyword if    '${PacketCapturedata}[policyId]'==""    Set Variable    add
    ...    ELSE    Set Variable    update
    #编写最外面的格式
    ${returnData}    evaluate    int(1)
    ${PacketCapture}    Create Dictionary    opAction=${opAction}    returnData=${returnData}    policyList=${policyList}
    # 返回请求json
    log    ${PacketCapture}
    ${json}    json.Dumps    ${PacketCapture}    ensure_ascii=False
    log    111111111111${json}
    [Return]    ${json}