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