Check cluster status after rejoin
[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}    ${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 Library           re
15
16 *** Variables ***
17 @{itm_created}    TZA
18 ${genius_config_dir}    ${CURDIR}/../../variables/genius
19 ${Bridge-1}       BR1
20 ${Bridge-2}       BR2
21
22 *** Test Cases ***
23 Create and Verify VTEP -No Vlan
24     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs without VLAN and Gateway configured in Json.
25     ${Dpn_id_1}    Get Dpn Ids    ${conn_id_1}
26     ${Dpn_id_2}    Get Dpn Ids    ${conn_id_2}
27     Set Global Variable    ${Dpn_id_1}
28     Set Global Variable    ${Dpn_id_2}
29     ${vlan}=    Set Variable    0
30     ${gateway-ip}=    Set Variable    0.0.0.0
31     Create Vteps    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
32     Wait Until Keyword Succeeds    40    10    Get ITM    ${itm_created[0]}    ${subnet}    ${vlan}
33     ...    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${TOOLS_SYSTEM_2_IP}
34     ${type}    set variable    odl-interface:tunnel-type-vxlan
35     ${tunnel-1}    Wait Until Keyword Succeeds    40    20    Get Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
36     ...    ${type}
37     Set Global Variable    ${tunnel-1}
38     ${tunnel-2}    Wait Until Keyword Succeeds    40    20    Get Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
39     ...    ${type}
40     Set Global Variable    ${tunnel-2}
41     ${tunnel-type}=    Set Variable    type: vxlan
42     Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
43     Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
44     Log    >>>>OVS Validation in Switch 1 for Tunnel Created<<<<<
45     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
46     ...    ${tunnel-1}    ${tunnel-type}
47     Log    >>>>OVS Validation in Switch 2 for Tunnel Created<<<<<
48     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_IP}
49     ...    ${tunnel-2}    ${tunnel-type}
50     Log    >>>> Getting Network Topology Operational <<<<<<
51     ${resp}    Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${Bridge-1}    ${Bridge-2}
52     ...    ${tunnel-1}    ${tunnel-2}    ${OPERATIONAL_TOPO_API}
53     Log    >>>>Validating Interface 1 & 2 states<<<<
54     ${return}    Validate interface state    ${tunnel-1}    ${Dpn_id_1}    ${tunnel-2}    ${Dpn_id_2}
55     log    ${return}
56     ${lower-layer-if-1}    Get from List    ${return}    0
57     ${port-num-1}    Get From List    ${return}    1
58     ${lower-layer-if-2}    Get from List    ${return}    2
59     ${port-num-2}    Get From List    ${return}    3
60     Log    >>>>>Verify Oper data base of Interface state<<<<<
61     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/
62     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
63     Log    ${respjson}
64     Should Be Equal As Strings    ${resp.status_code}    200
65     Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-1}
66     Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-2}
67     Log    >>>>> Checking Entry in table 0 on OVS 1<<<<<
68     ${check-3}    Wait Until Keyword Succeeds    40    10    Check Table0 Entry for 2 Dpn    ${conn_id_1}    ${Bridge-1}
69     ...    ${port-num-1}
70     Log    >>>>> Checking Entry in table 0 on OVS 2<<<<<
71     ${check-4}    Wait Until Keyword Succeeds    40    10    Check Table0 Entry for 2 Dpn    ${conn_id_2}    ${Bridge-2}
72     ...    ${port-num-2}
73     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/opendaylight-inventory:nodes/
74     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
75     Log    ${respjson}
76     Should Be Equal As Strings    ${resp.status_code}    200
77     Should Contain    ${resp.content}    ${lower-layer-if-1}    ${lower-layer-if-2}
78
79 Delete and Verify VTEP -No Vlan
80     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
81     Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
82     Wait Until Keyword Succeeds    40    10    Verify Data Base after Delete    ${Dpn_id_1}    ${Dpn_id_2}    ${tunnel-1}
83     ...    ${tunnel-2}
84
85 Create and Verify VTEP IPv6 - No Vlan
86     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs without VLAN and Gateway configured in Json.
87     ${Dpn_id_1}    Get Dpn Ids    ${conn_id_1}
88     ${Dpn_id_2}    Get Dpn Ids    ${conn_id_2}
89     Set Global Variable    ${Dpn_id_1}
90     Set Global Variable    ${Dpn_id_2}
91     ${vlan}=    Set Variable    0
92     ${gateway-ip}=    Set Variable    ::
93     ${TOOLS_SYSTEM_IP}    Set Variable    fd96:2a25:4ad3:3c7d:0:0:0:1000
94     ${TOOLS_SYSTEM_2_IP}    Set Variable    fd96:2a25:4ad3:3c7d:0:0:0:2000
95     Create Vteps IPv6    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
96     Wait Until Keyword Succeeds    40    10    Get ITM    ${itm_created[0]}    ${subnet}    ${vlan}
97     ...    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${TOOLS_SYSTEM_2_IP}
98     ${type}    set variable    odl-interface:tunnel-type-vxlan
99     ${tunnel-1}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
100     ...    ${type}
101     Set Global Variable    ${tunnel-1}
102     ${tunnel-2}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
103     ...    ${type}
104     Set Global Variable    ${tunnel-2}
105     ${tunnel-type}=    Set Variable    type: vxlan
106     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}
107     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}
108     Log    >>>>OVS Validation in Switch 1 for Tunnel Created<<<<<
109     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
110     ...    ${tunnel-1}    ${tunnel-type}
111     Log    >>>>OVS Validation in Switch 2 for Tunnel Created<<<<<
112     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_IP}
113     ...    ${tunnel-2}    ${tunnel-type}
114     Log    >>>> Getting Network Topology Operational <<<<<<
115     ${resp}    Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${Bridge-1}    ${Bridge-2}
116     ...    ${tunnel-1}    ${tunnel-2}    ${OPERATIONAL_TOPO_API}
117
118 Delete and Verify VTEP IPv6 -No Vlan
119     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
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    ${resp.content}
288     Log    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${src}/${dst}/
289     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
290     Log    ${respjson}
291     Should Be Equal As Strings    ${resp.status_code}    200
292     Should Contain    ${resp.content}    ${src}    ${dst}
293     ${json}=    evaluate    json.loads('''${resp.content}''')    json
294     log to console    \nOriginal JSON:\n${json}
295     ${return}    Run Keyword And Return Status    Should contain    ${resp.content}    tunnel-interface-names
296     log    ${return}
297     ${ret}    Run Keyword If    '${return}'=='True'    Check Interface Name    ${json["internal-tunnel"][0]}    tunnel-interface-names
298     [Return]    ${ret}
299
300 Validate interface state
301     [Arguments]    ${tunnel-1}    ${dpid-1}    ${tunnel-2}    ${dpid-2}
302     [Documentation]    Validates the created Interface Tunnel by checking its Operational status as UP/DOWN from the dump.
303     Log    ${tunnel-1},${dpid-1},${tunnel-2},${dpid-2}
304     ${data1-2}    Wait Until Keyword Succeeds    40    10    Check Interface Status    ${tunnel-1}    ${dpid-1}
305     ${data2-1}    Wait Until Keyword Succeeds    40    10    Check Interface Status    ${tunnel-2}    ${dpid-2}
306     @{data}    combine lists    ${data1-2}    ${data2-1}
307     log    ${data}
308     [Return]    ${data}
309
310 Check Table0 Entry for 2 Dpn
311     [Arguments]    ${connection_id}    ${Bridgename}    ${port-num1}
312     [Documentation]    Checks the Table 0 entry in the OVS when flows are dumped.
313     Switch Connection    ${connection_id}
314     Log    ${connection_id}
315     ${check}    Execute Command    sudo ovs-ofctl -O OpenFlow13 dump-flows ${Bridgename}
316     Log    ${check}
317     Should Contain    ${check}    in_port=${port-num1}
318     [Return]    ${check}
319
320 Ovs Verification 2 Dpn
321     [Arguments]    ${connection_id}    ${local}    ${remote-1}    ${tunnel}    ${tunnel-type}
322     [Documentation]    Checks whether the created Interface is seen on OVS or not.
323     Switch Connection    ${connection_id}
324     Log    ${connection_id}
325     ${check}    Execute Command    sudo ovs-vsctl show
326     Log    ${check}
327     Should Contain    ${check}    local_ip="${local}"    remote_ip="${remote-1}"    ${tunnel}
328     Should Contain    ${check}    ${tunnel-type}
329     [Return]    ${check}
330
331 Get ITM
332     [Arguments]    ${itm_created[0]}    ${subnet}    ${vlan}    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}
333     ...    ${TOOLS_SYSTEM_2_IP}
334     [Documentation]    It returns the created ITM Transport zone with the passed values during the creation is done.
335     Log    ${itm_created[0]},${subnet}, ${vlan}, ${Dpn_id_1},${TOOLS_SYSTEM_IP}, ${Dpn_id_2}, ${TOOLS_SYSTEM_2_IP}
336     @{Itm-no-vlan}    Create List    ${itm_created[0]}    ${subnet}    ${vlan}    ${Dpn_id_1}    ${Bridge-1}-eth1
337     ...    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${Bridge-2}-eth1    ${TOOLS_SYSTEM_2_IP}
338     Check For Elements At URI    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}    ${Itm-no-vlan}
339
340 Get Network Topology with Tunnel
341     [Arguments]    ${Bridge-1}    ${Bridge-2}    ${tunnel-1}    ${tunnel-2}    ${url}
342     [Documentation]    Returns the Network topology with Tunnel info in it.
343     @{bridges}    Create List    ${Bridge-1}    ${Bridge-2}    ${tunnel-1}    ${tunnel-2}
344     Check For Elements At URI    ${url}    ${bridges}
345
346 Get Network Topology without Tunnel
347     [Arguments]    ${url}    ${tunnel-1}    ${tunnel-2}
348     [Documentation]    Returns the Network Topology after Deleting of ITM transport zone is done , which wont be having any TUNNEL info in it.
349     @{tunnels}    create list    ${tunnel-1}    ${tunnel-2}
350     Check For Elements Not At URI    ${url}    ${tunnels}
351
352 Validate interface state Delete
353     [Arguments]    ${tunnel}
354     [Documentation]    Check for the Tunnel / Interface absence in OPERATIONAL data base of IETF interface after ITM transport zone is deleted.
355     Log    ${tunnel}
356     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
357     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
358     Log    ${respjson}
359     Should Be Equal As Strings    ${resp.status_code}    404
360     Should not contain    ${resp.content}    ${tunnel}
361
362 set json
363     [Arguments]    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}    ${subnet}
364     [Documentation]    Sets Json with the values passed for it.
365     ${body}    OperatingSystem.Get File    ${genius_config_dir}/Itm_creation_no_vlan.json
366     ${body}    replace string    ${body}    1.1.1.1    ${subnet}
367     ${body}    replace string    ${body}    "dpn-id": 101    "dpn-id": ${Dpn_id_1}
368     ${body}    replace string    ${body}    "dpn-id": 102    "dpn-id": ${Dpn_id_2}
369     ${body}    replace string    ${body}    "ip-address": "2.2.2.2"    "ip-address": "${TOOLS_SYSTEM_IP}"
370     ${body}    replace string    ${body}    "ip-address": "3.3.3.3"    "ip-address": "${TOOLS_SYSTEM_2_IP}"
371     ${body}    replace string    ${body}    "vlan-id": 0    "vlan-id": ${vlan}
372     ${body}    replace string    ${body}    "gateway-ip": "0.0.0.0"    "gateway-ip": "${gateway-ip}"
373     Log    ${body}
374     [Return]    ${body}    # returns complete json that has been updated
375
376 check-Tunnel-delete-on-ovs
377     [Arguments]    ${connection-id}    ${tunnel}
378     [Documentation]    Verifies the Tunnel is deleted from OVS
379     Log    ${tunnel}
380     Switch Connection    ${connection-id}
381     Log    ${connection-id}
382     ${return}    Execute Command    sudo ovs-vsctl show
383     Log    ${return}
384     Should Not Contain    ${return}    ${tunnel}
385     [Return]    ${return}
386
387 Check Interface Status
388     [Arguments]    ${tunnel}    ${dpid}
389     [Documentation]    Verifies the operational state of the interface .
390     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
391     Log    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
392     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
393     Log    ${respjson}
394     Should Be Equal As Strings    ${resp.status_code}    200
395     Should not contain    ${resp.content}    down
396     Should Contain    ${resp.content}    ${tunnel}    up    up
397     ${result-1}    re.sub    <.*?>    ,    ${resp.content}
398     Log    ${result-1}
399     ${lower_layer_if}    Should Match Regexp    ${result-1}    openflow:${dpid}:[0-9]+
400     log    ${lower_layer_if}
401     @{resp_array}    Split String    ${lower_layer_if}    :
402     ${port-num}    Get From List    ${resp_array}    2
403     Log    ${port-num}
404     [Return]    ${lower_layer_if}    ${port-num}
405
406 Verify Data Base after Delete
407     [Arguments]    ${Dpn_id_1}    ${Dpn_id_2}    ${tunnel-1}    ${tunnel-2}
408     [Documentation]    Verifies the config database after the Tunnel deletion is done.
409     ${type}    set variable    odl-interface:tunnel-type-vxlan
410     No Content From URI    session    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${Dpn_id_1}/${Dpn_id_2}/${type}/
411     No Content From URI    session    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${Dpn_id_2}/${Dpn_id_1}/${type}/
412     No Content From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
413     No Content From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
414     ${resp_7}    RequestsLibrary.Get Request    session    ${CONFIG_API}/ietf-interfaces:interfaces/
415     Run Keyword if    '${resp_7.content}'=='404'    Response is 404
416     Run Keyword if    '${resp_7.content}'=='200'    Response is 200
417     ${resp_8}    Wait Until Keyword Succeeds    40    10    Get Network Topology without Tunnel    ${CONFIG_TOPO_API}    ${tunnel-1}
418     ...    ${tunnel-2}
419     Log    ${resp_8}
420     ${Ovs-del-1}    Wait Until Keyword Succeeds    40    10    check-Tunnel-delete-on-ovs    ${conn_id_1}    ${tunnel-1}
421     Log    ${Ovs-del-1}
422     ${Ovs-del-2}    Wait Until Keyword Succeeds    40    10    check-Tunnel-delete-on-ovs    ${conn_id_2}    ${tunnel-2}
423     Log    ${Ovs-del-2}
424     Log    >>>>>>> Getting Network Topology Config without Tunnels<<<<<<<
425     Wait Until Keyword Succeeds    40    10    Get Network Topology without Tunnel    ${OPERATIONAL_TOPO_API}    ${tunnel-1}    ${tunnel-2}
426     Wait Until Keyword Succeeds    40    10    Validate interface state Delete    ${tunnel-1}
427     Wait Until Keyword Succeeds    40    10    Validate interface state Delete    ${tunnel-2}
428
429 Check Interface Name
430     [Arguments]    ${json}    ${expected_tunnel_interface_name}
431     [Documentation]    This keyword Checks the Tunnel interface name is tunnel-interface-names in the output or not .
432     ${Tunnels}    Collections.Get From Dictionary    ${json}    ${expected_tunnel_interface_name}
433     Log    ${Tunnels}
434     [Return]    ${Tunnels[0]}