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