2 Documentation L2Gateway Operations Library. This library has useful keywords for various actions on Hwvtep and Ovs connectivity. Most of the keywords expects that ovs_conn_id,ovs2_conn_id, hwvtep_conn_id, hwvtep2_conn_id and OS_CNTL_CONN_ID are available.
6 Library RequestsLibrary
9 Resource MininetKeywords.robot
10 Resource VpnOperations.robot
11 Resource OpenStackOperations.robot
12 Resource DevstackUtils.robot
13 Resource ../variables/l2gw/Variables.robot
14 Resource ../variables/netvirt/Variables.robot
18 ${L2GW_VAR_BASE} ${CURDIR}/../variables/l2gw
22 Add Ovs Bridge Manager Controller And Verify
23 [Documentation] Keyword to set OVS manager and controller to ${ODL_IP} for the OVS IP connected in ${conn_id} and verify the entries in OVSDB NETWORK TOPOLOGY and NETSTAT results.
24 [Arguments] ${conn_id}=${OS_CMP1_CONN_ID} ${hwvtep_bridge}=${HWVTEP_BRIDGE}
25 ${output}= Exec Command ${conn_id} ${OVS_RESTART}
26 ${output}= Exec Command ${conn_id} ${OVS_DEL_MGR}
27 ${output}= Exec Command ${conn_id} ${OVS_DEL_CTRLR} ${INTEGRATION_BRIDGE}
28 ${output}= Exec Command ${conn_id} ${DEL_OVS_BRIDGE} ${INTEGRATION_BRIDGE}
29 ${output}= Exec Command ${conn_id} ${OVS_SHOW}
30 Should Not Contain ${output} Manager
31 Should Not Contain ${output} Controller
32 ${output}= Exec Command ${conn_id} ${CREATE_OVS_BRIDGE} ${INTEGRATION_BRIDGE}
33 ${output}= Exec Command ${conn_id} ${SET_FAIL_MODE} ${INTEGRATION_BRIDGE} secure
34 ${output}= Exec Command ${conn_id} ${OVS_SET_MGR}:${ODL_IP}:${OVSDBPORT}
35 ${output}= Exec Command ${conn_id} ${OVS_SET_CTRLR} ${INTEGRATION_BRIDGE} tcp:${ODL_IP}:${ODL_OF_PORT}
36 Wait Until Keyword Succeeds
39 ... Verify Strings In Command Output
42 ... Manager "tcp:${ODL_IP}:${OVSDBPORT}"
43 ... Controller "tcp:${ODL_IP}:${ODL_OF_PORT}"
44 ${output}= Exec Command ${conn_id} ${NETSTAT}
45 Wait Until Keyword Succeeds 30s 2s Validate Regexp In String ${output} ${NETSTAT_OVSDB_REGEX}
46 Wait Until Keyword Succeeds 30s 2s Validate Regexp In String ${output} ${NETSTAT_OF_REGEX}
47 @{list_to_check}= Create List bridge/${INTEGRATION_BRIDGE} bridge/${hwvtep_bridge}
48 Wait Until Keyword Succeeds
51 ... Check For Elements At URI
52 ... ${OVSDB_NETWORK_TOPOLOGY}
56 Create Itm Tunnel Between Hwvtep and Ovs
57 [Documentation] Keyword to create ITM Tunnel Between HWVTEP and OVS connection in ${ovs_id}.
58 [Arguments] ${ovs_id} ${ovs_ip}
59 ${dpn_id}= Get Dpnid Decimal ${ovs_id}
60 ${first_two_octets} ${third_octet} ${last_octet}= Split String From Right ${ovs_ip} . 2
61 ${prefix}= Set Variable ${first_two_octets}.0.0/24
62 TemplatedRequests.Post_As_Json_Templated
63 ... folder=${L2GW_VAR_BASE}/itm_create
64 ... mapping={"dpnid":"${dpn_id}","ip":"${ovs_ip}","prefix":"${prefix}"}
66 ${output}= ITM Get Tunnels
69 Add Vtep Manager And Verify
70 [Documentation] Keyword to add vtep manager for HWVTEP connected in ${conn_id} as ${odl_ip} received in argument and verify the entries in NETSTAT and HWVTEP NETWORK TOPOLOGY.
71 [Arguments] ${odl_ip} ${conn_id}=${hwvtep_conn_id}
72 ${set_manager_command}= Set Variable ${VTEP_ADD_MGR}:${odl_ip}:${OVSDBPORT}
73 ${output}= Exec Command ${conn_id} ${set_manager_command}
75 @{list_to_verify}= Create List ${odl_ip} state=ACTIVE
76 Wait Until Keyword Succeeds 60s 2s Verify Vtep List ${conn_id} ${MANAGER_TABLE} @{list_to_verify}
77 ${output}= Exec Command ${conn_id} ${NETSTAT}
78 Should Contain ${output} ${OVSDBPORT}
79 @{list_to_check}= Create List ${odl_ip}
80 Wait Until Keyword Succeeds
83 ... Utils.Check For Elements At URI
84 ... ${HWVTEP_NETWORK_TOPOLOGY}
88 Create Verify L2Gateway
89 [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
90 [Arguments] ${bridge_name} ${intf_name} ${gw_name}
91 ${l2gw_output}= OpenStackOperations.Create L2Gateway ${bridge_name} ${intf_name} ${gw_name}
93 ${output}= OpenStackOperations.Get All L2Gateway
95 Should Contain ${output} ${gw_name}
96 @{list_to_check}= Create List ${gw_name}
97 Utils.Check For Elements At URI ${L2GW_LIST_REST_URL} ${list_to_check} session
100 Update And Verify L2Gateway
101 [Documentation] Keyword to add interface {intf_name_2} to an existing L2 Gateway ${gw_name} for bridge ${bridge_name} (Using Neutron CLI).
102 [Arguments] ${bridge_name} ${gw_name} ${intf_name_1} ${intf_name_2}
103 ${l2gw_output}= OpenStackOperations.Update L2Gateway
108 ${output}= OpenStackOperations.Get All L2Gateway
110 Should Contain ${output} ${gw_name}
111 Should Contain ${output} ${intf_name_1}
112 Should Contain ${output} ${intf_name_2}
113 @{list_to_check}= Create List ${gw_name}
114 Utils.Check For Elements At URI ${L2GW_LIST_REST_URL} ${list_to_check} session
115 RETURN ${l2gw_output}
118 [Documentation] Keyword to delete the L2 Gateway ${gw_name} received in argument.
119 ... If ${check_for_null} is True return of 404 is treated as empty list. From Neon onwards,
120 ... an empty list is always returned as null, giving 404 on rest call.
121 [Arguments] ${gw_name} ${check_for_null}=False
122 ${output}= Exec Command ${OS_CNTL_CONN_ID} ${L2GW_DELETE} ${gw_name}
124 @{list_to_check}= Create List ${gw_name}
125 BuiltIn.Wait Until Keyword Succeeds
128 ... Utils.Check For Elements Not At URI
129 ... ${L2GW_LIST_REST_URL}
132 ... check_for_null=${check_for_null}
134 Create Verify L2Gateway Connection
135 [Documentation] Keyword to create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
136 [Arguments] ${gw_name} ${net_name}
137 ${l2gw_output}= OpenStackOperations.Create L2Gateway Connection ${gw_name} ${net_name}
139 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${gw_name}
140 ${output}= OpenStackOperations.Get All L2Gateway Connection
142 Should Contain ${output} ${l2gw_id}
143 @{list_to_check}= Create List ${l2gw_id}
144 Utils.Check For Elements At URI ${L2GW_CONN_LIST_REST_URL} ${list_to_check} session
145 RETURN ${l2gw_output}
147 Verify L2Gateway Connection
148 [Documentation] Keyword to verify existing L2 Gateway Connection for ${gw_name} to ${net_name} $(Using Neutron CLI).
149 [Arguments] ${gw_name} ${net_name}
150 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${gw_name}
151 ${output}= OpenStackOperations.Get All L2Gateway Connection
153 Should Contain ${output} ${l2gw_id}
154 @{list_to_check}= Create List ${l2gw_id}
155 Utils.Check For Elements At URI ${L2GW_CONN_LIST_REST_URL} ${list_to_check} session
157 Delete L2Gateway Connection
158 [Documentation] Delete the L2 Gateway connection existing for Gateway ${gw_name} received in argument (Using Neutron CLI).
159 ... If ${check_for_null} is True return of 404 is treated as empty list. From Neon onwards, an empty list is always
160 ... returned as null, giving 404 on rest call.
161 [Arguments] ${gw_name} ${check_for_null}=False
162 ${l2gw_conn_id}= OpenStackOperations.Get L2gw Connection Id ${gw_name}
163 ${output}= Exec Command ${OS_CNTL_CONN_ID} ${L2GW_CONN_DELETE} ${l2gw_conn_id}
165 @{list_to_check}= Create List ${l2gw_conn_id}
166 BuiltIn.Wait Until Keyword Succeeds
169 ... Utils.Check For Elements Not At URI
170 ... ${L2GW_CONN_LIST_REST_URL}
173 ... check_for_null=${check_for_null}
175 Update Port For Hwvtep
176 [Documentation] Keyword to update the Neutron Ports for specific configuration required to connect to HWVTEP (Using REST).
177 [Arguments] ${port_name}
178 ${port_id}= Get Port Id ${port_name}
180 ${json_data}= Get Neutron Port Rest ${port_id}
181 Should Contain ${json_data} ${STR_VIF_TYPE}
182 Should Contain ${json_data} ${STR_VNIC_TYPE}
183 ${json_data}= Replace String ${json_data} ${STR_VIF_TYPE} ${STR_VIF_REPLACE}
184 ${json_data}= Replace String ${json_data} ${STR_VNIC_TYPE} ${STR_VNIC_REPLACE}
185 ${return}= OpenStackOperations.Update Port Rest ${port_id} ${json_data}
186 ${output}= OpenStackOperations.Get Neutron Port Rest ${port_id}
188 Should Contain ${output} ${STR_VIF_REPLACE}
189 Should Contain ${output} ${STR_VNIC_REPLACE}
190 Should Not Contain ${output} ${STR_VIF_TYPE}
191 Should Not Contain ${output} ${STR_VNIC_TYPE}
194 Attach Port To Hwvtep Namespace
195 [Documentation] Keyword to assign the ${port_mac} to the tap port ${tap_name} in namespace ${ns_name}
196 [Arguments] ${port_mac} ${ns_name} ${tap_name} ${conn_id}=${hwvtep_conn_id}
197 Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF} ${tap_name} ${HW_ETHER} ${port_mac}
198 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF}
199 Should Contain ${output} ${port_mac}
201 Namespace Dhclient Verify
202 [Documentation] Keyword to run dhclient for the tap port ${ns_tap} and verify if it has got assigned with ${ns_port_ip}.
203 [Arguments] ${ns_name} ${ns_tap} ${ns_port_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
204 Start Command In Hwvtep ${NETNS_EXEC} ${ns_name} dhclient ${ns_tap} ${hwvtep_ip}
205 Wait Until Keyword Succeeds
208 ... Verify Strings In Command Output
210 ... ${NETNS_EXEC} ${ns_name} ${IFCONF}
213 Verify Strings In Command Output
214 [Documentation] Keyword to run the ${command} in ${conn_id} and verify if the output contains the list @{string_list}.
215 [Arguments] ${conn_id} ${command} @{string_list}
216 ${output}= Exec Command ${conn_id} ${command}
217 FOR ${item} IN @{string_list}
218 Should Contain ${output} ${item}
221 Verify Ping In Namespace Extra Timeout
222 [Documentation] Keyword to ping the IP ${vm_ip} from ${ns_name} and verify MCAS Local Table contains ${ns_port_mac}.
223 [Arguments] ${ns_name} ${ns_port_mac} ${vm_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
224 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF}
226 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ping -c3 ${vm_ip} 30s
228 Should Not Contain ${output} ${PACKET_LOSS}
229 Wait Until Keyword Succeeds 30s 2s Verify Macs Local Table While Ping ${ns_port_mac} ${conn_id}
231 Verify Ping Fails In Namespace
232 [Documentation] Keyword to ping the IP ${vm_ip} from ${ns_name} and should verify that it fails
233 [Arguments] ${ns_name} ${ns_port_mac} ${vm_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
234 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ping -c3 ${vm_ip} 30s
236 Should Contain ${output} ${PACKET_LOSS}
238 Verify Macs Local Table While Ping
239 [Documentation] Keyword to check if ${mac} is available under UCAST_MACS_LOCALE_TABLE of HWVTEP dump table.
240 [Arguments] ${mac} ${conn_id}
241 Verify Vtep List ${conn_id} ${UCAST_MACS_LOCALE_TABLE} ${mac}
244 [Documentation] Keyword to verify if the VM has received IP, and to verify it is not null.
245 [Arguments] ${vm_name}
246 @{vm_ip} ${dhcp_ip}= Get VM IPs ${vm_name}
247 Should Not Contain ${vm_ip} None
248 Should Not Contain ${dhcp_ip} None
252 [Documentation] Keyword to collect the general debug information required for HWVTEP Test Suite.
253 Exec Command ${hwvtep_conn_id} ${OVSDB_CLIENT_DUMP}
254 OpenStackOperations.Get Test Teardown Debugs
255 ${resp}= RequestsLibrary.Get Request session ${CONFIG_API}/itm-state:external-tunnel-list/
257 ${resp}= RequestsLibrary.Get Request
259 ... ${CONFIG_API}/network-topology:network-topology/topology/hwvtep:1
261 ${resp}= RequestsLibrary.Get Request
263 ... ${OPERATIONAL_API}/network-topology:network-topology/topology/hwvtep:1
265 Exec Command ${OS_CNTL_CONN_ID} cat /etc/neutron/neutron.conf
266 Exec Command ${OS_CNTL_CONN_ID} cat /etc/neutron/l2gw_plugin.ini
267 Exec Command ${OS_CNTL_CONN_ID} ps -ef | grep neutron-server
269 Start Command In Hwvtep
270 [Documentation] Keyword to execute Start Command in HWVTEP IP.
271 [Arguments] ${command} ${hwvtep_ip}
272 ${conn_id}= SSHLibrary.Open Connection ${hwvtep_ip} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
274 Flexible SSH Login ${DEFAULT_USER} ${DEFAULT_PASSWORD}
275 Start Command ${command}
276 ${output}= Exec Command ${conn_id} sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -O Openflow13
281 [Documentation] Keyword to run vtep-ctl list for the table ${table_name} and verify the list @{list} contents exists in output.
282 [Arguments] ${conn_id} ${table_name} @{list}
283 ${output}= Exec Command ${conn_id} ${VTEP LIST} ${table_name}
284 FOR ${item} IN @{list}
285 Should Contain ${output} ${item}
289 [Documentation] Keyword to return the contents of vtep-ctl list for table ${table_name}.
290 [Arguments] ${table_name} ${conn_id}=${hwvtep_conn_id}
291 ${output}= Exec Command ${conn_id} ${VTEP LIST} ${table_name}
295 [Documentation] Keyword to return DPN ID in decimal for the br-int in IP connected via ${conn_id}.
296 [Arguments] ${conn_id}
297 ${output}= Exec Command ${conn_id} ${GET_DPNID}
299 ${splitted_output}= Split String ${output} ${EMPTY}
300 ${dpn_id}= Get from List ${splitted_output} 0
305 [Documentation] Keyword to verify that the OVS tunnel entries are configured for OVS and HWVTEP.
306 [Arguments] ${hwvtep_ip} ${ovs_ip} ${seg_id}=${NET_1_SEGID} ${conn_id}=${hwvtep_conn_id}
307 ${output}= Exec Command ${conn_id} ${OVS_SHOW}
309 Should Contain ${output} key="${seg_id}", remote_ip="${ovs_ip}"
310 ${output}= Exec Command ${OS_CMP1_CONN_ID} ${OVS_SHOW}
312 Should Contain ${output} key=flow, local_ip="${ovs_ip}", remote_ip="${hwvtep_ip}"
314 Get Vtep Field Values From Table
315 [Documentation] Keyword to return specific field value received in ${column_name} from the vtep-ctl list for ${table_name}.
316 [Arguments] ${table_name} ${column_name} ${conn_id}=${hwvtep_conn_id}
317 ${output}= Exec Command ${conn_id} ${VTEP_LIST_COLUMN}${column_name} list ${table_name} | awk '{print $3}'
319 @{keys}= Split String ${output}
323 Validate Regexp In String
324 [Arguments] ${string} ${regexp} ${verify_count}=1
325 @{occr}= Get Regexp Matches ${string} ${regexp}
326 ${count}= Get Length ${occr}
327 Should Be Equal As Integers ${count} ${verify_count}
330 [Arguments] ${conn_id} ${command} ${timeout}=10s
331 Switch Connection ${conn_id}
332 ${output}= DevstackUtils.Write Commands Until Prompt ${command} ${timeout}
336 Verify Elan Flow Entries
337 [Documentation] Verify Flows Are Present For ELAN service
338 [Arguments] ${ip} ${srcMacAddrs} ${destMacAddrs}
339 ${flow_output}= Run Command On Remote System
341 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
343 Should Contain ${flow_output} table=50
344 ${sMac_output}= Get Lines Containing String ${flow_output} table=50
346 FOR ${sMacAddr} IN @{srcMacAddrs}
347 ${resp}= Should Contain ${sMac_output} dl_src=${sMacAddr}
349 Should Contain ${flow_output} table=51
350 ${dMac_output}= Get Lines Containing String ${flow_output} table=51
352 FOR ${dMacAddr} IN @{destMacAddrs}
353 ${resp}= Should Contain ${dMac_output} dl_dst=${dMacAddr}
355 Should Contain ${flow_output} table=52
356 ${sMac_output}= Get Lines Containing String ${flow_output} table=52
359 Cleanup L2GW Optional Resources
360 [Documentation] Cleanup resources that are only allocated on certain combos...
361 OpenStackOperations.Delete Port ${HWVTEP_PORT_3}