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