Remove SXP beryllium resources
[integration/test.git] / csit / suites / netvirt / Netvirt_Vpnservice / BFD_Monitoring.robot
1 *** Settings ***
2 Documentation     Test suite for Tunnel Monitoring. More test cases to be added in subsequent patches.
3 Suite Setup       Start Suite
4 Suite Teardown    Stop Suite
5 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown     Get Test Teardown Debugs
7 Library           OperatingSystem
8 Library           RequestsLibrary
9 Resource          ../../../libraries/CompareStream.robot
10 Resource          ../../../libraries/OpenStackOperations.robot
11 Resource          ../../../libraries/DevstackUtils.robot
12 Resource          ../../../libraries/VpnOperations.robot
13 Resource          ../../../libraries/SetupUtils.robot
14 Resource          ../../../libraries/KarafKeywords.robot
15 Resource          ../../../libraries/OVSDB.robot
16 Resource          ../../../variables/netvirt/Variables.robot
17 Resource          ../../../variables/Variables.robot
18
19 *** Variables ***
20 ${BFD_ENABLED_FALSE}    false
21 ${BFD_ENABLED_TRUE}    true
22 ${PING_REGEXP}    , 0% packet loss
23 ${VAR_BASE}       ${CURDIR}/../../../variables/netvirt
24
25 *** Test Cases ***
26 TC00 Verify Setup
27     [Documentation]    Verify if tunnels are present. If not then create new tunnel.
28     : FOR    ${VM}    IN    @{VM_INSTANCES_NET1}    @{VM_INSTANCES_NET2}
29     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
30     ${VM_IP_NET1}    ${VM_IP_NET2}    Wait Until Keyword Succeeds    180s    10s    Verify VMs received IP
31     Set Suite Variable    ${VM_IP_NET2}
32     Set Suite Variable    ${VM_IP_NET1}
33     ${output}=    ITM Get Tunnels
34     Log    ${output}
35     ${count}=    Get Count    ${output}    tunnel_port
36     Log    ${count}
37     Run Keyword If    ${count} == 0    Create Tunnel
38     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_NET1}    @{VM_INSTANCES_NET2}
39     ...    AND    Get Suite Teardown Debugs
40
41 TC01 Verify That Default Tunnel Type Is Set To BFD
42     [Documentation]    Verify that the default tunnel type is set to BFD if both the devices support BFD
43     Log    Verifying ITM tunnel through REST
44     ${output}=    ITM Get Tunnels
45     Log    ${output}
46     Log    Verifying the BFD based tunnel configuration
47     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
48     Log    ${output}
49     Should Contain    ${output}    ${TUNNEL_MONITOR_ON}
50     Should Contain    ${output}    ${MONITORING_INTERVAL}
51     Should Contain    ${output}    ${INTERVAL_1000}
52     Log    Verifying the tunnel state with show state command
53     Wait Until Keyword Succeeds    30s    5s    Verify Tunnel Status as UP
54     Log    Verifying the default configuration i.e BFD, tunnel monitoring enabled
55     ${resp}    RequestsLibrary.Get Request    session    ${TUNNEL_MONITOR_URL}
56     Should Be Equal As Strings    ${resp.status_code}    ${RESP_CODE}
57     Log    ${resp.content}
58     Should Contain    ${resp.content}    ${BFD}
59     Should Contain    ${resp.content}    ${BFD_ENABLED_TRUE}
60     Log    Verifying the default monitor interval
61     ${resp}    RequestsLibrary.Get Request    session    ${MONITOR_INTERVAL_URL}
62     Should Be Equal As Strings    ${resp.status_code}    ${RESP_CODE}
63     Log    ${resp.content}
64     Should Contain    ${resp.content}    ${TMI_1000}
65     Log    Verifying the VXLAN Interface
66     Wait Until Keyword Succeeds    180s    10s    Verify VXLAN interface
67     Log    Verify Flows are present
68     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present    ${OS_COMPUTE_1_IP}
69     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present    ${OS_COMPUTE_2_IP}
70     Log    Verify Ping Between VMs on different Compute Nodes
71     Wait Until Keyword Succeeds    30s    5s    Verify Ping
72
73 TC02 Verify that Tunnel Monitoring can be disabled and monitor interval can be configured through REST
74     [Documentation]    Verify that Tunnel Monitoring can be disabled and monitor interval can be configured through REST
75     Log    Verifying ITM tunnel are present and tunnel status
76     ${output}=    ITM Get Tunnels
77     Log    ${output}
78     Wait Until Keyword Succeeds    10s    5s    Verify Tunnel Status as UP
79     Log    Verifying the BFD based tunnel configuration is on
80     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
81     Log    ${output}
82     Should Contain    ${output}    ${TUNNEL_MONITOR_ON}
83     Log    Disabling the tunnel monitoring from REST
84     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/disable_tunnel_monitoring    session=session
85     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Monitoring    ${BFD_ENABLED_FALSE}    ${BFD}
86     Log    Verifying the default tunnel monitoring is off
87     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
88     Log    ${output}
89     Should Contain    ${output}    ${TUNNEL_MONITOR_OFF}
90     Wait Until Keyword Succeeds    10s    5s    Verify Tunnel Status as UP
91     Log    Verifying the default monitoring interval i.e 1000ms via REST
92     ${resp}=    RequestsLibrary.Get Request    session    ${MONITOR_INTERVAL_URL}
93     Log    ${resp.content}
94     Should Be Equal As Strings    ${resp.status_code}    ${RESP_CODE}
95     Should Contain    ${resp.content}    ${TMI_1000}
96     Log    Change and verify the default tunnel monitoring interval after monitoring is disabled
97     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/monitor_interval    mapping={"int":"2000"}    session=session
98     ${resp}=    RequestsLibrary.Get Request    session    ${MONITOR_INTERVAL_URL}
99     Log    ${resp.content}
100     Should Be Equal As Strings    ${resp.status_code}    ${RESP_CODE}
101     Should Contain    ${resp.content}    ${TMI_2000}
102
103 TC03 Verify that the monitoring interval value boundaries with Monitoring Enabled
104     [Documentation]    Verify that the monitoring interval value boundaries with Monitoring Enabled
105     Log    Verifying ITM tunnel are present and tunnel status
106     ${output}=    ITM Get Tunnels
107     Log    ${output}
108     Wait Until Keyword Succeeds    10s    5s    Verify Tunnel Status as UP
109     Log    Enabling the tunnel monitoring from REST
110     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/enable_tunnel_monitoring    session=session
111     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Monitoring    ${BFD_ENABLED_TRUE}    ${BFD}
112     Log    Verifying the tunnel status
113     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
114     Log    ${output}
115     Should Contain    ${output}    ${TUNNEL_MONITOR_ON}
116     Log    Changing and verifying the tunnel monitoring interval to 1000ms
117     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/monitor_interval    mapping={"int":"1000"}    session=session
118     ${resp}=    RequestsLibrary.Get Request    session    ${MONITOR_INTERVAL_URL}
119     Log    ${resp.content}
120     Should Be Equal As Strings    ${resp.status_code}    ${RESP_CODE}
121     Should Contain    ${resp.content}    ${TMI_1000}
122     Log    Setting the tunnel monitoring interval to 30000ms
123     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/monitor_interval    mapping={"int":"30000"}    session=session
124     Log    Verifying the tunnel monitoring interval to 30000ms
125     Wait Until Keyword Succeeds    10s    1s    Check Tunnel Monitoring Interval    ${TMI_30000}
126     Log    Verifying the tunnel monitoring interval to greater than 30000ms cannot be set
127     ${resp}=    RequestsLibrary.Put Request    session    ${MONITOR_INTERVAL_NEW}    data=${INTERVAL_31000}
128     Should Be Equal As Strings    ${resp.status_code}    ${RESP_ERROR_CODE}
129     Wait Until Keyword Succeeds    10s    1s    Check Tunnel Monitoring Interval    ${TMI_30000}
130     Log    Verifying the tunnel monitoring interval to 50ms cannot be set
131     ${resp}=    RequestsLibrary.Put Request    session    ${MONITOR_INTERVAL_NEW}    data=${INTERVAL_50}
132     Should Be Equal As Strings    ${resp.status_code}    ${RESP_ERROR_CODE}
133     Wait Until Keyword Succeeds    10s    1s    Check Tunnel Monitoring Interval    ${TMI_30000}
134     Log    Verifying the tunnel monitoring interval to 0ms cannot be set
135     ${resp}=    RequestsLibrary.Put Request    session    ${MONITOR_INTERVAL_NEW}    data=${INTERVAL_0}
136     Should Be Equal As Strings    ${resp.status_code}    ${RESP_ERROR_CODE}
137     Wait Until Keyword Succeeds    10s    1s    Check Tunnel Monitoring Interval    ${TMI_30000}
138     Log    Verifying the tunnel monitoring interval to a negative value cannot be set
139     ${resp}=    RequestsLibrary.Put Request    session    ${MONITOR_INTERVAL_NEW}    data=${INTERVAL_NEG}
140     Should Be Equal As Strings    ${resp.status_code}    ${RESP_ERROR_CODE}
141     Wait Until Keyword Succeeds    10s    1s    Check Tunnel Monitoring Interval    ${TMI_30000}
142     Log    Restoring back to default moitor interval
143     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/monitor_interval    mapping={"int":"1000"}    session=session
144     ${resp}    RequestsLibrary.Get Request    session    ${MONITOR_INTERVAL_URL}
145     Log    ${resp.content}
146     Should Contain    ${resp.content}    ${TMI_1000}
147
148 TC04 Verify that the tunnel monitoring protocol can be configured to LLDP
149     [Documentation]    Verify that the tunnel monitoring protocol can be configured to LLDP
150     ${output} =    ITM Get Tunnels
151     Log    ${output}
152     Wait Until Keyword Succeeds    30s    5s    Verify Tunnel Status as UP
153     Log    Disabling the tunnel monitoring from REST in order to change the protocol
154     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/disable_tunnel_monitoring    session=session
155     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Monitoring    ${BFD_ENABLED_FALSE}    ${BFD}
156     Log    Changing the tunnel monitoring to LLDP and verify
157     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/disablemonitor_lldp    session=session
158     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Monitoring    ${BFD_ENABLED_FALSE}    ${LLDP}
159     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
160     Log    ${output}
161     Should Contain    ${output}    ${TUNNEL_MONITOR_OFF}
162     Log    Enabling tunnel monitoring
163     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/enablemonitor_lldp    session=session
164     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Monitoring    ${BFD_ENABLED_TRUE}    ${LLDP}
165     Wait Until Keyword Succeeds    30s    5s    Verify Tunnel Status as UP
166     Wait Until Keyword Succeeds    30s    5s    Verify Ping
167     Log    Verifying the monitoring interval
168     ${resp}    RequestsLibrary.Get Request    session    ${MONITOR_INTERVAL_URL}
169     Log    ${resp.content}
170     Should Be Equal As Strings    ${resp.status_code}    ${RESP_CODE}
171     Should Contain    ${resp.content}    ${TMI_1000}
172     Log    Changing the tunnel monitoring interval
173     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/monitor_interval    mapping={"int":"20000"}    session=session
174     Log    Verifying the monitoring interval got changed
175     ${resp}    RequestsLibrary.Get Request    session    ${MONITOR_INTERVAL_URL}
176     Log    ${resp.content}
177     Should Be Equal As Strings    ${resp.status_code}    ${RESP_CODE}
178     Should Contain    ${resp.content}    ${TMI_20000}
179     Log    Changing the tunnel monitoring back to bfd and verify
180     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/disablemonitor_lldp    session=session
181     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Monitoring    ${BFD_ENABLED_FALSE}    ${LLDP}
182     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/disable_tunnel_monitoring    session=session
183     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Monitoring    ${BFD_ENABLED_FALSE}    ${BFD}
184     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_BASE}/enable_tunnel_monitoring    session=session
185     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Monitoring    ${BFD_ENABLED_TRUE}    ${BFD}
186     Wait Until Keyword Succeeds    90s    5s    Verify Tunnel Status as UP
187     Wait Until Keyword Succeeds    60s    5s    Verify Ping
188
189 TC05 Disconnect And Reconnect Compute Nodes
190     [Documentation]    Verify that when compute nodes are disconnected from controller tunnel goes to unknown state.
191     ${output} =    ITM Get Tunnels
192     Log    ${output}
193     Wait Until Keyword Succeeds    90s    5s    Verify Tunnel Status as UP
194     Log    Disconnect Compute Nodes
195     Disconnect Compute Nodes    ${OS_COMPUTE_1_IP}    ${ODL_SYSTEM_IP}
196     Disconnect Compute Nodes    ${OS_COMPUTE_2_IP}    ${ODL_SYSTEM_IP}
197     Disconnect Compute Nodes    ${OS_CONTROL_NODE_IP}    ${ODL_SYSTEM_IP}
198     Wait Until Keyword Succeeds    120s    5s    Verify Tunnel Status as UNKNOWN
199     Wait Until Keyword Succeeds    60s    5s    Verify Ping
200     Log    Reconect Compute Nodes
201     Reconnect Compute Nodes    ${OS_COMPUTE_1_IP}    ${ODL_SYSTEM_IP}
202     Reconnect Compute Nodes    ${OS_COMPUTE_2_IP}    ${ODL_SYSTEM_IP}
203     Reconnect Compute Nodes    ${OS_CONTROL_NODE_IP}    ${ODL_SYSTEM_IP}
204     Wait Until Keyword Succeeds    120s    5s    Verify Tunnel Status as UP
205     Log    Verifying Tunnel Monitoring
206     ${resp}    RequestsLibrary.Get Request    session    ${TUNNEL_MONITOR_URL}
207     Log    ${resp.content}
208     Should Be Equal As Strings    ${resp.status_code}    ${RESP_CODE}
209     Should Contain    ${resp.content}    ${BFD_ENABLED_TRUE}
210     Should Contain    ${resp.content}    ${BFD}
211     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present    ${OS_COMPUTE_1_IP}
212     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present    ${OS_COMPUTE_2_IP}
213     Wait Until Keyword Succeeds    30s    5s    Verify Ping
214
215 *** Keywords ***
216 Start Suite
217     [Documentation]    Run before the suite execution
218     DevstackUtils.Devstack Suite Setup
219     SetupUtils.Setup_Utils_For_Setup_And_Teardown
220     Presuite Cleanup
221     Create Setup
222
223 Stop Suite
224     [Documentation]    Run after the tests execution
225     Delete Setup
226     Close All Connections
227
228 Presuite Cleanup
229     [Documentation]    Clean the already existing tunnels and tep interfaces
230     ${resp}    RequestsLibrary.Delete Request    session    ${TUNNEL_TRANSPORTZONE}
231     Log    ${resp.content}
232     ${resp}    RequestsLibrary.Delete Request    session    ${TUNNEL_INTERFACES}
233     Log    ${resp.content}
234
235 Create Setup
236     [Documentation]    Create Two Networks, Two Subnets, Four Ports And Four VMs
237     Log    Create two networks
238     Create Network    ${NETWORKS[0]}
239     Create Network    ${NETWORKS[1]}
240     ${NET_LIST}    List Networks
241     Should Contain    ${NET_LIST}    ${NETWORKS[0]}
242     Should Contain    ${NET_LIST}    ${NETWORKS[1]}
243     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${NETWORK_URL}    ${NETWORKS}
244     Log    Create two subnets for previously created networks
245     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNET_CIDR[0]}
246     Create SubNet    ${NETWORKS[1]}    ${SUBNETS[1]}    ${SUBNET_CIDR[1]}
247     ${SUB_LIST}    List Subnets
248     Should Contain    ${SUB_LIST}    ${SUBNETS[0]}
249     Should Contain    ${SUB_LIST}    ${SUBNETS[1]}
250     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${SUBNETWORK_URL}    ${SUBNETS}
251     Neutron Security Group Create    sg-vpnservice1
252     Neutron Security Group Rule Create    sg-vpnservice1    direction=ingress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
253     Neutron Security Group Rule Create    sg-vpnservice1    direction=egress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
254     Neutron Security Group Rule Create    sg-vpnservice1    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
255     Neutron Security Group Rule Create    sg-vpnservice1    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
256     Neutron Security Group Rule Create    sg-vpnservice1    direction=ingress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
257     Neutron Security Group Rule Create    sg-vpnservice1    direction=egress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
258     Log    Create four ports under previously created subnets
259     Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}    sg=sg-vpnservice1
260     Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=sg-vpnservice1
261     Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=sg-vpnservice1
262     Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=sg-vpnservice1
263     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${PORT_URL}    ${PORT_LIST}
264     Log    Create VM Instances
265     Create Vm Instance With Port On Compute Node    ${PORT_LIST[0]}    ${VM_INSTANCES_NET1[0]}    ${OS_COMPUTE_1_IP}    sg=sg-vpnservice1
266     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES_NET1[1]}    ${OS_COMPUTE_2_IP}    sg=sg-vpnservice1
267     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES_NET2[0]}    ${OS_COMPUTE_1_IP}    sg=sg-vpnservice1
268     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES_NET2[1]}    ${OS_COMPUTE_2_IP}    sg=sg-vpnservice1
269
270 Verify VMs received IP
271     [Documentation]    Verify VMs received IP
272     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
273     ...    true    @{VM_INSTANCES_NET1}
274     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    60s    5s    Collect VM IP Addresses
275     ...    true    @{VM_INSTANCES_NET2}
276     ${VM_IP_NET1}    ${NET1_DHCP_IP}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET1}
277     ${VM_IP_NET2}    ${NET2_DHCP_IP}    Collect VM IP Addresses    false    @{VM_INSTANCES_NET2}
278     ${VM_INSTANCES}=    Collections.Combine Lists    ${VM_INSTANCES_NET1}    ${VM_INSTANCES_NET2}
279     ${VM_IPS}=    Collections.Combine Lists    ${VM_IP_NET1}    ${VM_IP_NET2}
280     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES_NET1}
281     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
282     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
283     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
284     Log    ${VM_IP_NET1}
285     Log    ${VM_IP_NET2}
286     Should Not Contain    ${VM_IP_NET2}    None
287     Should Not Contain    ${VM_IP_NET1}    None
288     [Return]    ${VM_IP_NET1}    ${VM_IP_NET2}
289
290 Verify Ping
291     [Documentation]    Verify Ping among VMs
292     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[0]}    ping -c 3 ${VM_IP_NET1[1]}
293     Should Contain    ${output}    ${PING_REGEXP}
294     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[0]}    ping -c 3 ${VM_IP_NET2[1]}
295     Should Contain    ${output}    ${PING_REGEXP}
296     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET1[1]}    ping -c 3 ${VM_IP_NET1[0]}
297     Should Contain    ${output}    ${PING_REGEXP}
298     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET2[1]}    ping -c 3 ${VM_IP_NET2[0]}
299     Should Contain    ${output}    ${PING_REGEXP}
300
301 Verify Flows Are Present
302     [Arguments]    ${ip}
303     [Documentation]    Verify Flows Are Present
304     ${flow_output}=    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
305     Log    ${flow_output}
306     ${resp}=    Should Contain    ${flow_output}    table=50
307     Log    ${resp}
308     ${resp}=    Should Match regexp    ${flow_output}    table=0.*goto_table:36
309     ${resp}=    Should Match regexp    ${flow_output}    table=0.*goto_table:17
310     ${table51_output} =    Get Lines Containing String    ${flow_output}    table=51
311     Log    ${table51_output}
312     @{table51_output}=    Split To Lines    ${table51_output}    0    -1
313     : FOR    ${line}    IN    @{table51_output}
314     \    Log    ${line}
315     \    ${resp}=    Should Match Regexp    ${line}    ${MAC_REGEX}
316
317 Disconnect Compute Nodes
318     [Arguments]    ${Compute_node_ip}    ${Controller_ip}
319     ${current_ssh_connection}=    SSHLibrary.Get Connection
320     ${conn_id}=    SSHLibrary.Open Connection    ${Compute_node_ip}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=${DEFAULT_TIMEOUT}
321     Flexible SSH Login    ${DEFAULT_USER}    ${EMPTY}
322     ${cmd}=    BuiltIn.Set Variable    sudo ovs-vsctl set Controller br-int target="tcp\\:${Controller_ip}\\:6654"
323     ${cntlstdout}    Write Commands Until Prompt    ${cmd}
324     Log    ${cntlstdout}
325     ${output}=    Write Commands Until Prompt    sudo ovs-vsctl show
326     Log    ${output}
327     SSHLibrary.Close Connection
328
329 Reconnect Compute Nodes
330     [Arguments]    ${Compute_node_ip}    ${Controller_ip}
331     ${current_ssh_connection}=    SSHLibrary.Get Connection
332     ${conn_id}=    SSHLibrary.Open Connection    ${Compute_node_ip}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=${DEFAULT_TIMEOUT}
333     Flexible SSH Login    ${DEFAULT_USER}    ${EMPTY}
334     ${cmd}=    BuiltIn.Set Variable    sudo ovs-vsctl set Controller br-int target="tcp\\:${Controller_ip}\\:6653"
335     ${cntlstdout}    Write Commands Until Prompt    ${cmd}
336     Log    ${cntlstdout}
337     ${output}=    Write Commands Until Prompt    sudo ovs-vsctl show
338     Log    ${output}
339     SSHLibrary.Close Connection
340
341 Check Tunnel Monitoring Interval
342     [Arguments]    ${TMI_INTERVAL}
343     [Documentation]    Check the tunnel monitoring interval through REST
344     ${resp}    RequestsLibrary.Get Request    session    ${MONITOR_INTERVAL_URL}
345     Log    ${resp.content}
346     Should Be Equal As Strings    ${resp.status_code}    ${RESP_CODE}
347     Should Contain    ${resp.content}    ${TMI_INTERVAL}
348
349 Verify Tunnel Monitoring
350     [Arguments]    ${BFD_STATUS}    ${PROTOCOL}
351     [Documentation]    Check the tunnel monitoring status
352     ${resp}=    RequestsLibrary.Get Request    session    ${TUNNEL_MONITOR_URL}
353     Log    ${resp.content}
354     Should Be Equal As Strings    ${resp.status_code}    ${RESP_CODE}
355     Should Contain    ${resp.content}    ${BFD_STATUS}
356     Should Contain    ${resp.content}    ${PROTOCOL}
357
358 Create Tunnel
359     [Documentation]    Create tunnels betwee the 2 compute nodes and Openstack controller.
360     Log    If ODL version is Boron or higher then ITM tunnel should be auto configured. If not then the suite should fail. For ODL version Beryllium or lower, ITM tunnel should be created.
361     CompareStream.Run_Keyword_If_At_Least_Boron    BuiltIn.Fail    Tunnel should be auto configured for ${ODL_STREAM}
362     ${node_1_dpid}=    Get DPID    ${OS_COMPUTE_1_IP}
363     ${node_2_dpid}=    Get DPID    ${OS_COMPUTE_2_IP}
364     ${node_3_dpid}=    Get DPID    ${OS_CONTROL_NODE_IP}
365     ${node_1_adapter}=    Get Ethernet Adapter    ${OS_COMPUTE_1_IP}
366     ${node_2_adapter}=    Get Ethernet Adapter    ${OS_COMPUTE_2_IP}
367     ${node_3_adapter}=    Get Ethernet Adapter    ${OS_CONTROL_NODE_IP}
368     ${first_two_octets}    ${third_octet}    ${last_octet}=    Split String From Right    ${OS_COMPUTE_1_IP}    .    2
369     ${subnet}=    Set Variable    ${first_two_octets}.0.0/16
370     ${gateway}=    Get Default Gateway    ${OS_COMPUTE_1_IP}
371     ${gateway1}=    Get Default Gateway    ${OS_CONTROL_NODE_IP}
372     ${gateway2}=    Get Default Gateway    ${OS_COMPUTE_2_IP}
373     Issue Command On Karaf Console    tep:add ${node_1_dpid} ${node_1_adapter} 0 ${OS_COMPUTE_1_IP} ${subnet} null TZA
374     Issue Command On Karaf Console    tep:add ${node_2_dpid} ${node_2_adapter} 0 ${OS_COMPUTE_2_IP} ${subnet} null TZA
375     Issue Command On Karaf Console    tep:add ${node_3_dpid} ${node_3_adapter} 0 ${OS_CONTROL_NODE_IP} ${subnet} null TZA
376     Issue Command On Karaf Console    tep:commit
377     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
378     Log    ${output}
379     Wait Until Keyword Succeeds    30s    5s    Verify Tunnel Status as UP
380
381 Delete Setup
382     [Documentation]    Delete the created VMs, ports, subnet and networks
383     Log    Delete the VM instances
384     ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET1}    @{VM_INSTANCES_NET2}
385     : FOR    ${VmInstance}    IN    @{VM_INSTANCES}
386     \    Delete Vm Instance    ${VmInstance}
387     Log    Delete neutron ports
388     : FOR    ${Port}    IN    @{PORT_LIST}
389     \    Delete Port    ${Port}
390     Log    Delete subnets
391     : FOR    ${Subnet}    IN    @{SUBNETS}
392     \    Delete SubNet    ${Subnet}
393     Log    Delete networks
394     : FOR    ${Network}    IN    @{NETWORKS}
395     \    Delete Network    ${Network}
396     Delete SecurityGroup    sg-vpnservice1