Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / libraries / VtnMaKeywords.robot
1 *** Settings ***
2 Library         SSHLibrary
3 Library         String
4 Library         DateTime
5 Library         Collections
6 Library         json
7 Library         RequestsLibrary
8 Variables       ../variables/Variables.py
9 Variables       ../variables/vtn/Modules.py
10 Resource        ./Utils.robot
11 Resource        ./KarafKeywords.robot
12 Resource        ./MininetKeywords.robot
13 Resource        ./TemplatedRequests.robot
14 Resource        DataModels.robot
15
16
17 *** Variables ***
18 ${vlan_topo}                    --custom vlan_vtn_test.py --topo vlantopo
19 ${VERSION_VTN}                  controller/nb/v2/vtn/version
20 ${VTN_INVENTORY}                restconf/operational/vtn-inventory:vtn-nodes
21 ${ENTITY_OWNERS}                restconf/operational/entity-owners:entity-owners
22 ${DUMPFLOWS_OF10}               dpctl dump-flows -OOpenFlow10
23 ${DUMPFLOWS_OF13}               dpctl dump-flows -OOpenFlow13
24 ${FF_DUMPFLOWS_OF10}            sh ovs-ofctl dump-flows -OOpenFlow10 s3
25 ${FF_DUMPFLOWS_OF13}            sh ovs-ofctl dump-flows -OOpenFlow13 s3
26 ${DROP_DUMPFLOWS_OF10}          sh ovs-ofctl dump-flows -OOpenFlow10 s2
27 ${DROP_DUMPFLOWS_OF13}          sh ovs-ofctl dump-flows -OOpenFlow13 s2
28 ${DROP_OUT_DUMPFLOWS_OF10}      sh ovs-ofctl dump-flows -OOpenFlow10 s3
29 ${DROP_OUT_DUMPFLOWS_OF13}      sh ovs-ofctl dump-flows -OOpenFlow13 s3
30 ${FF_OUT_DUMPFLOWS_OF10}        sh ovs-ofctl dump-flows -OOpenFlow10 s2
31 ${FF_OUT_DUMPFLOWS_OF13}        sh ovs-ofctl dump-flows -OOpenFlow13 s2
32 ${index}                        7
33 @{inet_actions}                 mod_nw_src:192.0.0.1    mod_nw_dst:192.0.0.2
34 @{BRIDGE1_DATAFLOW}
35 ...                             "reason":"PORTMAPPED"
36 ...                             "tenant-name":"Tenant1"
37 ...                             "bridge-name":"vBridge1"
38 ...                             "interface-name":"if2"
39 @{BRIDGE2_DATAFLOW}
40 ...                             "reason":"PORTMAPPED"
41 ...                             "tenant-name":"Tenant1"
42 ...                             "bridge-name":"vBridge2"
43 ...                             "interface-name":"if3"
44 ${vlanmap_bridge1}              200
45 ${vlanmap_bridge2}              300
46 @{VLANMAP_BRIDGE1_DATAFLOW}     "reason":"VLANMAPPED"    "tenant-name":"Tenant1"    "bridge-name":"vBridge1_vlan"
47 @{VLANMAP_BRIDGE2_DATAFLOW}     "reason":"VLANMAPPED"    "tenant-name":"Tenant1"    "bridge-name":"vBridge2_vlan"
48 ${out_before_pathpolicy}        output:2
49 ${out_after_pathpolicy}         output:3
50 ${pathpolicy_topo}              --custom topo-3sw-2host_multipath.py --topo pathpolicytopo
51 @{PATHMAP_ATTR}                 "index":"1"    "condition":"flowcond_path"    "policy":"1"
52 ${policy_id}                    1
53 ${in_port}                      1
54 ${filter_index}                 1
55 @{inet_action}                  set_field:192.0.0.1->ip_src    set_field:192.0.0.2->ip_dst
56 ${dscp_action}                  set_field:32->ip_dscp
57 ${dscp_be_action}               set_field:32->nw_tos_shifted
58 ${dscp_flow}                    mod_nw_tos:128
59 @{icmp_action}                  mod_tp_dst:1    mod_tp_src:3
60 ${drop_action}                  actions=drop
61 ${vlanpcp_action}               mod_vlan_pcp:6
62 ${vlanpcp_actions}              set_field:6->vlan_pcp
63 ${dlsrc_action}                 mod_dl_src:00:00:00:00:00:11
64 ${dlsrc_actions}                set_field:00:00:00:00:00:11->eth_src
65 @{PATHPOLICY_ATTR}              "id":1    "port-desc":"openflow:4,2,s4-eth2"
66 ${custom}                       ${CURDIR}/${CREATE_PATHPOLICY_TOPOLOGY_FILE_PATH}
67
68
69 *** Keywords ***
70 Start SuiteVtnMa
71     [Documentation]    Start VTN Manager Rest Config Api Test Suite, and enabling karaf loglevel as TRACE for VTN.
72     #Issue Command On Karaf Console    log:set TRACE org.opendaylight.vtn
73     ${vtn_mgr_id}=    SSHLibrary.Open Connection    ${ODL_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=30s
74     Set Suite Variable    ${vtn_mgr_id}
75     SSHLibrary.Login_With_Public_Key    ${ODL_SYSTEM_USER}    ${USER_HOME}/.ssh/${SSH_KEY}    any
76     SSHLibrary.Execute Command
77     ...    sudo sed -i "$ i log4j.logger.org.opendaylight.vtn = TRACE" ${WORKSPACE}/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
78     Create Session
79     ...    session
80     ...    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
81     ...    auth=${AUTH}
82     ...    headers=${HEADERS_YANG_JSON}
83     BuiltIn.Wait_Until_Keyword_Succeeds    30    3    Fetch vtn list
84     Start Mininet
85
86 Start SuiteVtnMaTest
87     [Documentation]    Start VTN Manager Test Suite
88     Create Session
89     ...    session
90     ...    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
91     ...    auth=${AUTH}
92     ...    headers=${HEADERS_YANG_JSON}
93
94 Stop SuiteVtnMa
95     [Documentation]    Stop VTN Manager Test Suite
96     Delete All Sessions
97
98 Stop SuiteVtnMaTest
99     [Documentation]    Stop VTN Manager Test Suite
100     Delete All Sessions
101
102 Fetch vtn list
103     [Documentation]    Check if VTN Manager is up.
104     ${resp}=    RequestsLibrary.GET On Session    session    restconf/operational/vtn:vtns    expected_status=200
105
106 Fetch vtn switch inventory
107     [Documentation]    Check if Switch is detected.
108     [Arguments]    ${sw_name}
109     ${resp}=    RequestsLibrary.GET On Session
110     ...    session
111     ...    restconf/operational/vtn-inventory:vtn-nodes/vtn-node/${sw_name}    expected_status=200
112
113 Collect Debug Info
114     [Documentation]    Check if Switch is detected.
115     write    ${DUMPFLOWS_OF10}
116     ${result}=    Read Until    mininet>
117     write    ${DUMPFLOWS_OF13}
118     ${result}=    Read Until    mininet>
119     Get Model Dump    ${ODL_SYSTEM_IP}    ${vtn_data_models}
120
121 Add a Topology wait
122     [Documentation]    Add a topology wait to complete all Inter-switch link connection of switches
123     [Arguments]    ${topo_wait}
124     ${resp}=    RequestsLibrary.Put Request
125     ...    session
126     ...    restconf/config/vtn-config:vtn-config
127     ...    data={"vtn-config": {"topology-wait":${topo_wait}, "host-tracking": "true"}}
128     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
129
130 Add a Vtn
131     [Documentation]    Create a vtn with specified parameters.
132     [Arguments]    ${vtn_name}
133     ${resp}=    RequestsLibrary.Post Request
134     ...    session
135     ...    restconf/operations/vtn:update-vtn
136     ...    data={"input": {"tenant-name":${vtn_name}, "update-mode": "CREATE","operation": "SET", "description": "creating vtn", "idle-timeout":300, "hard-timeout":0}}
137     Should Be Equal As Strings    ${resp.status_code}    200
138
139 Add a vBridge
140     [Documentation]    Create a vBridge in a VTN
141     [Arguments]    ${vtn_name}    ${vbr_name}
142     ${resp}=    RequestsLibrary.Post Request
143     ...    session
144     ...    restconf/operations/vtn-vbridge:update-vbridge
145     ...    data={"input": {"update-mode": "CREATE","operation":"SET", "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "description": "vbrdige created"}}
146     Should Be Equal As Strings    ${resp.status_code}    200
147
148 Add a interface
149     [Documentation]    Create a interface into a vBridge of a VTN
150     [Arguments]    ${vtn_name}    ${vbr_name}    ${interface_name}
151     ${resp}=    RequestsLibrary.Post Request
152     ...    session
153     ...    restconf/operations/vtn-vinterface:update-vinterface
154     ...    data={"input": {"update-mode":"CREATE","operation":"SET", "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "description": "vbrdige interfacecreated", "enabled":"true", "interface-name": ${interface_name}}}
155     Should Be Equal As Strings    ${resp.status_code}    200
156
157 Add a portmap
158     [Documentation]    Create a portmap for a interface of a vbridge
159     [Arguments]    ${vtn_name}    ${vbr_name}    ${interface_name}    ${node_id}    ${port_id}
160     ${resp}=    RequestsLibrary.Post Request
161     ...    session
162     ...    restconf/operations/vtn-port-map:set-port-map
163     ...    data={"input": { "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "interface-name": ${interface_name}, "node":"${node_id}", "port-name":"${port_id}"}}
164     Should Be Equal As Strings    ${resp.status_code}    200
165
166 Delete a Vtn
167     [Documentation]    Delete a vtn with specified parameters.
168     [Arguments]    ${vtn_name}
169     ${resp}=    RequestsLibrary.Post Request
170     ...    session
171     ...    restconf/operations/vtn:remove-vtn
172     ...    data={"input": {"tenant-name":${vtn_name}}}
173     Should Be Equal As Strings    ${resp.status_code}    200
174
175 Add a vlanmap
176     [Documentation]    Create a vlanmap
177     [Arguments]    ${vtn_name}    ${vbr_name}    ${vlan_id}
178     ${resp}=    RequestsLibrary.Post Request
179     ...    session
180     ...    restconf/operations/vtn-vlan-map:add-vlan-map
181     ...    data={"input": {"tenant-name":${vtn_name},"bridge-name":${vbr_name},"vlan-id":${vlan_id}}}
182     Should Be Equal As Strings    ${resp.status_code}    200
183
184 Verify Data Flows
185     [Documentation]    Verify the reason and physical data flows for the specified vtn and vbridge
186     [Arguments]    ${vtn_name}    ${vBridge_name}
187     ${resp}=    RequestsLibrary.Post Request
188     ...    session
189     ...    restconf/operations/vtn-flow:get-data-flow
190     ...    data={"input":{"tenant-name":"${vtn_name}","mode":"UPDATESTATS"}}
191     IF    '${vBridge_name}' == 'vBridge1'
192         DataFlowsForBridge    ${resp}    @{BRIDGE1_DATAFLOW}
193     ELSE IF    '${vBridge_name}' == 'vBridge2'
194         DataFlowsForBridge    ${resp}    @{BRIDGE2_DATAFLOW}
195     ELSE IF    '${vBridge_name}' == 'vBridge1_vlan'
196         DataFlowsForBridge    ${resp}    @{VLANMAP_BRIDGE1_DATAFLOW}
197     ELSE
198         DataFlowsForBridge    ${resp}    @{VLANMAP_BRIDGE2_DATAFLOW}
199     END
200
201 Start PathSuiteVtnMaTest
202     [Documentation]    Start VTN Manager Test Suite and Mininet
203     Start SuiteVtnMaTest
204     MininetKeywords.Start Mininet Single Controller
205     ...    ${TOOLS_SYSTEM_IP}
206     ...    ${ODL_SYSTEM_IP}
207     ...    ${pathpolicy_topo}
208     ...    ${custom}
209     ...    ofversion=13
210
211 Start PathSuiteVtnMaTestOF10
212     [Documentation]    Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
213     Start SuiteVtnMaTest
214     MininetKeywords.Start Mininet Single Controller
215     ...    ${TOOLS_SYSTEM_IP}
216     ...    ${ODL_SYSTEM_IP}
217     ...    ${pathpolicy_topo}
218     ...    ${custom}
219     ...    ofversion=10
220
221 Stop PathSuiteVtnMaTest
222     [Documentation]    Cleanup/Shutdown work at the completion of all tests.
223     Delete All Sessions
224     MininetKeywords.Stop Mininet And Exit
225
226 DataFlowsForBridge
227     [Documentation]    Verify whether the required attributes exists.
228     [Arguments]    ${resp}    @{BRIDGE_DATAFLOW}
229     FOR    ${dataflowElement}    IN    @{BRIDGE_DATAFLOW}
230         should Contain    ${resp.text}    ${dataflowElement}
231     END
232
233 Add a pathmap
234     [Documentation]    Create a pathmap for a vtn
235     [Arguments]    ${pathmap_data}
236     ${resp}=    RequestsLibrary.Post Request
237     ...    session
238     ...    restconf/operations/vtn-path-map:set-path-map
239     ...    data=${pathmap_data}
240     Should Be Equal As Strings    ${resp.status_code}    200
241
242 Get a pathmap
243     [Documentation]    Get a pathmap for a vtn.
244     ${resp}=    RequestsLibrary.GET On Session    session    restconf/operational/vtn-path-map:global-path-maps
245     FOR    ${pathElement}    IN    @{PATHMAP_ATTR}
246         should Contain    ${resp.text}    ${pathElement}
247     END
248
249 Add a pathpolicy
250     [Documentation]    Create a pathpolicy for a vtn
251     [Arguments]    ${pathpolicy_data}
252     ${resp}=    RequestsLibrary.Post Request
253     ...    session
254     ...    restconf/operations/vtn-path-policy:set-path-policy
255     ...    data=${pathpolicy_data}
256     Should Be Equal As Strings    ${resp.status_code}    200
257
258 Get a pathpolicy
259     [Documentation]    Get a pathpolicy for a vtn.
260     [Arguments]    ${pathpolicy_id}
261     ${resp}=    RequestsLibrary.GET On Session
262     ...    session
263     ...    restconf/operational/vtn-path-policy:vtn-path-policies/vtn-path-policy/${pathpolicy_id}
264     FOR    ${pathpolicyElement}    IN    @{PATHPOLICY_ATTR}
265         should Contain    ${resp.text}    ${pathpolicyElement}
266     END
267
268 Delete a pathmap
269     [Documentation]    Remove a pathmap for a vtn
270     [Arguments]    ${tenant_path}
271     ${resp}=    RequestsLibrary.Post Request
272     ...    session
273     ...    restconf/operations/vtn-path-map:remove-path-map
274     ...    data={"input":{"tenant-name":"${tenant_path}","map-index":["${policy_id}"]}}
275     Should Be Equal As Strings    ${resp.status_code}    200
276
277 Delete a pathpolicy
278     [Documentation]    Delete a pathpolicy for a vtn
279     [Arguments]    ${policy_id}
280     ${resp}=    RequestsLibrary.Post Request
281     ...    session
282     ...    restconf/operations/vtn-path-policy:remove-path-policy
283     ...    data={"input":{"id":"${policy_id}"}}
284     Should Be Equal As Strings    ${resp.status_code}    200
285
286 Verify flowEntryPathPolicy
287     [Documentation]    Checking Flows on switch S1 and switch S3 after applying path policy
288     [Arguments]    ${of_version}    ${port}    ${output}
289     ${DUMPFLOWS}=    Set Variable If    "${of_version}"=="OF10"    ${DUMPFLOWS_OF10}    ${DUMPFLOWS_OF13}
290     write    ${DUMPFLOWS}
291     ${result}=    Read Until    mininet>
292     Should Contain    ${result}    in_port=${port}    actions=${output}
293
294 Add a macmap
295     [Documentation]    Create a macmap for a vbridge
296     [Arguments]    ${vtn_name}    ${vBridge_name}    ${src_add}    ${dst_add}
297     ${resp}=    RequestsLibrary.Post Request
298     ...    session
299     ...    restconf/operations/vtn-mac-map:set-mac-map
300     ...    data={"input":{"operation":"SET","allowed-hosts":["${dst_add}@0","${src_add}@0"],"tenant-name":"${vtn_name}","bridge-name":"${vBridge_name}"}}
301     Should Be Equal As Strings    ${resp.status_code}    200
302
303 Get DynamicMacAddress
304     [Documentation]    Get Dynamic mac address of Host
305     [Arguments]    ${h}
306     write    ${h} ifconfig -a | grep HWaddr
307     ${source}=    Read Until    mininet>
308     ${HWaddress}=    Split String    ${source}    ${SPACE}
309     ${sourceHWaddr}=    Get from List    ${HWaddress}    ${index}
310     ${sourceHWaddress}=    Convert To Lowercase    ${sourceHWaddr}
311     RETURN    ${sourceHWaddress}    # Also [Return] would work here.
312
313 Mininet Ping Should Succeed
314     [Documentation]    Ping hosts to check connectivity
315     [Arguments]    ${host1}    ${host2}
316     Write    ${host1} ping -c 1 ${host2}
317     ${result}=    Read Until    mininet>
318     Should Contain    ${result}    64 bytes
319
320 Mininet Ping Should Not Succeed
321     [Documentation]    Ping hosts when there is no connectivity and check hosts is unreachable
322     [Arguments]    ${host1}    ${host2}
323     Write    ${host1} ping -c 3 ${host2}
324     ${result}=    Read Until    mininet>
325     Should Not Contain    ${result}    64 bytes
326
327 Start vlan_topo
328     [Documentation]    Create custom topology for vlan functionality
329     [Arguments]    ${OF}
330     Install Package On Ubuntu System    vlan
331     IF    '${OF}' == 'OF13'
332         MininetKeywords.Start Mininet Single Controller
333         ...    ${TOOLS_SYSTEM_IP}
334         ...    ${ODL_SYSTEM_IP}
335         ...    ${vlan_topo}
336         ...    ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
337         ...    ofversion=13
338     ELSE IF    '${OF}' == 'OF10'
339         MininetKeywords.Start Mininet Single Controller
340         ...    ${TOOLS_SYSTEM_IP}
341         ...    ${ODL_SYSTEM_IP}
342         ...    ${vlan_topo}
343         ...    ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
344         ...    ofversion=10
345     END
346
347 Get flow
348     [Documentation]    Get data flow.
349     [Arguments]    ${vtn_name}
350     ${resp}=    RequestsLibrary.GET On Session
351     ...    session
352     ...    restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
353     ...    expected_status=200
354
355 Remove a portmap
356     [Documentation]    Remove a portmap for a interface of a vbridge
357     [Arguments]    ${vtn_name}    ${vBridge_name}    ${interface_name}
358     ${resp}=    RequestsLibrary.Post Request
359     ...    session
360     ...    restconf/operations/vtn-port-map:remove-port-map
361     ...    data={"input": {"tenant-name":${vtn_name},"bridge-name":${vBridge_name},"interface-name":${interface_name}}}
362     Should Be Equal As Strings    ${resp.status_code}    200
363
364 Verify FlowMacAddress
365     [Documentation]    Verify the source and destination mac address.
366     [Arguments]    ${host1}    ${host2}    ${OF_VERSION}
367     IF    '${OF_VERSION}' == 'OF10'
368         Verify Flows On OpenFlow    ${host1}    ${host2}    ${FF_DUMPFLOWS_OF10}
369     ELSE
370         VerifyFlowsOnOpenFlow    ${host1}    ${host2}    ${FF_DUMPFLOWS_OF13}
371     END
372
373 Verify Flows On OpenFlow
374     [Documentation]    Verify the mac addresses on the specified open flow.
375     [Arguments]    ${host1}    ${host2}    ${DUMPFLOWS}
376     ${booleanValue}=    Run Keyword And Return Status    Verify macaddress    ${host1}    ${host2}    ${DUMPFLOWS}
377     Should Be Equal As Strings    ${booleanValue}    True
378
379 Verify RemovedFlowMacAddress
380     [Documentation]    Verify the removed source and destination mac address.
381     [Arguments]    ${host1}    ${host2}    ${OF_VERSION}
382     IF    '${OF_VERSION}' == 'OF10'
383         Verify Removed Flows On OpenFlow    ${host1}    ${host2}    ${FF_DUMPFLOWS_OF10}
384     ELSE
385         Verify Removed Flows On OpenFlow    ${host1}    ${host2}    ${FF_DUMPFLOWS_OF13}
386     END
387
388 Verify Removed Flows On OpenFlow
389     [Documentation]    Verify the removed mac addresses on the specified open flow.
390     [Arguments]    ${host1}    ${host2}    ${DUMPFLOWS}
391     ${booleanValue}=    Run Keyword And Return Status    Verify macaddress    ${host1}    ${host2}    ${DUMPFLOWS}
392     Should Not Be Equal As Strings    ${booleanValue}    True
393
394 Verify macaddress
395     [Documentation]    Verify the source and destination mac address after ping in the dumpflows
396     [Arguments]    ${host1}    ${host2}    ${DUMPFLOWS}
397     write    ${host1} ifconfig -a | grep HWaddr
398     ${sourcemacaddr}=    Read Until    mininet>
399     ${macaddress}=    Split String    ${sourcemacaddr}    ${SPACE}
400     ${sourcemacaddr}=    Get from List    ${macaddress}    ${index}
401     ${sourcemacaddress}=    Convert To Lowercase    ${sourcemacaddr}
402     write    ${host2} ifconfig -a | grep HWaddr
403     ${destmacaddr}=    Read Until    mininet>
404     ${macaddress}=    Split String    ${destmacaddr}    ${SPACE}
405     ${destmacaddr}=    Get from List    ${macaddress}    ${index}
406     ${destmacaddress}=    Convert To Lowercase    ${destmacaddr}
407     write    ${DUMPFLOWS}
408     ${result}=    Read Until    mininet>
409     Should Contain    ${result}    ${sourcemacaddress}
410     Should Contain    ${result}    ${destmacaddress}
411
412 Verify flowactions
413     [Documentation]    Verify the flowfilter actions after ping in the dumpflows
414     [Arguments]    ${actions}    ${DUMPFLOWS}
415     write    ${DUMPFLOWS}
416     ${result}=    Read Until    mininet>
417     Should Contain    ${result}    ${actions}
418
419 Add a vtn flowfilter
420     [Documentation]    Create a flowfilter for a vtn
421     [Arguments]    ${vtn_name}    ${vtnflowfilter_data}
422     ${resp}=    RequestsLibrary.Post Request
423     ...    session
424     ...    restconf/operations/vtn-flow-filter:set-flow-filter
425     ...    data={"input": {"tenant-name": "${vtn_name}",${vtnflowfilter_data}}}
426     Should Be Equal As Strings    ${resp.status_code}    200
427
428 Remove a vtn flowfilter
429     [Documentation]    Delete a vtn flowfilter
430     [Arguments]    ${vtn_name}    ${filter_index}
431     ${resp}=    RequestsLibrary.Post Request
432     ...    session
433     ...    restconf/operations/vtn-flow-filter:remove-flow-filter
434     ...    data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}"}}
435     Should Be Equal As Strings    ${resp.status_code}    200
436
437 Add a vbr flowfilter
438     [Documentation]    Create a flowfilter for a vbr
439     [Arguments]    ${vtn_name}    ${vBridge_name}    ${vbrflowfilter_data}
440     ${resp}=    RequestsLibrary.Post Request
441     ...    session
442     ...    restconf/operations/vtn-flow-filter:set-flow-filter
443     ...    data={"input": {"tenant-name": "${vtn_name}", "bridge-name": "${vBridge_name}", ${vbrflowfilter_data}}}
444     Should Be Equal As Strings    ${resp.status_code}    200
445
446 Remove a vbr flowfilter
447     [Documentation]    Delete a vbr flowfilter
448     [Arguments]    ${vtn_name}    ${vBridge_name}    ${filter_index}
449     ${resp}=    RequestsLibrary.Post Request
450     ...    session
451     ...    restconf/operations/vtn-flow-filter:remove-flow-filter
452     ...    data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}","bridge-name": "${vBridge_name}"}}
453     Should Be Equal As Strings    ${resp.status_code}    200
454
455 Add a vbrif flowfilter
456     [Documentation]    Create a flowfilter for a vbrif
457     [Arguments]    ${vtn_name}    ${vBridge_name}    ${interface_name}    ${vbrif_flowfilter_data}
458     ${resp}=    RequestsLibrary.Post Request
459     ...    session
460     ...    restconf/operations/vtn-flow-filter:set-flow-filter
461     ...    data={"input": {"tenant-name": ${vtn_name}, "bridge-name": "${vBridge_name}","interface-name":"${interface_name}",${vbrif_flowfilter_data}}}
462     Should Be Equal As Strings    ${resp.status_code}    200
463
464 Remove a vbrif flowfilter
465     [Documentation]    Delete a vbrif flowfilter
466     [Arguments]    ${vtn_name}    ${vBridge_name}    ${interface_name}    ${filter_index}
467     ${resp}=    RequestsLibrary.Post Request
468     ...    session
469     ...    restconf/operations/vtn-flow-filter:remove-flow-filter
470     ...    data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}","bridge-name": "${vBridge_name}","interface-name": "${interface_name}"}}
471     Should Be Equal As Strings    ${resp.status_code}    200
472
473 Add a vlan portmap
474     [Documentation]    Create a portmap for a interface of a vbridge
475     [Arguments]    ${vtn_name}    ${vbr_name}    ${interface_name}    ${id}    ${node_id}    ${port_id}
476     ${resp}=    RequestsLibrary.Post Request
477     ...    session
478     ...    restconf/operations/vtn-port-map:set-port-map
479     ...    data={"input": { "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "interface-name": ${interface_name}, "vlan-id": ${id}, "node":"${node_id}", "port-name":"${port_id}"}}
480     Should Be Equal As Strings    ${resp.status_code}    200
481
482 Verify Flow Entries for Flowfilter
483     [Documentation]    Verify switch flow entry using flowfilter for a vtn
484     [Arguments]    ${dumpflows}    @{flowfilter_actions}
485     ${booleanValue}=    Run Keyword And Return Status
486     ...    Verify Actions on Flow Entry
487     ...    ${dumpflows}
488     ...    @{flowfilter_actions}
489     Should Be Equal As Strings    ${booleanValue}    True
490
491 Verify Removed Flow Entry for Inet Drop Flowfilter
492     [Documentation]    Verify removed switch flow entry using flowfilter drop for a vtn
493     [Arguments]    ${dumpflows}    @{flowfilter_actions}
494     ${booleanValue}=    Run Keyword And Return Status
495     ...    Verify Actions on Flow Entry
496     ...    ${dumpflows}
497     ...    @{flowfilter_actions}
498     Should Be Equal As Strings    ${booleanValue}    True
499
500 Verify Actions on Flow Entry
501     [Documentation]    check flow action elements by giving dumpflows in mininet
502     [Arguments]    ${dumpflows}    @{flowfilter_actions}
503     write    ${dumpflows}
504     ${result}=    Read Until    mininet>
505     FOR    ${flowElement}    IN    @{flowfilter_actions}
506         should Contain    ${result}    ${flowElement}
507     END
508
509 Add a flowcondition
510     [Documentation]    Create a flowcondition using Restconfig Api
511     [Arguments]    ${flowcond_name}    ${flowconditiondata}
512     ${resp}=    RequestsLibrary.Post Request
513     ...    session
514     ...    restconf/operations/vtn-flow-condition:set-flow-condition
515     ...    data={"input":{"operation":"SET","present":"false","name":"${flowcond_name}",${flowconditiondata}}}
516     Should Be Equal As Strings    ${resp.status_code}    200
517
518 Get flowconditions
519     [Documentation]    Retrieve the list of flowconditions created
520     ${resp}=    RequestsLibrary.Get On Session
521     ...    session
522     ...    restconf/operational/vtn-flow-condition:vtn-flow-conditions
523     ...    expected_status=200
524
525 Get flowcondition
526     [Documentation]    Retrieve the flowcondition by name and to check the removed flowcondition we added "retrieve" argument to differentiate the status code,
527     ...    since after removing flowcondition name the status will be different compare to status code when the flowcondition name is present.
528     [Arguments]    ${flowcond_name}    ${retrieve}
529     ${resp}=    RequestsLibrary.GET On Session
530     ...    session
531     ...    restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
532     ...    expected_status=anything
533     IF    '${retrieve}' == 'retrieve'
534         Should Be Equal As Strings    ${resp.status_code}    200
535     ELSE
536         Should Not Be Equal As Strings    ${resp.status_code}    200
537     END
538
539 Remove flowcondition
540     [Documentation]    Remove the flowcondition by name
541     [Arguments]    ${flowcond_name}
542     ${resp}=    RequestsLibrary.Post Request
543     ...    session
544     ...    restconf/operations/vtn-flow-condition:remove-flow-condition
545     ...    data={"input":{"name":"${flowcond_name}"}}
546     Should Be Equal As Strings    ${resp.status_code}    200