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