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} ${OVS_BRIDGE}
25 ${output}= Exec Command ${conn_id} ${DEL_OVS_BRIDGE} ${OVS_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} ${OVS_BRIDGE}
30 ${output}= Exec Command ${conn_id} ${SET_FAIL_MODE} ${OVS_BRIDGE} secure
31 ${output}= Exec Command ${conn_id} ${OVS_SET_MGR}:${ODL_IP}:${OVSDBPORT}
32 ${output}= Exec Command ${conn_id} ${OVS_SET_CTRLR} ${OVS_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/${OVS_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 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
119 [Return] ${l2gw_output}
121 Delete L2Gateway Connection
122 [Arguments] ${gw_name}
123 [Documentation] Delete the L2 Gateway connection existing for Gateway ${gw_name} received in argument (Using Neutron CLI).
124 ${l2gw_conn_id}= OpenStackOperations.Get L2gw Connection Id ${gw_name}
125 ${output}= Exec Command ${OS_CNTL_CONN_ID} ${L2GW_CONN_DELETE} ${l2gw_conn_id}
126 @{list_to_check}= Create List ${l2gw_conn_id}
127 Utils.Check For Elements Not At URI ${L2GW_CONN_LIST_REST_URL} ${list_to_check} session
130 Update Port For Hwvtep
131 [Arguments] ${port_name}
132 [Documentation] Keyword to update the Neutron Ports for specific configuration required to connect to HWVTEP (Using REST).
133 ${port_id}= Get Port Id ${port_name}
135 ${json_data}= Get Neutron Port Rest ${port_id}
136 Should Contain ${json_data} ${STR_VIF_TYPE}
137 Should Contain ${json_data} ${STR_VNIC_TYPE}
138 ${json_data}= Replace String ${json_data} ${STR_VIF_TYPE} ${STR_VIF_REPLACE}
139 ${json_data}= Replace String ${json_data} ${STR_VNIC_TYPE} ${STR_VNIC_REPLACE}
140 ${return}= OpenStackOperations.Update Port Rest ${port_id} ${json_data}
141 ${output}= OpenStackOperations.Get Neutron Port Rest ${port_id}
143 Should Contain ${output} ${STR_VIF_REPLACE}
144 Should Contain ${output} ${STR_VNIC_REPLACE}
145 Should Not Contain ${output} ${STR_VIF_TYPE}
146 Should Not Contain ${output} ${STR_VNIC_TYPE}
149 Attach Port To Hwvtep Namespace
150 [Arguments] ${port_mac} ${ns_name} ${tap_name} ${conn_id}=${hwvtep_conn_id}
151 [Documentation] Keyword to assign the ${port_mac} to the tap port ${tap_name} in namespace ${ns_name}
152 Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF} ${tap_name} ${HW_ETHER} ${port_mac}
153 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF}
154 Should Contain ${output} ${port_mac}
156 Namespace Dhclient Verify
157 [Arguments] ${ns_name} ${ns_tap} ${ns_port_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
158 [Documentation] Keyword to run dhclient for the tap port ${ns_tap} and verify if it has got assigned with ${ns_port_ip}.
159 Start Command In Hwvtep ${NETNS_EXEC} ${ns_name} dhclient ${ns_tap} ${hwvtep_ip}
160 Wait Until Keyword Succeeds 60s 2s Verify Strings In Command Output ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF} ${ns_port_ip}
162 Verify Strings In Command Output
163 [Arguments] ${conn_id} ${command} @{string_list}
164 [Documentation] Keyword to run the ${command} in ${conn_id} and verify if the output contains the list @{string_list}.
165 ${output}= Exec Command ${conn_id} ${command}
166 : FOR ${item} IN @{string_list}
167 \ Should Contain ${output} ${item}
169 Verify Ping In Namespace Extra Timeout
170 [Arguments] ${ns_name} ${ns_port_mac} ${vm_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
171 [Documentation] Keyword to ping the IP ${vm_ip} from ${ns_name} and verify MCAS Local Table contains ${ns_port_mac}.
172 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF}
174 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ping -c3 ${vm_ip} 30s
176 Should Not Contain ${output} ${PACKET_LOSS}
177 Wait Until Keyword Succeeds 30s 2s Verify Mcas Local Table While Ping ${ns_port_mac} ${conn_id}
179 Verify Ping Fails In Namespace
180 [Arguments] ${ns_name} ${ns_port_mac} ${vm_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
181 [Documentation] Keyword to ping the IP ${vm_ip} from ${ns_name} and should verify that it fails
182 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ping -c3 ${vm_ip} 30s
184 Should Contain ${output} ${PACKET_LOSS}
186 Verify Mcas Local Table While Ping
187 [Arguments] ${mac} ${conn_id}
188 [Documentation] Keyword to check if ${mac} is available under UCAST_MACS_LOCALE_TABLE of HWVTEP dump table.
189 Verify Vtep List ${conn_id} ${UCAST_MACS_LOCALE_TABLE} ${mac}
192 [Arguments] ${vm_name}
193 [Documentation] Keyword to verify if the VM has received IP, and to verify it is not null.
194 @{vm_ip} ${dhcp_ip} = Get VM IPs ${vm_name}
195 Should Not Contain ${vm_ip} None
196 Should Not Contain ${dhcp_ip} None
200 [Documentation] Keyword to collect the general debug information required for HWVTEP Test Suite.
201 Exec Command ${hwvtep_conn_id} ${OVSDB_CLIENT_DUMP}
202 OpenStackOperations.Get Test Teardown Debugs
203 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/itm-state:external-tunnel-list/
205 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/network-topology:network-topology/topology/hwvtep:1
207 ${resp} = RequestsLibrary.Get Request session ${OPERATIONAL_API}/network-topology:network-topology/topology/hwvtep:1
209 Exec Command ${OS_CNTL_CONN_ID} cat /etc/neutron/neutron.conf
210 Exec Command ${OS_CNTL_CONN_ID} cat /etc/neutron/l2gw_plugin.ini
211 Exec Command ${OS_CNTL_CONN_ID} ps -ef | grep neutron-server
213 Start Command In Hwvtep
214 [Arguments] ${command} ${hwvtep_ip}
215 [Documentation] Keyword to execute Start Command in HWVTEP IP.
216 ${conn_id}= SSHLibrary.Open Connection ${hwvtep_ip} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
218 Flexible SSH Login ${DEFAULT_USER} ${DEFAULT_PASSWORD}
219 Start Command ${command}
220 ${output}= Exec Command ${conn_id} sudo ovs-ofctl dump-flows br-int -O Openflow13
225 [Arguments] ${conn_id} ${table_name} @{list}
226 [Documentation] Keyword to run vtep-ctl list for the table ${table_name} and verify the list @{list} contents exists in output.
227 ${output}= Exec Command ${conn_id} ${VTEP LIST} ${table_name}
228 : FOR ${item} IN @{list}
229 \ Should Contain ${output} ${item}
232 [Arguments] ${table_name} ${conn_id}=${hwvtep_conn_id}
233 [Documentation] Keyword to return the contents of vtep-ctl list for table ${table_name}.
234 ${output}= Exec Command ${conn_id} ${VTEP LIST} ${table_name}
238 [Arguments] ${conn_id}
239 [Documentation] Keyword to return DPN ID in decimal for the br-int in IP connected via ${conn_id}.
240 ${output}= Exec Command ${conn_id} ${GET_DPNID}
242 ${splitted_output}= Split String ${output} ${EMPTY}
243 ${dpn_id}= Get from List ${splitted_output} 0
248 [Arguments] ${hwvtep_ip} ${ovs_ip} ${seg_id}=${NET_1_SEGID} ${conn_id}=${hwvtep_conn_id}
249 [Documentation] Keyword to verify that the OVS tunnel entries are configured for OVS and HWVTEP.
250 ${output}= Exec Command ${conn_id} ${OVS_SHOW}
252 Should Contain ${output} key="${seg_id}", remote_ip="${ovs_ip}"
253 ${output}= Exec Command ${OS_CMP1_CONN_ID} ${OVS_SHOW}
255 Should Contain ${output} key=flow, local_ip="${ovs_ip}", remote_ip="${hwvtep_ip}"
257 Get Vtep Field Values From Table
258 [Arguments] ${table_name} ${column_name} ${conn_id}=${hwvtep_conn_id}
259 [Documentation] Keyword to return specific field value received in ${column_name} from the vtep-ctl list for ${table_name}.
260 ${output}= Exec Command ${conn_id} ${VTEP_LIST_COLUMN}${column_name} list ${table_name} | awk '{print $3}'
262 @{keys}= Split String ${output}
266 Validate Regexp In String
267 [Arguments] ${string} ${regexp} ${verify_count}=1
268 @{occr}= Get Regexp Matches ${string} ${regexp}
269 ${count}= Get Length ${occr}
270 Should Be Equal As Integers ${count} ${verify_count}
273 [Arguments] ${conn_id} ${command} ${timeout}=10s
274 Switch Connection ${conn_id}
275 ${output}= DevstackUtils.Write Commands Until Prompt ${command} ${timeout}
279 Verify Elan Flow Entries
280 [Arguments] ${ip} ${srcMacAddrs} ${destMacAddrs}
281 [Documentation] Verify Flows Are Present For ELAN service
282 ${flow_output} = Run Command On Remote System ${ip} sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
284 Should Contain ${flow_output} table=50
285 ${sMac_output} = Get Lines Containing String ${flow_output} table=50
287 : FOR ${sMacAddr} IN @{srcMacAddrs}
288 \ ${resp}= Should Contain ${sMac_output} dl_src=${sMacAddr}
289 Should Contain ${flow_output} table=51
290 ${dMac_output} = Get Lines Containing String ${flow_output} table=51
292 : FOR ${dMacAddr} IN @{destMacAddrs}
293 \ ${resp}= Should Contain ${dMac_output} dl_dst=${dMacAddr}
294 Should Contain ${flow_output} table=52
295 ${sMac_output} = Get Lines Containing String ${flow_output} table=52
298 Cleanup L2GW Optional Resources
299 [Documentation] Cleanup resources that are only allocated on certain combos...
300 BuiltIn.Pass_Execution_If "skip_if_${OPENSTACK_BRANCH}" in @{TEST_TAGS} Not supported in Ocata/Pike
301 CompareStream.Run_Keyword_If_At_Most_Nitrogen BuiltIn.Pass_Execution Only run on oxygen and later
302 OpenStackOperations.Delete Port ${HWVTEP_PORT_3}