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