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}
91 [Documentation] Keyword to delete the L2 Gateway ${gw_name} received in argument.
92 ${output}= Exec Command ${OS_CNTL_CONN_ID} ${L2GW_DELETE} ${gw_name}
94 @{list_to_check}= Create List ${gw_name}
95 BuiltIn.Wait Until Keyword Succeeds 5s 1s Utils.Check For Elements Not At URI ${L2GW_LIST_REST_URL} ${list_to_check} session
97 Create Verify L2Gateway Connection
98 [Arguments] ${gw_name} ${net_name}
99 [Documentation] Keyword to create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
100 ${l2gw_output}= OpenStackOperations.Create L2Gateway Connection ${gw_name} ${net_name}
102 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${gw_name}
103 ${output}= OpenStackOperations.Get All L2Gateway Connection
105 Should Contain ${output} ${l2gw_id}
106 @{list_to_check}= Create List ${l2gw_id}
107 Utils.Check For Elements At URI ${L2GW_CONN_LIST_REST_URL} ${list_to_check} session
108 [Return] ${l2gw_output}
110 Verify L2Gateway Connection
111 [Arguments] ${gw_name} ${net_name}
112 [Documentation] Keyword to verify existing L2 Gateway Connection for ${gw_name} to ${net_name} $(Using Neutron CLI).
113 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${gw_name}
114 ${output}= OpenStackOperations.Get All L2Gateway Connection
116 Should Contain ${output} ${l2gw_id}
117 @{list_to_check}= Create List ${l2gw_id}
118 Utils.Check For Elements At URI ${L2GW_CONN_LIST_REST_URL} ${list_to_check} session
120 Delete L2Gateway Connection
121 [Arguments] ${gw_name}
122 [Documentation] Delete the L2 Gateway connection existing for Gateway ${gw_name} received in argument (Using Neutron CLI).
123 ${l2gw_conn_id}= OpenStackOperations.Get L2gw Connection Id ${gw_name}
124 ${output}= Exec Command ${OS_CNTL_CONN_ID} ${L2GW_CONN_DELETE} ${l2gw_conn_id}
126 @{list_to_check}= Create List ${l2gw_conn_id}
127 BuiltIn.Wait Until Keyword Succeeds 5s 1s Utils.Check For Elements Not At URI ${L2GW_CONN_LIST_REST_URL} ${list_to_check} session
129 Update Port For Hwvtep
130 [Arguments] ${port_name}
131 [Documentation] Keyword to update the Neutron Ports for specific configuration required to connect to HWVTEP (Using REST).
132 ${port_id}= Get Port Id ${port_name}
134 ${json_data}= Get Neutron Port Rest ${port_id}
135 Should Contain ${json_data} ${STR_VIF_TYPE}
136 Should Contain ${json_data} ${STR_VNIC_TYPE}
137 ${json_data}= Replace String ${json_data} ${STR_VIF_TYPE} ${STR_VIF_REPLACE}
138 ${json_data}= Replace String ${json_data} ${STR_VNIC_TYPE} ${STR_VNIC_REPLACE}
139 ${return}= OpenStackOperations.Update Port Rest ${port_id} ${json_data}
140 ${output}= OpenStackOperations.Get Neutron Port Rest ${port_id}
142 Should Contain ${output} ${STR_VIF_REPLACE}
143 Should Contain ${output} ${STR_VNIC_REPLACE}
144 Should Not Contain ${output} ${STR_VIF_TYPE}
145 Should Not Contain ${output} ${STR_VNIC_TYPE}
148 Attach Port To Hwvtep Namespace
149 [Arguments] ${port_mac} ${ns_name} ${tap_name} ${conn_id}=${hwvtep_conn_id}
150 [Documentation] Keyword to assign the ${port_mac} to the tap port ${tap_name} in namespace ${ns_name}
151 Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF} ${tap_name} ${HW_ETHER} ${port_mac}
152 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF}
153 Should Contain ${output} ${port_mac}
155 Namespace Dhclient Verify
156 [Arguments] ${ns_name} ${ns_tap} ${ns_port_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
157 [Documentation] Keyword to run dhclient for the tap port ${ns_tap} and verify if it has got assigned with ${ns_port_ip}.
158 Start Command In Hwvtep ${NETNS_EXEC} ${ns_name} dhclient ${ns_tap} ${hwvtep_ip}
159 Wait Until Keyword Succeeds 60s 2s Verify Strings In Command Output ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF} ${ns_port_ip}
161 Verify Strings In Command Output
162 [Arguments] ${conn_id} ${command} @{string_list}
163 [Documentation] Keyword to run the ${command} in ${conn_id} and verify if the output contains the list @{string_list}.
164 ${output}= Exec Command ${conn_id} ${command}
165 : FOR ${item} IN @{string_list}
166 \ Should Contain ${output} ${item}
168 Verify Ping In Namespace Extra Timeout
169 [Arguments] ${ns_name} ${ns_port_mac} ${vm_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
170 [Documentation] Keyword to ping the IP ${vm_ip} from ${ns_name} and verify MCAS Local Table contains ${ns_port_mac}.
171 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF}
173 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ping -c3 ${vm_ip} 30s
175 Should Not Contain ${output} ${PACKET_LOSS}
176 Wait Until Keyword Succeeds 30s 2s Verify Macs Local Table While Ping ${ns_port_mac} ${conn_id}
178 Verify Ping Fails In Namespace
179 [Arguments] ${ns_name} ${ns_port_mac} ${vm_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
180 [Documentation] Keyword to ping the IP ${vm_ip} from ${ns_name} and should verify that it fails
181 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ping -c3 ${vm_ip} 30s
183 Should Contain ${output} ${PACKET_LOSS}
185 Verify Macs Local Table While Ping
186 [Arguments] ${mac} ${conn_id}
187 [Documentation] Keyword to check if ${mac} is available under UCAST_MACS_LOCALE_TABLE of HWVTEP dump table.
188 Verify Vtep List ${conn_id} ${UCAST_MACS_LOCALE_TABLE} ${mac}
191 [Arguments] ${vm_name}
192 [Documentation] Keyword to verify if the VM has received IP, and to verify it is not null.
193 @{vm_ip} ${dhcp_ip} = Get VM IPs ${vm_name}
194 Should Not Contain ${vm_ip} None
195 Should Not Contain ${dhcp_ip} None
199 [Documentation] Keyword to collect the general debug information required for HWVTEP Test Suite.
200 Exec Command ${hwvtep_conn_id} ${OVSDB_CLIENT_DUMP}
201 OpenStackOperations.Get Test Teardown Debugs
202 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/itm-state:external-tunnel-list/
204 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/network-topology:network-topology/topology/hwvtep:1
206 ${resp} = RequestsLibrary.Get Request session ${OPERATIONAL_API}/network-topology:network-topology/topology/hwvtep:1
208 Exec Command ${OS_CNTL_CONN_ID} cat /etc/neutron/neutron.conf
209 Exec Command ${OS_CNTL_CONN_ID} cat /etc/neutron/l2gw_plugin.ini
210 Exec Command ${OS_CNTL_CONN_ID} ps -ef | grep neutron-server
212 Start Command In Hwvtep
213 [Arguments] ${command} ${hwvtep_ip}
214 [Documentation] Keyword to execute Start Command in HWVTEP IP.
215 ${conn_id}= SSHLibrary.Open Connection ${hwvtep_ip} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
217 Flexible SSH Login ${DEFAULT_USER} ${DEFAULT_PASSWORD}
218 Start Command ${command}
219 ${output}= Exec Command ${conn_id} sudo ovs-ofctl dump-flows ${INTEGRATION_BRIDGE} -O Openflow13
224 [Arguments] ${conn_id} ${table_name} @{list}
225 [Documentation] Keyword to run vtep-ctl list for the table ${table_name} and verify the list @{list} contents exists in output.
226 ${output}= Exec Command ${conn_id} ${VTEP LIST} ${table_name}
227 : FOR ${item} IN @{list}
228 \ Should Contain ${output} ${item}
231 [Arguments] ${table_name} ${conn_id}=${hwvtep_conn_id}
232 [Documentation] Keyword to return the contents of vtep-ctl list for table ${table_name}.
233 ${output}= Exec Command ${conn_id} ${VTEP LIST} ${table_name}
237 [Arguments] ${conn_id}
238 [Documentation] Keyword to return DPN ID in decimal for the br-int in IP connected via ${conn_id}.
239 ${output}= Exec Command ${conn_id} ${GET_DPNID}
241 ${splitted_output}= Split String ${output} ${EMPTY}
242 ${dpn_id}= Get from List ${splitted_output} 0
247 [Arguments] ${hwvtep_ip} ${ovs_ip} ${seg_id}=${NET_1_SEGID} ${conn_id}=${hwvtep_conn_id}
248 [Documentation] Keyword to verify that the OVS tunnel entries are configured for OVS and HWVTEP.
249 ${output}= Exec Command ${conn_id} ${OVS_SHOW}
251 Should Contain ${output} key="${seg_id}", remote_ip="${ovs_ip}"
252 ${output}= Exec Command ${OS_CMP1_CONN_ID} ${OVS_SHOW}
254 Should Contain ${output} key=flow, local_ip="${ovs_ip}", remote_ip="${hwvtep_ip}"
256 Get Vtep Field Values From Table
257 [Arguments] ${table_name} ${column_name} ${conn_id}=${hwvtep_conn_id}
258 [Documentation] Keyword to return specific field value received in ${column_name} from the vtep-ctl list for ${table_name}.
259 ${output}= Exec Command ${conn_id} ${VTEP_LIST_COLUMN}${column_name} list ${table_name} | awk '{print $3}'
261 @{keys}= Split String ${output}
265 Validate Regexp In String
266 [Arguments] ${string} ${regexp} ${verify_count}=1
267 @{occr}= Get Regexp Matches ${string} ${regexp}
268 ${count}= Get Length ${occr}
269 Should Be Equal As Integers ${count} ${verify_count}
272 [Arguments] ${conn_id} ${command} ${timeout}=10s
273 Switch Connection ${conn_id}
274 ${output}= DevstackUtils.Write Commands Until Prompt ${command} ${timeout}
278 Verify Elan Flow Entries
279 [Arguments] ${ip} ${srcMacAddrs} ${destMacAddrs}
280 [Documentation] Verify Flows Are Present For ELAN service
281 ${flow_output} = Run Command On Remote System ${ip} sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}
283 Should Contain ${flow_output} table=50
284 ${sMac_output} = Get Lines Containing String ${flow_output} table=50
286 : FOR ${sMacAddr} IN @{srcMacAddrs}
287 \ ${resp}= Should Contain ${sMac_output} dl_src=${sMacAddr}
288 Should Contain ${flow_output} table=51
289 ${dMac_output} = Get Lines Containing String ${flow_output} table=51
291 : FOR ${dMacAddr} IN @{destMacAddrs}
292 \ ${resp}= Should Contain ${dMac_output} dl_dst=${dMacAddr}
293 Should Contain ${flow_output} table=52
294 ${sMac_output} = Get Lines Containing String ${flow_output} table=52
297 Cleanup L2GW Optional Resources
298 [Documentation] Cleanup resources that are only allocated on certain combos...
299 OpenStackOperations.Delete Port ${HWVTEP_PORT_3}