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