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.
5 Library RequestsLibrary
8 Resource MininetKeywords.robot
9 Resource VpnOperations.robot
10 Resource OpenStackOperations.robot
11 Resource DevstackUtils.robot
12 Resource ../variables/l2gw/Variables.robot
13 Resource ../variables/netvirt/Variables.robot
16 ${L2GW_VAR_BASE} ${CURDIR}/../variables/l2gw
19 Add Ovs Bridge Manager Controller And Verify
20 [Arguments] ${conn_id}=${OS_CMP1_CONN_ID} ${hwvtep_bridge}=${HWVTEP_BRIDGE}
21 [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.
22 ${output}= Exec Command ${conn_id} ${OVS_RESTART}
23 ${output}= Exec Command ${conn_id} ${OVS_DEL_MGR}
24 ${output}= Exec Command ${conn_id} ${OVS_DEL_CTRLR} ${INTEGRATION_BRIDGE}
25 ${output}= Exec Command ${conn_id} ${DEL_OVS_BRIDGE} ${INTEGRATION_BRIDGE}
26 ${output}= Exec Command ${conn_id} ${OVS_SHOW}
27 Should Not Contain ${output} Manager
28 Should Not Contain ${output} Controller
29 ${output}= Exec Command ${conn_id} ${CREATE_OVS_BRIDGE} ${INTEGRATION_BRIDGE}
30 ${output}= Exec Command ${conn_id} ${SET_FAIL_MODE} ${INTEGRATION_BRIDGE} secure
31 ${output}= Exec Command ${conn_id} ${OVS_SET_MGR}:${ODL_IP}:${OVSDBPORT}
32 ${output}= Exec Command ${conn_id} ${OVS_SET_CTRLR} ${INTEGRATION_BRIDGE} tcp:${ODL_IP}:${ODL_OF_PORT}
33 Wait Until Keyword Succeeds 60s 2s Verify Strings In Command Output ${conn_id} ${OVS_SHOW} Manager "tcp:${ODL_IP}:${OVSDBPORT}"
34 ... Controller "tcp:${ODL_IP}:${ODL_OF_PORT}"
35 ${output}= Exec Command ${conn_id} ${NETSTAT}
36 Wait Until Keyword Succeeds 30s 2s Validate Regexp In String ${output} ${NETSTAT_OVSDB_REGEX}
37 Wait Until Keyword Succeeds 30s 2s Validate Regexp In String ${output} ${NETSTAT_OF_REGEX}
38 @{list_to_check}= Create List bridge/${INTEGRATION_BRIDGE} bridge/${hwvtep_bridge}
39 Wait Until Keyword Succeeds 30s 2s Check For Elements At URI ${OVSDB_NETWORK_TOPOLOGY} ${list_to_check} session
41 Create Itm Tunnel Between Hwvtep and Ovs
42 [Arguments] ${ovs_id} ${ovs_ip}
43 [Documentation] Keyword to create ITM Tunnel Between HWVTEP and OVS connection in ${ovs_id}.
44 ${dpn_id}= Get Dpnid Decimal ${ovs_id}
45 ${first_two_octets} ${third_octet} ${last_octet}= Split String From Right ${ovs_ip} . 2
46 ${prefix} = Set Variable ${first_two_octets}.0.0/24
47 TemplatedRequests.Post_As_Json_Templated folder=${L2GW_VAR_BASE}/itm_create mapping={"dpnid":"${dpn_id}","ip":"${ovs_ip}","prefix":"${prefix}"} session=session
48 ${output}= ITM Get Tunnels
51 Add Vtep Manager And Verify
52 [Arguments] ${odl_ip} ${conn_id}=${hwvtep_conn_id}
53 [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.
54 ${set_manager_command}= Set Variable ${VTEP_ADD_MGR}:${odl_ip}:${OVSDBPORT}
55 ${output}= Exec Command ${conn_id} ${set_manager_command}
57 @{list_to_verify}= Create List ${odl_ip} state=ACTIVE
58 Wait Until Keyword Succeeds 60s 2s Verify Vtep List ${conn_id} ${MANAGER_TABLE} @{list_to_verify}
59 ${output}= Exec Command ${conn_id} ${NETSTAT}
60 Should Contain ${output} ${OVSDBPORT}
61 @{list_to_check}= Create List ${odl_ip}
62 Wait Until Keyword Succeeds 30s 2s Utils.Check For Elements At URI ${HWVTEP_NETWORK_TOPOLOGY} ${list_to_check} session
64 Create Verify L2Gateway
65 [Arguments] ${bridge_name} ${intf_name} ${gw_name}
66 [Documentation] Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
67 ${l2gw_output}= OpenStackOperations.Create L2Gateway ${bridge_name} ${intf_name} ${gw_name}
69 ${output}= OpenStackOperations.Get All L2Gateway
71 Should Contain ${output} ${gw_name}
72 @{list_to_check}= Create List ${gw_name}
73 Utils.Check For Elements At URI ${L2GW_LIST_REST_URL} ${list_to_check} session
74 [Return] ${l2gw_output}
76 Update And Verify L2Gateway
77 [Arguments] ${bridge_name} ${gw_name} ${intf_name_1} ${intf_name_2}
78 [Documentation] Keyword to add interface {intf_name_2} to an existing L2 Gateway ${gw_name} for bridge ${bridge_name} (Using Neutron CLI).
79 ${l2gw_output}= OpenStackOperations.Update L2Gateway ${bridge_name} ${gw_name} ${intf_name_1} ${intf_name_2}
80 ${output}= OpenStackOperations.Get All L2Gateway
82 Should Contain ${output} ${gw_name}
83 Should Contain ${output} ${intf_name_1}
84 Should Contain ${output} ${intf_name_2}
85 @{list_to_check}= Create List ${gw_name}
86 Utils.Check For Elements At URI ${L2GW_LIST_REST_URL} ${list_to_check} session
87 [Return] ${l2gw_output}
90 [Arguments] ${gw_name} ${check_for_null}=False
91 [Documentation] Keyword to delete the L2 Gateway ${gw_name} received in argument.
92 ... If ${check_for_null} is True return of 404 is treated as empty list. From Neon onwards,
93 ... an empty list is always returned as null, giving 404 on rest call.
94 ${output}= Exec Command ${OS_CNTL_CONN_ID} ${L2GW_DELETE} ${gw_name}
96 @{list_to_check}= Create List ${gw_name}
97 BuiltIn.Wait Until Keyword Succeeds 5s 1s Utils.Check For Elements Not At URI ${L2GW_LIST_REST_URL} ${list_to_check} session
98 ... check_for_null=${check_for_null}
100 Create Verify L2Gateway Connection
101 [Arguments] ${gw_name} ${net_name}
102 [Documentation] Keyword to create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
103 ${l2gw_output}= OpenStackOperations.Create L2Gateway Connection ${gw_name} ${net_name}
105 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${gw_name}
106 ${output}= OpenStackOperations.Get All L2Gateway Connection
108 Should Contain ${output} ${l2gw_id}
109 @{list_to_check}= Create List ${l2gw_id}
110 Utils.Check For Elements At URI ${L2GW_CONN_LIST_REST_URL} ${list_to_check} session
111 [Return] ${l2gw_output}
113 Verify L2Gateway Connection
114 [Arguments] ${gw_name} ${net_name}
115 [Documentation] Keyword to verify existing L2 Gateway Connection for ${gw_name} to ${net_name} $(Using Neutron CLI).
116 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${gw_name}
117 ${output}= OpenStackOperations.Get All L2Gateway Connection
119 Should Contain ${output} ${l2gw_id}
120 @{list_to_check}= Create List ${l2gw_id}
121 Utils.Check For Elements At URI ${L2GW_CONN_LIST_REST_URL} ${list_to_check} session
123 Delete L2Gateway Connection
124 [Arguments] ${gw_name} ${check_for_null}=False
125 [Documentation] Delete the L2 Gateway connection existing for Gateway ${gw_name} received in argument (Using Neutron CLI).
126 ... If ${check_for_null} is True return of 404 is treated as empty list. From Neon onwards, an empty list is always
127 ... returned as null, giving 404 on rest call.
128 ${l2gw_conn_id}= OpenStackOperations.Get L2gw Connection Id ${gw_name}
129 ${output}= Exec Command ${OS_CNTL_CONN_ID} ${L2GW_CONN_DELETE} ${l2gw_conn_id}
131 @{list_to_check}= Create List ${l2gw_conn_id}
132 BuiltIn.Wait Until Keyword Succeeds 5s 1s Utils.Check For Elements Not At URI ${L2GW_CONN_LIST_REST_URL} ${list_to_check} session
133 ... check_for_null=${check_for_null}
135 Update Port For Hwvtep
136 [Arguments] ${port_name}
137 [Documentation] Keyword to update the Neutron Ports for specific configuration required to connect to HWVTEP (Using REST).
138 ${port_id}= Get Port Id ${port_name}
140 ${json_data}= Get Neutron Port Rest ${port_id}
141 Should Contain ${json_data} ${STR_VIF_TYPE}
142 Should Contain ${json_data} ${STR_VNIC_TYPE}
143 ${json_data}= Replace String ${json_data} ${STR_VIF_TYPE} ${STR_VIF_REPLACE}
144 ${json_data}= Replace String ${json_data} ${STR_VNIC_TYPE} ${STR_VNIC_REPLACE}
145 ${return}= OpenStackOperations.Update Port Rest ${port_id} ${json_data}
146 ${output}= OpenStackOperations.Get Neutron Port Rest ${port_id}
148 Should Contain ${output} ${STR_VIF_REPLACE}
149 Should Contain ${output} ${STR_VNIC_REPLACE}
150 Should Not Contain ${output} ${STR_VIF_TYPE}
151 Should Not Contain ${output} ${STR_VNIC_TYPE}
154 Attach Port To Hwvtep Namespace
155 [Arguments] ${port_mac} ${ns_name} ${tap_name} ${conn_id}=${hwvtep_conn_id}
156 [Documentation] Keyword to assign the ${port_mac} to the tap port ${tap_name} in namespace ${ns_name}
157 Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF} ${tap_name} ${HW_ETHER} ${port_mac}
158 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF}
159 Should Contain ${output} ${port_mac}
161 Namespace Dhclient Verify
162 [Arguments] ${ns_name} ${ns_tap} ${ns_port_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
163 [Documentation] Keyword to run dhclient for the tap port ${ns_tap} and verify if it has got assigned with ${ns_port_ip}.
164 Start Command In Hwvtep ${NETNS_EXEC} ${ns_name} dhclient ${ns_tap} ${hwvtep_ip}
165 Wait Until Keyword Succeeds 60s 2s Verify Strings In Command Output ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF} ${ns_port_ip}
167 Verify Strings In Command Output
168 [Arguments] ${conn_id} ${command} @{string_list}
169 [Documentation] Keyword to run the ${command} in ${conn_id} and verify if the output contains the list @{string_list}.
170 ${output}= Exec Command ${conn_id} ${command}
171 FOR ${item} IN @{string_list}
172 Should Contain ${output} ${item}
175 Verify Ping In Namespace Extra Timeout
176 [Arguments] ${ns_name} ${ns_port_mac} ${vm_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
177 [Documentation] Keyword to ping the IP ${vm_ip} from ${ns_name} and verify MCAS Local Table contains ${ns_port_mac}.
178 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF}
180 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ping -c3 ${vm_ip} 30s
182 Should Not Contain ${output} ${PACKET_LOSS}
183 Wait Until Keyword Succeeds 30s 2s Verify Macs Local Table While Ping ${ns_port_mac} ${conn_id}
185 Verify Ping Fails In Namespace
186 [Arguments] ${ns_name} ${ns_port_mac} ${vm_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
187 [Documentation] Keyword to ping the IP ${vm_ip} from ${ns_name} and should verify that it fails
188 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ping -c3 ${vm_ip} 30s
190 Should Contain ${output} ${PACKET_LOSS}
192 Verify Macs Local Table While Ping
193 [Arguments] ${mac} ${conn_id}
194 [Documentation] Keyword to check if ${mac} is available under UCAST_MACS_LOCALE_TABLE of HWVTEP dump table.
195 Verify Vtep List ${conn_id} ${UCAST_MACS_LOCALE_TABLE} ${mac}
198 [Arguments] ${vm_name}
199 [Documentation] Keyword to verify if the VM has received IP, and to verify it is not null.
200 @{vm_ip} ${dhcp_ip} = Get VM IPs ${vm_name}
201 Should Not Contain ${vm_ip} None
202 Should Not Contain ${dhcp_ip} None
206 [Documentation] Keyword to collect the general debug information required for HWVTEP Test Suite.
207 Exec Command ${hwvtep_conn_id} ${OVSDB_CLIENT_DUMP}
208 OpenStackOperations.Get Test Teardown Debugs
209 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/itm-state:external-tunnel-list/
211 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/network-topology:network-topology/topology/hwvtep:1
213 ${resp} = RequestsLibrary.Get Request session ${OPERATIONAL_API}/network-topology:network-topology/topology/hwvtep:1
215 Exec Command ${OS_CNTL_CONN_ID} cat /etc/neutron/neutron.conf
216 Exec Command ${OS_CNTL_CONN_ID} cat /etc/neutron/l2gw_plugin.ini
217 Exec Command ${OS_CNTL_CONN_ID} ps -ef | grep neutron-server
219 Start Command In Hwvtep
220 [Arguments] ${command} ${hwvtep_ip}
221 [Documentation] Keyword to execute Start Command in HWVTEP IP.
222 ${conn_id}= SSHLibrary.Open Connection ${hwvtep_ip} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
224 Flexible SSH Login ${DEFAULT_USER} ${DEFAULT_PASSWORD}
225 Start Command ${command}
226 ${output}= Exec Command ${conn_id} sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -O Openflow13
231 [Arguments] ${conn_id} ${table_name} @{list}
232 [Documentation] Keyword to run vtep-ctl list for the table ${table_name} and verify the list @{list} contents exists in output.
233 ${output}= Exec Command ${conn_id} ${VTEP LIST} ${table_name}
234 FOR ${item} IN @{list}
235 Should Contain ${output} ${item}
239 [Arguments] ${table_name} ${conn_id}=${hwvtep_conn_id}
240 [Documentation] Keyword to return the contents of vtep-ctl list for table ${table_name}.
241 ${output}= Exec Command ${conn_id} ${VTEP LIST} ${table_name}
245 [Arguments] ${conn_id}
246 [Documentation] Keyword to return DPN ID in decimal for the br-int in IP connected via ${conn_id}.
247 ${output}= Exec Command ${conn_id} ${GET_DPNID}
249 ${splitted_output}= Split String ${output} ${EMPTY}
250 ${dpn_id}= Get from List ${splitted_output} 0
255 [Arguments] ${hwvtep_ip} ${ovs_ip} ${seg_id}=${NET_1_SEGID} ${conn_id}=${hwvtep_conn_id}
256 [Documentation] Keyword to verify that the OVS tunnel entries are configured for OVS and HWVTEP.
257 ${output}= Exec Command ${conn_id} ${OVS_SHOW}
259 Should Contain ${output} key="${seg_id}", remote_ip="${ovs_ip}"
260 ${output}= Exec Command ${OS_CMP1_CONN_ID} ${OVS_SHOW}
262 Should Contain ${output} key=flow, local_ip="${ovs_ip}", remote_ip="${hwvtep_ip}"
264 Get Vtep Field Values From Table
265 [Arguments] ${table_name} ${column_name} ${conn_id}=${hwvtep_conn_id}
266 [Documentation] Keyword to return specific field value received in ${column_name} from the vtep-ctl list for ${table_name}.
267 ${output}= Exec Command ${conn_id} ${VTEP_LIST_COLUMN}${column_name} list ${table_name} | awk '{print $3}'
269 @{keys}= Split String ${output}
273 Validate Regexp In String
274 [Arguments] ${string} ${regexp} ${verify_count}=1
275 @{occr}= Get Regexp Matches ${string} ${regexp}
276 ${count}= Get Length ${occr}
277 Should Be Equal As Integers ${count} ${verify_count}
280 [Arguments] ${conn_id} ${command} ${timeout}=10s
281 Switch Connection ${conn_id}
282 ${output}= DevstackUtils.Write Commands Until Prompt ${command} ${timeout}
286 Verify Elan Flow Entries
287 [Arguments] ${ip} ${srcMacAddrs} ${destMacAddrs}
288 [Documentation] Verify Flows Are Present For ELAN service
289 ${flow_output} = Run Command On Remote System ${ip} sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
291 Should Contain ${flow_output} table=50
292 ${sMac_output} = Get Lines Containing String ${flow_output} table=50
294 FOR ${sMacAddr} IN @{srcMacAddrs}
295 ${resp}= Should Contain ${sMac_output} dl_src=${sMacAddr}
297 Should Contain ${flow_output} table=51
298 ${dMac_output} = Get Lines Containing String ${flow_output} table=51
300 FOR ${dMacAddr} IN @{destMacAddrs}
301 ${resp}= Should Contain ${dMac_output} dl_dst=${dMacAddr}
303 Should Contain ${flow_output} table=52
304 ${sMac_output} = Get Lines Containing String ${flow_output} table=52
307 Cleanup L2GW Optional Resources
308 [Documentation] Cleanup resources that are only allocated on certain combos...
309 OpenStackOperations.Delete Port ${HWVTEP_PORT_3}