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