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