Add missing segid vars
[integration/test.git] / csit / suites / genius / Configure_ITM.robot
1 *** Settings ***
2 Documentation     Test Suite for ITM
3 Suite Setup       Genius Suite Setup
4 Suite Teardown    Genius Suite Teardown
5 Test Setup        Genius Test Setup
6 Test Teardown     Genius Test Teardown    ${data_models}
7 Library           Collections
8 Library           OperatingSystem
9 Library           RequestsLibrary
10 Library           String
11 Library           re
12 Variables         ../../variables/genius/Modules.py
13 Resource          ../../libraries/DataModels.robot
14 Resource          ../../libraries/Genius.robot
15 Resource          ../../libraries/Utils.robot
16 Resource          ../../variables/Variables.robot
17
18 *** Variables ***
19 @{itm_created}    TZA
20 ${genius_config_dir}    ${CURDIR}/../../variables/genius
21 ${Bridge-1}       BR1
22 ${Bridge-2}       BR2
23
24 *** Test Cases ***
25 Create and Verify VTEP -No Vlan
26     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs without VLAN and Gateway configured in Json.
27     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
28     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
29     ${vlan}=    Set Variable    0
30     ${gateway-ip}=    Set Variable    0.0.0.0
31     Genius.Create Vteps    ${Dpn_id_1}    ${Dpn_id_2}    ${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     ${tunnel-2}    Wait Until Keyword Succeeds    40    20    Get Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
38     ...    ${type}
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     Wait Until Keyword Succeeds    40    10    Genius.Ovs Verification For 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
43     ...    ${tunnel-1}    ${tunnel-type}
44     Wait Until Keyword Succeeds    40    10    Genius.Ovs Verification For 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_IP}
45     ...    ${tunnel-2}    ${tunnel-type}
46     ${resp}    Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${Bridge-1}    ${Bridge-2}
47     ...    ${tunnel-1}    ${tunnel-2}    ${OPERATIONAL_TOPO_API}
48     ${return}    Validate interface state    ${tunnel-1}    ${Dpn_id_1}    ${tunnel-2}    ${Dpn_id_2}
49     log    ${return}
50     ${lower-layer-if-1}    Get from List    ${return}    0
51     ${port-num-1}    Get From List    ${return}    1
52     ${lower-layer-if-2}    Get from List    ${return}    2
53     ${port-num-2}    Get From List    ${return}    3
54     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/
55     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
56     Log    ${respjson}
57     Should Be Equal As Strings    ${resp.status_code}    200
58     Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-1}
59     Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-2}
60     Wait Until Keyword Succeeds    40    10    Genius.Check Table0 Entry For 2 Dpn    ${conn_id_1}    ${Bridge-1}    ${port-num-1}
61     Wait Until Keyword Succeeds    40    10    Genius.Check Table0 Entry For 2 Dpn    ${conn_id_2}    ${Bridge-2}    ${port-num-2}
62     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/opendaylight-inventory:nodes/
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}    ${lower-layer-if-1}    ${lower-layer-if-2}
67
68 Delete and Verify VTEP -No Vlan
69     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
70     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
71     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
72     ${type}    Set Variable    odl-interface:tunnel-type-vxlan
73     ${tunnel-1}    Get_Tunnel    ${Dpn_id_1}    ${Dpn_id_2}    ${type}
74     ${tunnel-2}    Get_Tunnel    ${Dpn_id_2}    ${Dpn_id_1}    ${type}
75     Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
76     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/itm-state:tunnels_state/
77     Should Not Contain    ${resp}    ${tunnel-1}    ${tunnel-2}
78     Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_1}    ${tunnel-1}
79     Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_2}    ${tunnel-2}
80
81 Create and Verify VTEP IPv6 - No Vlan
82     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs without VLAN and Gateway configured in Json.
83     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
84     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
85     ${vlan}=    Set Variable    0
86     ${gateway-ip}=    Set Variable    ::
87     ${TOOLS_SYSTEM_IP}    Set Variable    fd96:2a25:4ad3:3c7d:0:0:0:1000
88     ${TOOLS_SYSTEM_2_IP}    Set Variable    fd96:2a25:4ad3:3c7d:0:0:0:2000
89     Create Vteps IPv6    ${Dpn_id_1}    ${Dpn_id_2}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
90     Wait Until Keyword Succeeds    40    10    Get ITM    ${itm_created[0]}    ${subnet}    ${vlan}
91     ...    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${TOOLS_SYSTEM_2_IP}
92     ${type}    Set Variable    odl-interface:tunnel-type-vxlan
93     ${tunnel-1}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
94     ...    ${type}
95     ${tunnel-2}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
96     ...    ${type}
97     ${tunnel-type}=    Set Variable    type: vxlan
98     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}
99     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}
100     Wait Until Keyword Succeeds    40    10    Genius.Ovs Verification For 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
101     ...    ${tunnel-1}    ${tunnel-type}
102     Wait Until Keyword Succeeds    40    10    Genius.Ovs Verification For 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_IP}
103     ...    ${tunnel-2}    ${tunnel-type}
104     ${resp}    Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${Bridge-1}    ${Bridge-2}
105     ...    ${tunnel-1}    ${tunnel-2}    ${OPERATIONAL_TOPO_API}
106
107 Delete and Verify VTEP IPv6 -No Vlan
108     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
109     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
110     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
111     ${type}    Set Variable    odl-interface:tunnel-type-vxlan
112     ${tunnel-1}    Get_Tunnel    ${Dpn_id_1}    ${Dpn_id_2}    ${type}
113     ${tunnel-2}    Get_Tunnel    ${Dpn_id_2}    ${Dpn_id_1}    ${type}
114     Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
115     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/itm-state:tunnels_state/
116     Should Not Contain    ${resp}    ${tunnel-1}    ${tunnel-2}
117     Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_1}    ${tunnel-1}
118     Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_2}    ${tunnel-2}
119
120 Create and Verify VTEP-Vlan
121     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs with VLAN and \ without Gateway configured in Json.
122     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
123     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
124     ${vlan}=    Set Variable    100
125     ${gateway-ip}=    Set Variable    0.0.0.0
126     Genius.Create Vteps    ${Dpn_id_1}    ${Dpn_id_2}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
127     ${get}    Wait Until Keyword Succeeds    40    10    Get ITM    ${itm_created[0]}    ${subnet}
128     ...    ${vlan}    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${TOOLS_SYSTEM_2_IP}
129     Log    ${get}
130     ${type}    Set Variable    odl-interface:tunnel-type-vxlan
131     ${tunnel-1}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
132     ...    ${type}
133     ${tunnel-2}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
134     ...    ${type}
135     ${tunnel-type}=    Set Variable    type: vxlan
136     Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
137     Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
138     Wait Until Keyword Succeeds    40    10    Genius.Ovs Verification For 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
139     ...    ${tunnel-1}    ${tunnel-type}
140     Wait Until Keyword Succeeds    40    10    Genius.Ovs Verification For 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_IP}
141     ...    ${tunnel-2}    ${tunnel-type}
142     ${url_2}    Set Variable    ${OPERATIONAL_API}/network-topology:network-topology/
143     Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${Bridge-1}    ${Bridge-2}    ${tunnel-1}
144     ...    ${tunnel-2}    ${url_2}
145     ${return}    Validate interface state    ${tunnel-1}    ${Dpn_id_1}    ${tunnel-2}    ${Dpn_id_2}
146     log    ${return}
147     ${lower-layer-if-1}    Get from List    ${return}    0
148     ${port-num-1}    Get From List    ${return}    1
149     ${lower-layer-if-2}    Get from List    ${return}    2
150     ${port-num-2}    Get From List    ${return}    3
151     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/
152     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
153     Log    ${respjson}
154     Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-1}
155     Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-2}
156     Wait Until Keyword Succeeds    40    10    Genius.Check Table0 Entry For 2 Dpn    ${conn_id_1}    ${Bridge-1}    ${port-num-1}
157     Wait Until Keyword Succeeds    40    10    Genius.Check Table0 Entry For 2 Dpn    ${conn_id_2}    ${Bridge-2}    ${port-num-2}
158     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/opendaylight-inventory:nodes/
159     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
160     Log    ${respjson}
161     Should Be Equal As Strings    ${resp.status_code}    200
162     Should Contain    ${resp.content}    ${lower-layer-if-2}    ${lower-layer-if-1}
163
164 Delete and Verify VTEP -Vlan
165     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
166     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
167     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
168     ${type}    Set Variable    odl-interface:tunnel-type-vxlan
169     ${tunnel-1}    Get_Tunnel    ${Dpn_id_1}    ${Dpn_id_2}    ${type}
170     ${tunnel-2}    Get_Tunnel    ${Dpn_id_2}    ${Dpn_id_1}    ${type}
171     Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
172     Wait Until Keyword Succeeds    40    10    Genius.Check ITM Tunnel State    ${tunnel-1}    ${tunnel-2}
173     Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_1}    ${tunnel-1}
174     Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_2}    ${tunnel-2}
175
176 Create VTEP - Vlan and Gateway
177     [Documentation]    This testcase creates a Internal Transport Manager - ITM tunnel between 2 DPNs with VLAN and Gateway configured in Json.
178     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
179     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
180     ${vlan}=    Set Variable    101
181     ${substr}    Should Match Regexp    ${TOOLS_SYSTEM_IP}    [0-9]\{1,3}\.[0-9]\{1,3}\.[0-9]\{1,3}\.
182     ${subnet}    Catenate    ${substr}0
183     ${gateway-ip}    Catenate    ${substr}1
184     Log    ${subnet}
185     Genius.Create Vteps    ${Dpn_id_1}    ${Dpn_id_2}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
186     Wait Until Keyword Succeeds    40    10    Get ITM    ${itm_created[0]}    ${subnet}    ${vlan}
187     ...    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${TOOLS_SYSTEM_2_IP}
188     ${type}    Set Variable    odl-interface:tunnel-type-vxlan
189     ${tunnel-1}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_1}    ${Dpn_id_2}
190     ...    ${type}
191     ${tunnel-2}    Wait Until Keyword Succeeds    40    10    Get Tunnel    ${Dpn_id_2}    ${Dpn_id_1}
192     ...    ${type}
193     ${tunnel-type}=    Set Variable    type: vxlan
194     Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
195     Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
196     Wait Until Keyword Succeeds    40    10    Genius.Ovs Verification For 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
197     ...    ${tunnel-1}    ${tunnel-type}
198     Wait Until Keyword Succeeds    40    10    Genius.Ovs Verification For 2 Dpn    ${conn_id_2}    ${TOOLS_SYSTEM_2_IP}    ${TOOLS_SYSTEM_IP}
199     ...    ${tunnel-2}    ${tunnel-type}
200     ${resp}    Wait Until Keyword Succeeds    40    10    Get Network Topology with Tunnel    ${Bridge-1}    ${Bridge-2}
201     ...    ${tunnel-1}    ${tunnel-2}    ${OPERATIONAL_TOPO_API}
202     Log    ${resp}
203     ${return}    Validate interface state    ${tunnel-1}    ${Dpn_id_1}    ${tunnel-2}    ${Dpn_id_2}
204     log    ${return}
205     ${lower-layer-if-1}    Get from List    ${return}    0
206     ${port-num-1}    Get From List    ${return}    1
207     ${lower-layer-if-2}    Get from List    ${return}    2
208     ${port-num-2}    Get From List    ${return}    3
209     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/
210     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
211     Log    ${respjson}
212     Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-1}
213     Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-2}
214     Wait Until Keyword Succeeds    40    10    Genius.Check Table0 Entry For 2 Dpn    ${conn_id_1}    ${Bridge-1}    ${port-num-1}
215     Wait Until Keyword Succeeds    40    10    Genius.Check Table0 Entry For 2 Dpn    ${conn_id_2}    ${Bridge-2}    ${port-num-2}
216     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/opendaylight-inventory:nodes/
217     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
218     Log    ${respjson}
219     Should Be Equal As Strings    ${resp.status_code}    200
220     Should Contain    ${resp.content}    ${lower-layer-if-2}    ${lower-layer-if-1}
221
222 Delete VTEP -Vlan and gateway
223     [Documentation]    This testcase deletes the ITM tunnel created between 2 dpns.
224     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
225     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
226     ${type}    Set Variable    odl-interface:tunnel-type-vxlan
227     ${tunnel-1}    Get_Tunnel    ${Dpn_id_1}    ${Dpn_id_2}    ${type}
228     ${tunnel-2}    Get_Tunnel    ${Dpn_id_2}    ${Dpn_id_1}    ${type}
229     Remove All Elements At URI And Verify    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}/
230     Wait Until Keyword Succeeds    40    10    Genius.Check ITM Tunnel State    ${tunnel-1}    ${tunnel-2}
231     Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_1}    ${tunnel-1}
232     Wait Until Keyword Succeeds    40    10    Genius.Check Tunnel Delete On OVS    ${conn_id_2}    ${tunnel-2}
233
234 *** Keywords ***
235 Create Vteps IPv6
236     [Arguments]    ${Dpn_id_1}    ${Dpn_id_2}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
237     [Documentation]    This keyword creates VTEPs between ${TOOLS_SYSTEM_IP} and ${TOOLS_SYSTEM_2_IP}
238     ${body}    OperatingSystem.Get File    ${genius_config_dir}/Itm_creation_no_vlan.json
239     ${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}:
240     ${subnet}    Catenate    ${substr}0
241     Log    ${subnet}
242     Set Global Variable    ${subnet}
243     ${vlan}=    Set Variable    ${vlan}
244     ${gateway-ip}=    Set Variable    ${gateway-ip}
245     ${body}    Genius.Set Json    ${Dpn_id_1}    ${Dpn_id_2}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}
246     ...    ${gateway-ip}    ${subnet}
247     Post Log Check    ${CONFIG_API}/itm:transport-zones/    ${body}    204
248
249 Get Tunnel
250     [Arguments]    ${src}    ${dst}    ${type}
251     [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.
252     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${src}/${dst}/${type}/
253     log    ${resp.content}
254     Log    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${src}/${dst}/
255     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
256     Log    ${respjson}
257     Should Be Equal As Strings    ${resp.status_code}    200
258     Should Contain    ${resp.content}    ${src}    ${dst}
259     ${json}=    evaluate    json.loads('''${resp.content}''')    json
260     log to console    \nOriginal JSON:\n${json}
261     ${return}    Run Keyword And Return Status    Should contain    ${resp.content}    tunnel-interface-names
262     log    ${return}
263     ${ret}    Run Keyword If    '${return}'=='True'    Check Interface Name    ${json["internal-tunnel"][0]}    tunnel-interface-names
264     [Return]    ${ret}
265
266 Validate interface state
267     [Arguments]    ${tunnel-1}    ${dpid-1}    ${tunnel-2}    ${dpid-2}
268     [Documentation]    Validates the created Interface Tunnel by checking its Operational status as UP/DOWN from the dump.
269     Log    ${tunnel-1},${dpid-1},${tunnel-2},${dpid-2}
270     ${data1-2}    Wait Until Keyword Succeeds    40    10    Check Interface Status    ${tunnel-1}    ${dpid-1}
271     ${data2-1}    Wait Until Keyword Succeeds    40    10    Check Interface Status    ${tunnel-2}    ${dpid-2}
272     @{data}    combine lists    ${data1-2}    ${data2-1}
273     log    ${data}
274     [Return]    ${data}
275
276 Get ITM
277     [Arguments]    ${itm_created[0]}    ${subnet}    ${vlan}    ${Dpn_id_1}    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}
278     ...    ${TOOLS_SYSTEM_2_IP}
279     [Documentation]    It returns the created ITM Transport zone with the passed values during the creation is done.
280     Log    ${itm_created[0]},${subnet}, ${vlan}, ${Dpn_id_1},${TOOLS_SYSTEM_IP}, ${Dpn_id_2}, ${TOOLS_SYSTEM_2_IP}
281     @{Itm-no-vlan}    Create List    ${itm_created[0]}    ${subnet}    ${vlan}    ${Dpn_id_1}    ${Bridge-1}-eth1
282     ...    ${TOOLS_SYSTEM_IP}    ${Dpn_id_2}    ${Bridge-2}-eth1    ${TOOLS_SYSTEM_2_IP}
283     Check For Elements At URI    ${CONFIG_API}/itm:transport-zones/transport-zone/${itm_created[0]}    ${Itm-no-vlan}
284
285 Get Network Topology with Tunnel
286     [Arguments]    ${Bridge-1}    ${Bridge-2}    ${tunnel-1}    ${tunnel-2}    ${url}
287     [Documentation]    Returns the Network topology with Tunnel info in it.
288     @{bridges}    Create List    ${Bridge-1}    ${Bridge-2}    ${tunnel-1}    ${tunnel-2}
289     Check For Elements At URI    ${url}    ${bridges}
290
291 Get Network Topology without Tunnel
292     [Arguments]    ${url}    ${tunnel-1}    ${tunnel-2}
293     [Documentation]    Returns the Network Topology after Deleting of ITM transport zone is done , which wont be having any TUNNEL info in it.
294     @{tunnels}    create list    ${tunnel-1}    ${tunnel-2}
295     Check For Elements Not At URI    ${url}    ${tunnels}
296
297 Validate interface state Delete
298     [Arguments]    ${tunnel}
299     [Documentation]    Check for the Tunnel / Interface absence in OPERATIONAL data base of IETF interface after ITM transport zone is deleted.
300     Log    ${tunnel}
301     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
302     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
303     Log    ${respjson}
304     Should Be Equal As Strings    ${resp.status_code}    404
305     Should not contain    ${resp.content}    ${tunnel}
306
307 check-Tunnel-delete-on-ovs
308     [Arguments]    ${connection-id}    ${tunnel}
309     [Documentation]    Verifies the Tunnel is deleted from OVS
310     Log    ${tunnel}
311     Switch Connection    ${connection-id}
312     Log    ${connection-id}
313     ${return}    Execute Command    sudo ovs-vsctl show
314     Log    ${return}
315     Should Not Contain    ${return}    ${tunnel}
316     [Return]    ${return}
317
318 Check Interface Status
319     [Arguments]    ${tunnel}    ${dpid}
320     [Documentation]    Verifies the operational state of the interface .
321     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
322     Log    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
323     ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
324     Log    ${respjson}
325     Should Be Equal As Strings    ${resp.status_code}    200
326     Should not contain    ${resp.content}    down
327     Should Contain    ${resp.content}    ${tunnel}    up    up
328     ${result-1}    re.sub    <.*?>    ,    ${resp.content}
329     Log    ${result-1}
330     ${lower_layer_if}    Should Match Regexp    ${result-1}    openflow:${dpid}:[0-9]+
331     log    ${lower_layer_if}
332     @{resp_array}    Split String    ${lower_layer_if}    :
333     ${port-num}    Get From List    ${resp_array}    2
334     Log    ${port-num}
335     [Return]    ${lower_layer_if}    ${port-num}
336
337 Verify Data Base after Delete
338     [Arguments]    ${Dpn_id_1}    ${Dpn_id_2}    ${tunnel-1}    ${tunnel-2}
339     [Documentation]    Verifies the config database after the Tunnel deletion is done.
340     ${type}    Set Variable    odl-interface:tunnel-type-vxlan
341     No Content From URI    session    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${Dpn_id_1}/${Dpn_id_2}/${type}/
342     No Content From URI    session    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${Dpn_id_2}/${Dpn_id_1}/${type}/
343     No Content From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
344     No Content From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
345     ${resp_7}    RequestsLibrary.Get Request    session    ${CONFIG_API}/ietf-interfaces:interfaces/
346     Run Keyword if    '${resp_7.content}'=='404'    Response is 404
347     Run Keyword if    '${resp_7.content}'=='200'    Response is 200
348     ${resp_8}    Wait Until Keyword Succeeds    40    10    Get Network Topology without Tunnel    ${CONFIG_TOPO_API}    ${tunnel-1}
349     ...    ${tunnel-2}
350     Log    ${resp_8}
351     Wait Until Keyword Succeeds    40    10    check-Tunnel-delete-on-ovs    ${conn_id_1}    ${tunnel-1}
352     Wait Until Keyword Succeeds    40    10    check-Tunnel-delete-on-ovs    ${conn_id_2}    ${tunnel-2}
353     Wait Until Keyword Succeeds    40    10    Get Network Topology without Tunnel    ${OPERATIONAL_TOPO_API}    ${tunnel-1}    ${tunnel-2}
354     Wait Until Keyword Succeeds    40    10    Validate interface state Delete    ${tunnel-1}
355     Wait Until Keyword Succeeds    40    10    Validate interface state Delete    ${tunnel-2}
356
357 Check Interface Name
358     [Arguments]    ${json}    ${expected_tunnel_interface_name}
359     [Documentation]    This keyword Checks the Tunnel interface name is tunnel-interface-names in the output or not .
360     ${Tunnels}    Collections.Get From Dictionary    ${json}    ${expected_tunnel_interface_name}
361     Log    ${Tunnels}
362     [Return]    ${Tunnels[0]}