Correctly space expected_status
[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 Request    session    restconf/operational/vtn:vtns
105     Should Be Equal As Strings    ${resp.status_code}    200
106
107 Fetch vtn switch inventory
108     [Documentation]    Check if Switch is detected.
109     [Arguments]    ${sw_name}
110     ${resp}=    RequestsLibrary.Get Request
111     ...    session
112     ...    restconf/operational/vtn-inventory:vtn-nodes/vtn-node/${sw_name}
113     Should Be Equal As Strings    ${resp.status_code}    200
114
115 Collect Debug Info
116     [Documentation]    Check if Switch is detected.
117     write    ${DUMPFLOWS_OF10}
118     ${result}=    Read Until    mininet>
119     write    ${DUMPFLOWS_OF13}
120     ${result}=    Read Until    mininet>
121     Get Model Dump    ${ODL_SYSTEM_IP}    ${vtn_data_models}
122
123 Add a Topology wait
124     [Documentation]    Add a topology wait to complete all Inter-switch link connection of switches
125     [Arguments]    ${topo_wait}
126     ${resp}=    RequestsLibrary.Put Request
127     ...    session
128     ...    restconf/config/vtn-config:vtn-config
129     ...    data={"vtn-config": {"topology-wait":${topo_wait}, "host-tracking": "true"}}
130     Should Contain    ${ALLOWED_STATUS_CODES}    ${resp.status_code}
131
132 Add a Vtn
133     [Documentation]    Create a vtn with specified parameters.
134     [Arguments]    ${vtn_name}
135     ${resp}=    RequestsLibrary.Post Request
136     ...    session
137     ...    restconf/operations/vtn:update-vtn
138     ...    data={"input": {"tenant-name":${vtn_name}, "update-mode": "CREATE","operation": "SET", "description": "creating vtn", "idle-timeout":300, "hard-timeout":0}}
139     Should Be Equal As Strings    ${resp.status_code}    200
140
141 Add a vBridge
142     [Documentation]    Create a vBridge in a VTN
143     [Arguments]    ${vtn_name}    ${vbr_name}
144     ${resp}=    RequestsLibrary.Post Request
145     ...    session
146     ...    restconf/operations/vtn-vbridge:update-vbridge
147     ...    data={"input": {"update-mode": "CREATE","operation":"SET", "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "description": "vbrdige created"}}
148     Should Be Equal As Strings    ${resp.status_code}    200
149
150 Add a interface
151     [Documentation]    Create a interface into a vBridge of a VTN
152     [Arguments]    ${vtn_name}    ${vbr_name}    ${interface_name}
153     ${resp}=    RequestsLibrary.Post Request
154     ...    session
155     ...    restconf/operations/vtn-vinterface:update-vinterface
156     ...    data={"input": {"update-mode":"CREATE","operation":"SET", "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "description": "vbrdige interfacecreated", "enabled":"true", "interface-name": ${interface_name}}}
157     Should Be Equal As Strings    ${resp.status_code}    200
158
159 Add a portmap
160     [Documentation]    Create a portmap for a interface of a vbridge
161     [Arguments]    ${vtn_name}    ${vbr_name}    ${interface_name}    ${node_id}    ${port_id}
162     ${resp}=    RequestsLibrary.Post Request
163     ...    session
164     ...    restconf/operations/vtn-port-map:set-port-map
165     ...    data={"input": { "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "interface-name": ${interface_name}, "node":"${node_id}", "port-name":"${port_id}"}}
166     Should Be Equal As Strings    ${resp.status_code}    200
167
168 Delete a Vtn
169     [Documentation]    Delete a vtn with specified parameters.
170     [Arguments]    ${vtn_name}
171     ${resp}=    RequestsLibrary.Post Request
172     ...    session
173     ...    restconf/operations/vtn:remove-vtn
174     ...    data={"input": {"tenant-name":${vtn_name}}}
175     Should Be Equal As Strings    ${resp.status_code}    200
176
177 Add a vlanmap
178     [Documentation]    Create a vlanmap
179     [Arguments]    ${vtn_name}    ${vbr_name}    ${vlan_id}
180     ${resp}=    RequestsLibrary.Post Request
181     ...    session
182     ...    restconf/operations/vtn-vlan-map:add-vlan-map
183     ...    data={"input": {"tenant-name":${vtn_name},"bridge-name":${vbr_name},"vlan-id":${vlan_id}}}
184     Should Be Equal As Strings    ${resp.status_code}    200
185
186 Verify Data Flows
187     [Documentation]    Verify the reason and physical data flows for the specified vtn and vbridge
188     [Arguments]    ${vtn_name}    ${vBridge_name}
189     ${resp}=    RequestsLibrary.Post Request
190     ...    session
191     ...    restconf/operations/vtn-flow:get-data-flow
192     ...    data={"input":{"tenant-name":"${vtn_name}","mode":"UPDATESTATS"}}
193     IF    '${vBridge_name}' == 'vBridge1'
194         DataFlowsForBridge    ${resp}    @{BRIDGE1_DATAFLOW}
195     ELSE IF    '${vBridge_name}' == 'vBridge2'
196         DataFlowsForBridge    ${resp}    @{BRIDGE2_DATAFLOW}
197     ELSE IF    '${vBridge_name}' == 'vBridge1_vlan'
198         DataFlowsForBridge    ${resp}    @{VLANMAP_BRIDGE1_DATAFLOW}
199     ELSE
200         DataFlowsForBridge    ${resp}    @{VLANMAP_BRIDGE2_DATAFLOW}
201     END
202
203 Start PathSuiteVtnMaTest
204     [Documentation]    Start VTN Manager Test Suite and Mininet
205     Start SuiteVtnMaTest
206     MininetKeywords.Start Mininet Single Controller
207     ...    ${TOOLS_SYSTEM_IP}
208     ...    ${ODL_SYSTEM_IP}
209     ...    ${pathpolicy_topo}
210     ...    ${custom}
211     ...    ofversion=13
212
213 Start PathSuiteVtnMaTestOF10
214     [Documentation]    Start VTN Manager Test Suite and Mininet in Open Flow 10 Specification
215     Start SuiteVtnMaTest
216     MininetKeywords.Start Mininet Single Controller
217     ...    ${TOOLS_SYSTEM_IP}
218     ...    ${ODL_SYSTEM_IP}
219     ...    ${pathpolicy_topo}
220     ...    ${custom}
221     ...    ofversion=10
222
223 Stop PathSuiteVtnMaTest
224     [Documentation]    Cleanup/Shutdown work at the completion of all tests.
225     Delete All Sessions
226     MininetKeywords.Stop Mininet And Exit
227
228 DataFlowsForBridge
229     [Documentation]    Verify whether the required attributes exists.
230     [Arguments]    ${resp}    @{BRIDGE_DATAFLOW}
231     FOR    ${dataflowElement}    IN    @{BRIDGE_DATAFLOW}
232         should Contain    ${resp.text}    ${dataflowElement}
233     END
234
235 Add a pathmap
236     [Documentation]    Create a pathmap for a vtn
237     [Arguments]    ${pathmap_data}
238     ${resp}=    RequestsLibrary.Post Request
239     ...    session
240     ...    restconf/operations/vtn-path-map:set-path-map
241     ...    data=${pathmap_data}
242     Should Be Equal As Strings    ${resp.status_code}    200
243
244 Get a pathmap
245     [Documentation]    Get a pathmap for a vtn.
246     ${resp}=    RequestsLibrary.Get Request    session    restconf/operational/vtn-path-map:global-path-maps
247     FOR    ${pathElement}    IN    @{PATHMAP_ATTR}
248         should Contain    ${resp.text}    ${pathElement}
249     END
250
251 Add a pathpolicy
252     [Documentation]    Create a pathpolicy for a vtn
253     [Arguments]    ${pathpolicy_data}
254     ${resp}=    RequestsLibrary.Post Request
255     ...    session
256     ...    restconf/operations/vtn-path-policy:set-path-policy
257     ...    data=${pathpolicy_data}
258     Should Be Equal As Strings    ${resp.status_code}    200
259
260 Get a pathpolicy
261     [Documentation]    Get a pathpolicy for a vtn.
262     [Arguments]    ${pathpolicy_id}
263     ${resp}=    RequestsLibrary.Get Request
264     ...    session
265     ...    restconf/operational/vtn-path-policy:vtn-path-policies/vtn-path-policy/${pathpolicy_id}
266     FOR    ${pathpolicyElement}    IN    @{PATHPOLICY_ATTR}
267         should Contain    ${resp.text}    ${pathpolicyElement}
268     END
269
270 Delete a pathmap
271     [Documentation]    Remove a pathmap for a vtn
272     [Arguments]    ${tenant_path}
273     ${resp}=    RequestsLibrary.Post Request
274     ...    session
275     ...    restconf/operations/vtn-path-map:remove-path-map
276     ...    data={"input":{"tenant-name":"${tenant_path}","map-index":["${policy_id}"]}}
277     Should Be Equal As Strings    ${resp.status_code}    200
278
279 Delete a pathpolicy
280     [Documentation]    Delete a pathpolicy for a vtn
281     [Arguments]    ${policy_id}
282     ${resp}=    RequestsLibrary.Post Request
283     ...    session
284     ...    restconf/operations/vtn-path-policy:remove-path-policy
285     ...    data={"input":{"id":"${policy_id}"}}
286     Should Be Equal As Strings    ${resp.status_code}    200
287
288 Verify flowEntryPathPolicy
289     [Documentation]    Checking Flows on switch S1 and switch S3 after applying path policy
290     [Arguments]    ${of_version}    ${port}    ${output}
291     ${DUMPFLOWS}=    Set Variable If    "${of_version}"=="OF10"    ${DUMPFLOWS_OF10}    ${DUMPFLOWS_OF13}
292     write    ${DUMPFLOWS}
293     ${result}=    Read Until    mininet>
294     Should Contain    ${result}    in_port=${port}    actions=${output}
295
296 Add a macmap
297     [Documentation]    Create a macmap for a vbridge
298     [Arguments]    ${vtn_name}    ${vBridge_name}    ${src_add}    ${dst_add}
299     ${resp}=    RequestsLibrary.Post Request
300     ...    session
301     ...    restconf/operations/vtn-mac-map:set-mac-map
302     ...    data={"input":{"operation":"SET","allowed-hosts":["${dst_add}@0","${src_add}@0"],"tenant-name":"${vtn_name}","bridge-name":"${vBridge_name}"}}
303     Should Be Equal As Strings    ${resp.status_code}    200
304
305 Get DynamicMacAddress
306     [Documentation]    Get Dynamic mac address of Host
307     [Arguments]    ${h}
308     write    ${h} ifconfig -a | grep HWaddr
309     ${source}=    Read Until    mininet>
310     ${HWaddress}=    Split String    ${source}    ${SPACE}
311     ${sourceHWaddr}=    Get from List    ${HWaddress}    ${index}
312     ${sourceHWaddress}=    Convert To Lowercase    ${sourceHWaddr}
313     RETURN    ${sourceHWaddress}    # Also [Return] would work here.
314
315 Mininet Ping Should Succeed
316     [Documentation]    Ping hosts to check connectivity
317     [Arguments]    ${host1}    ${host2}
318     Write    ${host1} ping -c 1 ${host2}
319     ${result}=    Read Until    mininet>
320     Should Contain    ${result}    64 bytes
321
322 Mininet Ping Should Not Succeed
323     [Documentation]    Ping hosts when there is no connectivity and check hosts is unreachable
324     [Arguments]    ${host1}    ${host2}
325     Write    ${host1} ping -c 3 ${host2}
326     ${result}=    Read Until    mininet>
327     Should Not Contain    ${result}    64 bytes
328
329 Start vlan_topo
330     [Documentation]    Create custom topology for vlan functionality
331     [Arguments]    ${OF}
332     Install Package On Ubuntu System    vlan
333     IF    '${OF}' == 'OF13'
334         MininetKeywords.Start Mininet Single Controller
335         ...    ${TOOLS_SYSTEM_IP}
336         ...    ${ODL_SYSTEM_IP}
337         ...    ${vlan_topo}
338         ...    ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
339         ...    ofversion=13
340     ELSE IF    '${OF}' == 'OF10'
341         MininetKeywords.Start Mininet Single Controller
342         ...    ${TOOLS_SYSTEM_IP}
343         ...    ${ODL_SYSTEM_IP}
344         ...    ${vlan_topo}
345         ...    ${CURDIR}/${CREATE_VLAN_TOPOLOGY_FILE_PATH}
346         ...    ofversion=10
347     END
348
349 Get flow
350     [Documentation]    Get data flow.
351     [Arguments]    ${vtn_name}
352     ${resp}=    RequestsLibrary.Get Request
353     ...    session
354     ...    restconf/operational/vtn-flow-impl:vtn-flows/vtn-flow-table/${vtn_name}
355     Should Be Equal As Strings    ${resp.status_code}    200
356
357 Remove a portmap
358     [Documentation]    Remove a portmap for a interface of a vbridge
359     [Arguments]    ${vtn_name}    ${vBridge_name}    ${interface_name}
360     ${resp}=    RequestsLibrary.Post Request
361     ...    session
362     ...    restconf/operations/vtn-port-map:remove-port-map
363     ...    data={"input": {"tenant-name":${vtn_name},"bridge-name":${vBridge_name},"interface-name":${interface_name}}}
364     Should Be Equal As Strings    ${resp.status_code}    200
365
366 Verify FlowMacAddress
367     [Documentation]    Verify the source and destination mac address.
368     [Arguments]    ${host1}    ${host2}    ${OF_VERSION}
369     IF    '${OF_VERSION}' == 'OF10'
370         Verify Flows On OpenFlow    ${host1}    ${host2}    ${FF_DUMPFLOWS_OF10}
371     ELSE
372         VerifyFlowsOnOpenFlow    ${host1}    ${host2}    ${FF_DUMPFLOWS_OF13}
373     END
374
375 Verify Flows On OpenFlow
376     [Documentation]    Verify the mac addresses on the specified open flow.
377     [Arguments]    ${host1}    ${host2}    ${DUMPFLOWS}
378     ${booleanValue}=    Run Keyword And Return Status    Verify macaddress    ${host1}    ${host2}    ${DUMPFLOWS}
379     Should Be Equal As Strings    ${booleanValue}    True
380
381 Verify RemovedFlowMacAddress
382     [Documentation]    Verify the removed source and destination mac address.
383     [Arguments]    ${host1}    ${host2}    ${OF_VERSION}
384     IF    '${OF_VERSION}' == 'OF10'
385         Verify Removed Flows On OpenFlow    ${host1}    ${host2}    ${FF_DUMPFLOWS_OF10}
386     ELSE
387         Verify Removed Flows On OpenFlow    ${host1}    ${host2}    ${FF_DUMPFLOWS_OF13}
388     END
389
390 Verify Removed Flows On OpenFlow
391     [Documentation]    Verify the removed mac addresses on the specified open flow.
392     [Arguments]    ${host1}    ${host2}    ${DUMPFLOWS}
393     ${booleanValue}=    Run Keyword And Return Status    Verify macaddress    ${host1}    ${host2}    ${DUMPFLOWS}
394     Should Not Be Equal As Strings    ${booleanValue}    True
395
396 Verify macaddress
397     [Documentation]    Verify the source and destination mac address after ping in the dumpflows
398     [Arguments]    ${host1}    ${host2}    ${DUMPFLOWS}
399     write    ${host1} ifconfig -a | grep HWaddr
400     ${sourcemacaddr}=    Read Until    mininet>
401     ${macaddress}=    Split String    ${sourcemacaddr}    ${SPACE}
402     ${sourcemacaddr}=    Get from List    ${macaddress}    ${index}
403     ${sourcemacaddress}=    Convert To Lowercase    ${sourcemacaddr}
404     write    ${host2} ifconfig -a | grep HWaddr
405     ${destmacaddr}=    Read Until    mininet>
406     ${macaddress}=    Split String    ${destmacaddr}    ${SPACE}
407     ${destmacaddr}=    Get from List    ${macaddress}    ${index}
408     ${destmacaddress}=    Convert To Lowercase    ${destmacaddr}
409     write    ${DUMPFLOWS}
410     ${result}=    Read Until    mininet>
411     Should Contain    ${result}    ${sourcemacaddress}
412     Should Contain    ${result}    ${destmacaddress}
413
414 Verify flowactions
415     [Documentation]    Verify the flowfilter actions after ping in the dumpflows
416     [Arguments]    ${actions}    ${DUMPFLOWS}
417     write    ${DUMPFLOWS}
418     ${result}=    Read Until    mininet>
419     Should Contain    ${result}    ${actions}
420
421 Add a vtn flowfilter
422     [Documentation]    Create a flowfilter for a vtn
423     [Arguments]    ${vtn_name}    ${vtnflowfilter_data}
424     ${resp}=    RequestsLibrary.Post Request
425     ...    session
426     ...    restconf/operations/vtn-flow-filter:set-flow-filter
427     ...    data={"input": {"tenant-name": "${vtn_name}",${vtnflowfilter_data}}}
428     Should Be Equal As Strings    ${resp.status_code}    200
429
430 Remove a vtn flowfilter
431     [Documentation]    Delete a vtn flowfilter
432     [Arguments]    ${vtn_name}    ${filter_index}
433     ${resp}=    RequestsLibrary.Post Request
434     ...    session
435     ...    restconf/operations/vtn-flow-filter:remove-flow-filter
436     ...    data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}"}}
437     Should Be Equal As Strings    ${resp.status_code}    200
438
439 Add a vbr flowfilter
440     [Documentation]    Create a flowfilter for a vbr
441     [Arguments]    ${vtn_name}    ${vBridge_name}    ${vbrflowfilter_data}
442     ${resp}=    RequestsLibrary.Post Request
443     ...    session
444     ...    restconf/operations/vtn-flow-filter:set-flow-filter
445     ...    data={"input": {"tenant-name": "${vtn_name}", "bridge-name": "${vBridge_name}", ${vbrflowfilter_data}}}
446     Should Be Equal As Strings    ${resp.status_code}    200
447
448 Remove a vbr flowfilter
449     [Documentation]    Delete a vbr flowfilter
450     [Arguments]    ${vtn_name}    ${vBridge_name}    ${filter_index}
451     ${resp}=    RequestsLibrary.Post Request
452     ...    session
453     ...    restconf/operations/vtn-flow-filter:remove-flow-filter
454     ...    data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}","bridge-name": "${vBridge_name}"}}
455     Should Be Equal As Strings    ${resp.status_code}    200
456
457 Add a vbrif flowfilter
458     [Documentation]    Create a flowfilter for a vbrif
459     [Arguments]    ${vtn_name}    ${vBridge_name}    ${interface_name}    ${vbrif_flowfilter_data}
460     ${resp}=    RequestsLibrary.Post Request
461     ...    session
462     ...    restconf/operations/vtn-flow-filter:set-flow-filter
463     ...    data={"input": {"tenant-name": ${vtn_name}, "bridge-name": "${vBridge_name}","interface-name":"${interface_name}",${vbrif_flowfilter_data}}}
464     Should Be Equal As Strings    ${resp.status_code}    200
465
466 Remove a vbrif flowfilter
467     [Documentation]    Delete a vbrif flowfilter
468     [Arguments]    ${vtn_name}    ${vBridge_name}    ${interface_name}    ${filter_index}
469     ${resp}=    RequestsLibrary.Post Request
470     ...    session
471     ...    restconf/operations/vtn-flow-filter:remove-flow-filter
472     ...    data={"input": {"indices": ["${filter_index}"], "tenant-name": "${vtn_name}","bridge-name": "${vBridge_name}","interface-name": "${interface_name}"}}
473     Should Be Equal As Strings    ${resp.status_code}    200
474
475 Add a vlan portmap
476     [Documentation]    Create a portmap for a interface of a vbridge
477     [Arguments]    ${vtn_name}    ${vbr_name}    ${interface_name}    ${id}    ${node_id}    ${port_id}
478     ${resp}=    RequestsLibrary.Post Request
479     ...    session
480     ...    restconf/operations/vtn-port-map:set-port-map
481     ...    data={"input": { "tenant-name":${vtn_name}, "bridge-name":${vbr_name}, "interface-name": ${interface_name}, "vlan-id": ${id}, "node":"${node_id}", "port-name":"${port_id}"}}
482     Should Be Equal As Strings    ${resp.status_code}    200
483
484 Verify Flow Entries for Flowfilter
485     [Documentation]    Verify switch flow entry using flowfilter for a vtn
486     [Arguments]    ${dumpflows}    @{flowfilter_actions}
487     ${booleanValue}=    Run Keyword And Return Status
488     ...    Verify Actions on Flow Entry
489     ...    ${dumpflows}
490     ...    @{flowfilter_actions}
491     Should Be Equal As Strings    ${booleanValue}    True
492
493 Verify Removed Flow Entry for Inet Drop Flowfilter
494     [Documentation]    Verify removed switch flow entry using flowfilter drop for a vtn
495     [Arguments]    ${dumpflows}    @{flowfilter_actions}
496     ${booleanValue}=    Run Keyword And Return Status
497     ...    Verify Actions on Flow Entry
498     ...    ${dumpflows}
499     ...    @{flowfilter_actions}
500     Should Be Equal As Strings    ${booleanValue}    True
501
502 Verify Actions on Flow Entry
503     [Documentation]    check flow action elements by giving dumpflows in mininet
504     [Arguments]    ${dumpflows}    @{flowfilter_actions}
505     write    ${dumpflows}
506     ${result}=    Read Until    mininet>
507     FOR    ${flowElement}    IN    @{flowfilter_actions}
508         should Contain    ${result}    ${flowElement}
509     END
510
511 Add a flowcondition
512     [Documentation]    Create a flowcondition using Restconfig Api
513     [Arguments]    ${flowcond_name}    ${flowconditiondata}
514     ${resp}=    RequestsLibrary.Post Request
515     ...    session
516     ...    restconf/operations/vtn-flow-condition:set-flow-condition
517     ...    data={"input":{"operation":"SET","present":"false","name":"${flowcond_name}",${flowconditiondata}}}
518     Should Be Equal As Strings    ${resp.status_code}    200
519
520 Get flowconditions
521     [Documentation]    Retrieve the list of flowconditions created
522     ${resp}=    RequestsLibrary.Get Request    session    restconf/operational/vtn-flow-condition:vtn-flow-conditions
523     Should Be Equal As Strings    ${resp.status_code}    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 Request
530     ...    session
531     ...    restconf/operational/vtn-flow-condition:vtn-flow-conditions/vtn-flow-condition/${flowcond_name}
532     IF    '${retrieve}' == 'retrieve'
533         Should Be Equal As Strings    ${resp.status_code}    200
534     ELSE
535         Should Not Be Equal As Strings    ${resp.status_code}    200
536     END
537
538 Remove flowcondition
539     [Documentation]    Remove the flowcondition by name
540     [Arguments]    ${flowcond_name}
541     ${resp}=    RequestsLibrary.Post Request
542     ...    session
543     ...    restconf/operations/vtn-flow-condition:remove-flow-condition
544     ...    data={"input":{"name":"${flowcond_name}"}}
545     Should Be Equal As Strings    ${resp.status_code}    200