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