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