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