4b270d53d18f8e4dab6c537a11086e277d7f7efc
[integration/test.git] / csit / suites / genius / 03_Configure_ITM.robot
1 *** Settings ***
2 Documentation     Test Suite for ITM
3 Suite Setup       Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Library           OperatingSystem
6 Library           String
7 Library           RequestsLibrary
8 Variables         ../../variables/Variables.py
9 Library           Collections
10 Resource          ../../libraries/Utils.robot
11 Library           re
12
13 *** Variables ***
14 @{itm_created}    TZA
15 ${genius_config_dir}    ${CURDIR}/../../variables/genius
16 ${Bridge-1}       BR1
17 ${Bridge-2}       BR2
18
19 *** Test Cases ***
20 Create and Verify VTEP -No Vlan
21     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs without VLAN and Gateway configured in Json.
22     ${Dpn_id_1}    Get Dpn Ids    ${conn_id_1}
23     ${Dpn_id_2}    Get Dpn Ids    ${conn_id_2}
24     Set Global Variable    ${Dpn_id_1}
25     Set Global Variable    ${Dpn_id_2}
26     ${vlan}=    Set Variable    0
27     ${gateway-ip}=    Set Variable    0.0.0.0
28     Create Vteps    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
29     Wait Until Keyword Succeeds    40    10    Get ITM    ${itm_created[0]}    ${subnet}    ${vlan}
30     ...    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${TOOLS_SYSTEM_2_IP}
31     ${type}    set variable    odl-interface:tunnel-type-vxlan
32     ${tunnel-1}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
33     ...    ${type}
34     Set Global Variable    ${tunnel-1}
35     ${tunnel-2}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
36     ...    ${type}
37     Set Global Variable    ${tunnel-2}
38     ${tunnel-type}=    Set Variable    type: vxlan
39     Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
40     Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
41     Log    >>>>OVS Validation in Switch 1 for Tunnel Created<<<<<
42     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
43     ...    ${tunnel-1}    ${tunnel-type}
44     Log    >>>>OVS Validation in Switch 2 for Tunnel Created<<<<<
45     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_IP}
46     ...    ${tunnel-2}    ${tunnel-type}
47     Log    >>>> Getting Network Topology Operational <<<<<<
48     ${resp}    Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${Bridge-1}    ${Bridge-2}
49     ...    ${tunnel-1}    ${tunnel-2}    ${OPERATIONAL_TOPO_API}
50     Log    >>>>Validating Interface 1 & 2 states<<<<
51     ${return}    Validate interface state    ${tunnel-1}    ${Dpn_id_1}    ${tunnel-2}    ${Dpn_id_2}
52     log    ${return}
53     ${lower-layer-if-1}    Get from List    ${return}    0
54     ${port-num-1}    Get From List    ${return}    1
55     ${lower-layer-if-2}    Get from List    ${return}    2
56     ${port-num-2}    Get From List    ${return}    3
57     Log    >>>>>Verify Oper data base of Interface state<<<<<
58     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/
59     Log    ${resp.content}
60     Should Be Equal As Strings    ${resp.status_code}    200
61     Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-1}
62     Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-2}
63     Log    >>>>> Checking Entry in table 0 on OVS 1<<<<<
64     ${check-3}    Wait Until Keyword Succeeds    40    10    Check Table0 Entry for 2 Dpn    ${conn_id_1}    ${Bridge-1}
65     ...    ${port-num-1}
66     Log    >>>>> Checking Entry in table 0 on OVS 2<<<<<
67     ${check-4}    Wait Until Keyword Succeeds    40    10    Check Table0 Entry for 2 Dpn    ${conn_id_2}    ${Bridge-2}
68     ...    ${port-num-2}
69     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/opendaylight-inventory:nodes/
70     Should Be Equal As Strings    ${resp.status_code}    200
71     Should Contain    ${resp.content}    ${lower-layer-if-1}    ${lower-layer-if-2}
72     Log    ${resp.content}
73
74 Delete and Verify VTEP -No Vlan
75     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
76     Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
77     Wait Until Keyword Succeeds    40    10    Verify Data Base after Delete    ${Dpn_id_1}    ${Dpn_id_2}    ${tunnel-1}
78     ...    ${tunnel-2}
79
80 Create and Verify VTEP IPv6 - No Vlan
81     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs without VLAN and Gateway configured in Json.
82     Pass Execution If    "${ODL_STREAM}" == "boron"    IPV6 support is not available in boron or before
83     ${Dpn_id_1}    Get Dpn Ids    ${conn_id_1}
84     ${Dpn_id_2}    Get Dpn Ids    ${conn_id_2}
85     Set Global Variable    ${Dpn_id_1}
86     Set Global Variable    ${Dpn_id_2}
87     ${vlan}=    Set Variable    0
88     ${gateway-ip}=    Set Variable    ::
89     ${TOOLS_SYSTEM_IP}    Set Variable    fd96:2a25:4ad3:3c7d:0:0:0:1000
90     ${TOOLS_SYSTEM_2_IP}    Set Variable    fd96:2a25:4ad3:3c7d:0:0:0:2000
91     Create Vteps IPv6    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
92     Wait Until Keyword Succeeds    40    10    Get ITM    ${itm_created[0]}    ${subnet}    ${vlan}
93     ...    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${TOOLS_SYSTEM_2_IP}
94     ${type}    set variable    odl-interface:tunnel-type-vxlan
95     ${tunnel-1}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
96     ...    ${type}
97     Set Global Variable    ${tunnel-1}
98     ${tunnel-2}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
99     ...    ${type}
100     Set Global Variable    ${tunnel-2}
101     ${tunnel-type}=    Set Variable    type: vxlan
102     Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/    headers=${ACCEPT_XML}
103     Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/    headers=${ACCEPT_XML}
104     Log    >>>>OVS Validation in Switch 1 for Tunnel Created<<<<<
105     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
106     ...    ${tunnel-1}    ${tunnel-type}
107     Log    >>>>OVS Validation in Switch 2 for Tunnel Created<<<<<
108     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_IP}
109     ...    ${tunnel-2}    ${tunnel-type}
110     Log    >>>> Getting Network Topology Operational <<<<<<
111     ${resp}    Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${Bridge-1}    ${Bridge-2}
112     ...    ${tunnel-1}    ${tunnel-2}    ${OPERATIONAL_TOPO_API}
113
114 Delete and Verify VTEP IPv6 -No Vlan
115     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
116     Pass Execution If    "${ODL_STREAM}" == "boron"    IPV6 support is not available in boron or before
117     Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
118     Wait Until Keyword Succeeds    40    10    Verify Data Base after Delete    ${Dpn_id_1}    ${Dpn_id_2}    ${tunnel-1}
119     ...    ${tunnel-2}
120
121 Create and Verify VTEP-Vlan
122     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs with VLAN and \ without Gateway configured in Json.
123     ${vlan}=    Set Variable    100
124     ${gateway-ip}=    Set Variable    0.0.0.0
125     Create Vteps    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
126     ${get}    Wait Until Keyword Succeeds    40    10    Get ITM    ${itm_created[0]}    ${subnet}
127     ...    ${vlan}    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${TOOLS_SYSTEM_2_IP}
128     Log    ${get}
129     ${type}    set variable    odl-interface:tunnel-type-vxlan
130     ${tunnel-3}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
131     ...    ${type}
132     log    ${tunnel-3}
133     Set Global Variable    ${tunnel-3}
134     ${tunnel-4}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
135     ...    ${type}
136     log    ${tunnel-4}
137     Set Global Variable    ${tunnel-4}
138     ${tunnel-type}=    Set Variable    type: vxlan
139     Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
140     Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
141     Log    >>>>OVS Validation in Switch 1 for Tunnel Created<<<<<
142     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
143     ...    ${tunnel-3}    ${tunnel-type}
144     Log    >>>>OVS Validation in Switch 2 for Tunnel Created<<<<<
145     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_IP}
146     ...    ${tunnel-4}    ${tunnel-type}
147     Log    >>>>> Checking Network opertional Topology <<<<<<
148     ${url_2}    set variable    ${OPERATIONAL_API}/network-topology:network-topology/
149     Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${Bridge-1}    ${Bridge-2}    ${tunnel-3}
150     ...    ${tunnel-4}    ${url_2}
151     ${return}    Validate interface state    ${tunnel-3}    ${Dpn_id_1}    ${tunnel-4}    ${Dpn_id_2}
152     log    ${return}
153     ${lower-layer-if-1}    Get from List    ${return}    0
154     ${port-num-1}    Get From List    ${return}    1
155     ${lower-layer-if-2}    Get from List    ${return}    2
156     ${port-num-2}    Get From List    ${return}    3
157     Log    >>>>>Verify Oper data base of Interface state<<<<<
158     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/
159     Log    ${resp.content}
160     Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-3}
161     Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-4}
162     Log    >>>>> Checking Entry in table 0 on OVS 1<<<<<
163     Wait Until Keyword Succeeds    40    10    Check Table0 Entry for 2 Dpn    ${conn_id_1}    ${Bridge-1}    ${port-num-1}
164     Log    >>>>> Checking Entry in table 0 on OVS \ 2<<<<<
165     Wait Until Keyword Succeeds    40    10    Check Table0 Entry for 2 Dpn    ${conn_id_2}    ${Bridge-2}    ${port-num-2}
166     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/opendaylight-inventory:nodes/
167     Log    ${resp.content}
168     Should Be Equal As Strings    ${resp.status_code}    200
169     Should Contain    ${resp.content}    ${lower-layer-if-2}    ${lower-layer-if-1}
170
171 Delete and Verify VTEP -Vlan
172     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
173     Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
174     Wait Until Keyword Succeeds    40    10    Verify Data Base after Delete    ${Dpn_id_1}    ${Dpn_id_2}    ${tunnel-3}
175     ...    ${tunnel-4}
176
177 Create VTEP - Vlan and Gateway
178     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs with VLAN and Gateway configured in Json.
179     ${vlan}=    Set Variable    101
180     ${substr}    Should Match Regexp    ${TOOLS_SYSTEM_IP}    [0-9]\{1,3}\.[0-9]\{1,3}\.[0-9]\{1,3}\.
181     ${subnet}    Catenate    ${substr}0
182     ${gateway-ip}    Catenate    ${substr}1
183     Log    ${subnet}
184     Create Vteps    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
185     Wait Until Keyword Succeeds    40    10    Get ITM    ${itm_created[0]}    ${subnet}    ${vlan}
186     ...    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${TOOLS_SYSTEM_2_IP}
187     ${type}    set variable    odl-interface:tunnel-type-vxlan
188     ${tunnel-5}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
189     ...    ${type}
190     log    ${tunnel-5}
191     Set Global Variable    ${tunnel-5}
192     ${tunnel-6}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
193     ...    ${type}
194     log    ${tunnel-6}
195     Set Global Variable    ${tunnel-6}
196     ${tunnel-type}=    Set Variable    type: vxlan
197     Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
198     Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
199     Log    >>>>OVS Validation in Switch 1 for Tunnel Created<<<<<
200     ${check-1}    Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}
201     ...    ${TOOLS_SYSTEM_2_IP}    ${tunnel-5}    ${tunnel-type}
202     Log    ${check-1}
203     ${check-2}    Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}
204     ...    ${TOOLS_SYSTEM_IP}    ${tunnel-6}    ${tunnel-type}
205     Log    ${check-2}
206     ${resp}    Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${Bridge-1}    ${Bridge-2}
207     ...    ${tunnel-5}    ${tunnel-6}    ${OPERATIONAL_TOPO_API}
208     Log    ${resp}
209     ${return}    Validate interface state    ${tunnel-5}    ${Dpn_id_1}    ${tunnel-6}    ${Dpn_id_2}
210     log    ${return}
211     ${lower-layer-if-1}    Get from List    ${return}    0
212     ${port-num-1}    Get From List    ${return}    1
213     ${lower-layer-if-2}    Get from List    ${return}    2
214     ${port-num-2}    Get From List    ${return}    3
215     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/
216     Log    ${resp.content}
217     Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-5}
218     Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-6}
219     ${check-3}    Wait Until Keyword Succeeds    40    10    Check Table0 Entry for 2 Dpn    ${conn_id_1}    ${Bridge-1}
220     ...    ${port-num-1}
221     Log    ${check-3}
222     ${check-4}    Wait Until Keyword Succeeds    40    10    Check Table0 Entry for 2 Dpn    ${conn_id_2}    ${Bridge-2}
223     ...    ${port-num-2}
224     Log    ${check-4}
225     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/opendaylight-inventory:nodes/
226     Should Be Equal As Strings    ${resp.status_code}    200
227     Should Contain    ${resp.content}    ${lower-layer-if-2}    ${lower-layer-if-1}
228     Log    ${resp.content}
229
230 Delete VTEP -Vlan and gateway
231     [Documentation]    This testcase deletes the ITM tunnel created between 2 dpns.
232     Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
233     Wait Until Keyword Succeeds    40    10    Verify Data Base after Delete    ${Dpn_id_1}    ${Dpn_id_2}    ${tunnel-5}
234     ...    ${tunnel-6}
235
236 *** Keywords ***
237 Create Vteps
238     [Arguments]    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
239     [Documentation]    This keyword creates VTEPs between ${TOOLS_SYSTEM_IP} and ${TOOLS_SYSTEM_2_IP}
240     ${body}    OperatingSystem.Get File    ${genius_config_dir}/Itm_creation_no_vlan.json
241     ${substr}    Should Match Regexp    ${TOOLS_SYSTEM_IP}    [0-9]\{1,3}\.[0-9]\{1,3}\.[0-9]\{1,3}\.
242     ${subnet}    Catenate    ${substr}0
243     Log    ${subnet}
244     Set Global Variable    ${subnet}
245     ${vlan}=    Set Variable    ${vlan}
246     ${gateway-ip}=    Set Variable    ${gateway-ip}
247     ${body}    set json    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}    ${subnet}
248     Post Log Check    ${CONFIG_API}/itm:transport-zones/    ${body}    204
249
250 Create Vteps IPv6
251     [Arguments]    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
252     [Documentation]    This keyword creates VTEPs between ${TOOLS_SYSTEM_IP} and ${TOOLS_SYSTEM_2_IP}
253     ${body}    OperatingSystem.Get File    ${genius_config_dir}/Itm_creation_no_vlan.json
254     ${substr}    Should Match Regexp    ${TOOLS_SYSTEM_IP}    [0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}:
255     ${subnet}    Catenate    ${substr}0
256     Log    ${subnet}
257     Set Global Variable    ${subnet}
258     ${vlan}=    Set Variable    ${vlan}
259     ${gateway-ip}=    Set Variable    ${gateway-ip}
260     ${body}    set json    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}    ${subnet}
261     Post Log Check    ${CONFIG_API}/itm:transport-zones/    ${body}    204
262
263 Get Dpn Ids
264     [Arguments]    ${connection_id}
265     [Documentation]    This keyword gets the DPN id of the switch after configuring bridges on it.It returns the captured DPN id.
266     Switch connection    ${connection_id}
267     ${cmd}    set Variable    sudo ovs-vsctl show | grep Bridge | awk -F "\\"" '{print $2}'
268     ${Bridgename1}    Execute command    ${cmd}
269     log    ${Bridgename1}
270     ${output1}    Execute command    sudo ovs-ofctl show -O Openflow13 ${Bridgename1} | head -1 | awk -F "dpid:" '{ print $2 }'
271     log    ${output1}
272     ${Dpn_id}    Execute command    echo \$\(\(16\#${output1}\)\)
273     log    ${Dpn_id}
274     [Return]    ${Dpn_id}
275
276 Get Tunnel
277     [Arguments]    ${src}    ${dst}    ${type}
278     [Documentation]    This Keyword Gets the Tunnel /Interface name which has been created between 2 DPNS by passing source , destination DPN Ids along with the type of tunnel which is configured.
279     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${src}/${dst}/${type}/
280     Log    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${src}/${dst}/
281     Log    ${resp.content}
282     Should Be Equal As Strings    ${resp.status_code}    200
283     Should Contain    ${resp.content}    ${src}    ${dst}    TUNNEL:
284     ${json}=    evaluate    json.loads('''${resp.content}''')    json
285     log to console    \nOriginal JSON:\n${json}
286     ${Tunnel}    Collections.Get From Dictionary    ${json["internal-tunnel"][0]}    tunnel-interface-name
287     Log To Console    ${Tunnel}
288     Log    ${Tunnel}
289     [Return]    ${Tunnel}
290
291 Validate interface state
292     [Arguments]    ${tunnel-1}    ${dpid-1}    ${tunnel-2}    ${dpid-2}
293     [Documentation]    Validates the created Interface Tunnel by checking its Operational status as UP/DOWN from the dump.
294     Log    ${tunnel-1},${dpid-1},${tunnel-2},${dpid-2}
295     ${data1-2}    Wait Until Keyword Succeeds    40    10    Check Interface status    ${tunnel-1}    ${dpid-1}
296     ${data2-1}    Wait Until Keyword Succeeds    40    10    Check Interface status    ${tunnel-2}    ${dpid-2}
297     @{data}    combine lists    ${data1-2}    ${data2-1}
298     log    ${data}
299     [Return]    ${data}
300
301 Check Table0 Entry for 2 Dpn
302     [Arguments]    ${connection_id}    ${Bridgename}    ${port-num1}
303     [Documentation]    Checks the Table 0 entry in the OVS when flows are dumped.
304     Switch Connection    ${connection_id}
305     Log    ${connection_id}
306     ${check}    Execute Command    sudo ovs-ofctl -O OpenFlow13 dump-flows ${Bridgename}
307     Log    ${check}
308     Should Contain    ${check}    in_port=${port-num1}
309     [Return]    ${check}
310
311 Ovs Verification 2 Dpn
312     [Arguments]    ${connection_id}    ${local}    ${remote-1}    ${tunnel}    ${tunnel-type}
313     [Documentation]    Checks whether the created Interface is seen on OVS or not.
314     Switch Connection    ${connection_id}
315     Log    ${connection_id}
316     ${check}    Execute Command    sudo ovs-vsctl show
317     Log    ${check}
318     Should Contain    ${check}    local_ip="${local}"    remote_ip="${remote-1}"    ${tunnel}
319     Should Contain    ${check}    ${tunnel-type}
320     [Return]    ${check}
321
322 Get ITM
323     [Arguments]    ${itm_created[0]}    ${subnet}    ${vlan}    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}
324     ...    ${TOOLS_SYSTEM_2_IP}
325     [Documentation]    It returns the created ITM Transport zone with the passed values during the creation is done.
326     Log    ${itm_created[0]},${subnet}, ${vlan}, ${Dpn_id_1},${TOOLS_SYSTEM_IP}, ${Dpn_id_2}, ${TOOLS_SYSTEM_2_IP}
327     @{Itm-no-vlan}    Create List    ${itm_created[0]}    ${subnet}    ${vlan}    ${Dpn_id_1}    ${Bridge-1}-eth1
328     ...    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${Bridge-2}-eth1    ${TOOLS_SYSTEM_2_IP}
329     Check For Elements At URI    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}    ${Itm-no-vlan}
330
331 Get Network Topology with Tunnel
332     [Arguments]    ${Bridge-1}    ${Bridge-2}    ${tunnel-1}    ${tunnel-2}    ${url}
333     [Documentation]    Returns the Network topology with Tunnel info in it.
334     @{bridges}    Create List    ${Bridge-1}    ${Bridge-2}    ${tunnel-1}    ${tunnel-2}
335     Check For Elements At URI    ${url}    ${bridges}
336
337 Get Network Topology without Tunnel
338     [Arguments]    ${url}    ${tunnel-1}    ${tunnel-2}
339     [Documentation]    Returns the Network Topology after Deleting of ITM transport zone is done , which wont be having any TUNNEL info in it.
340     @{tunnels}    create list    ${tunnel-1}    ${tunnel-2}
341     Check For Elements Not At URI    ${url}    ${tunnels}
342
343 Validate interface state Delete
344     [Arguments]    ${tunnel}
345     [Documentation]    Check for the Tunnel / Interface absence in OPERATIONAL data base of IETF interface after ITM transport zone is deleted.
346     Log    ${tunnel}
347     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
348     Log    ${resp.content}
349     Should Be Equal As Strings    ${resp.status_code}    404
350     Should not contain    ${resp.content}    ${tunnel}
351
352 set json
353     [Arguments]    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}    ${subnet}
354     [Documentation]    Sets Json with the values passed for it.
355     ${body}    OperatingSystem.Get File    ${genius_config_dir}/Itm_creation_no_vlan.json
356     ${body}    replace string    ${body}    1.1.1.1    ${subnet}
357     ${body}    replace string    ${body}    "dpn-id": 101    "dpn-id": ${Dpn_id_1}
358     ${body}    replace string    ${body}    "dpn-id": 102    "dpn-id": ${Dpn_id_2}
359     ${body}    replace string    ${body}    "ip-address": "2.2.2.2"    "ip-address": "${TOOLS_SYSTEM_IP}"
360     ${body}    replace string    ${body}    "ip-address": "3.3.3.3"    "ip-address": "${TOOLS_SYSTEM_2_IP}"
361     ${body}    replace string    ${body}    "vlan-id": 0    "vlan-id": ${vlan}
362     ${body}    replace string    ${body}    "gateway-ip": "0.0.0.0"    "gateway-ip": "${gateway-ip}"
363     Log    ${body}
364     [Return]    ${body}    # returns complete json that has been updated
365
366 check-Tunnel-delete-on-ovs
367     [Arguments]    ${connection-id}    ${tunnel}
368     [Documentation]    Verifies the Tunnel is deleted from OVS
369     Log    ${tunnel}
370     Switch Connection    ${connection-id}
371     Log    ${connection-id}
372     ${return}    Execute Command    sudo ovs-vsctl show
373     Log    ${return}
374     Should Not Contain    ${return}    ${tunnel}
375     [Return]    ${return}
376
377 check interface status
378     [Arguments]    ${tunnel}    ${dpid}
379     [Documentation]    Verifies the operational state of the interface .
380     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
381     Log    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
382     Log    ${resp.content}
383     Should Be Equal As Strings    ${resp.status_code}    200
384     Should not contain    ${resp.content}    down
385     Should Contain    ${resp.content}    ${tunnel}    up    up
386     ${result-1}    re.sub    <.*?>    ,    ${resp.content}
387     Log    ${result-1}
388     ${lower_layer_if}    Should Match Regexp    ${result-1}    openflow:${dpid}:[0-9]+
389     log    ${lower_layer_if}
390     @{resp_array}    Split String    ${lower_layer_if}    :
391     ${port-num}    Get From List    ${resp_array}    2
392     Log    ${port-num}
393     [Return]    ${lower_layer_if}    ${port-num}
394
395 Verify Data Base after Delete
396     [Arguments]    ${Dpn_id_1}    ${Dpn_id_2}    ${tunnel-1}    ${tunnel-2}
397     [Documentation]    Verifies the config database after the Tunnel deletion is done.
398     ${type}    set variable    odl-interface:tunnel-type-vxlan
399     No Content From URI    session    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${Dpn_id_1}/${Dpn_id_2}/${type}/
400     No Content From URI    session    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${Dpn_id_2}/${Dpn_id_1}/${type}/
401     No Content From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
402     No Content From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
403     ${resp_7}    RequestsLibrary.Get Request    session    ${CONFIG_API}/ietf-interfaces:interfaces/
404     Run Keyword if    '${resp_7.content}'=='404'    Response is 404
405     Run Keyword if    '${resp_7.content}'=='200'    Response is 200
406     ${resp_8}    Wait Until Keyword Succeeds    40    10    Get Network Topology without Tunnel    ${CONFIG_TOPO_API}    ${tunnel-1}
407     ...    ${tunnel-2}
408     Log    ${resp_8}
409     ${Ovs-del-1}    Wait Until Keyword Succeeds    40    10    check-Tunnel-delete-on-ovs    ${conn_id_1}    ${tunnel-1}
410     Log    ${Ovs-del-1}
411     ${Ovs-del-2}    Wait Until Keyword Succeeds    40    10    check-Tunnel-delete-on-ovs    ${conn_id_2}    ${tunnel-2}
412     Log    ${Ovs-del-2}
413     Log    >>>>>>> Getting Network Topology Config without Tunnels<<<<<<<
414     Wait Until Keyword Succeeds    40    10    Get Network Topology without Tunnel    ${OPERATIONAL_TOPO_API}    ${tunnel-1}    ${tunnel-2}
415     Wait Until Keyword Succeeds    40    10    Validate interface state Delete    ${tunnel-1}
416     Wait Until Keyword Succeeds    40    10    Validate interface state Delete    ${tunnel-2}