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 devstack_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}=${ovs_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 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}
77 [Arguments] ${gw_name}
78 [Documentation] Keyword to delete the L2 Gateway ${gw_name} received in argument.
79 ${output}= Exec Command ${devstack_conn_id} ${L2GW_DELETE} ${gw_name}
81 @{list_to_check}= Create List ${gw_name}
82 Utils.Check For Elements Not At URI ${L2GW_LIST_REST_URL} ${list_to_check} session
84 Create Verify L2Gateway Connection
85 [Arguments] ${gw_name} ${net_name}
86 [Documentation] Keyword to create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
87 ${l2gw_output}= OpenStackOperations.Create L2Gateway Connection ${gw_name} ${net_name}
89 ${l2gw_id}= OpenStackOperations.Get L2gw Id ${gw_name}
90 ${output}= OpenStackOperations.Get All L2Gateway Connection
92 Should Contain ${output} ${l2gw_id}
93 @{list_to_check}= Create List ${l2gw_id}
94 Utils.Check For Elements At URI ${L2GW_CONN_LIST_REST_URL} ${list_to_check} session
95 [Return] ${l2gw_output}
97 Delete L2Gateway Connection
98 [Arguments] ${gw_name}
99 [Documentation] Delete the L2 Gateway connection existing for Gateway ${gw_name} received in argument (Using Neutron CLI).
100 ${l2gw_conn_id}= OpenStackOperations.Get L2gw Connection Id ${gw_name}
101 ${output}= Exec Command ${devstack_conn_id} ${L2GW_CONN_DELETE} ${l2gw_conn_id}
102 @{list_to_check}= Create List ${l2gw_conn_id}
103 Utils.Check For Elements Not At URI ${L2GW_CONN_LIST_REST_URL} ${list_to_check} session
106 Update Port For Hwvtep
107 [Arguments] ${port_name}
108 [Documentation] Keyword to update the Neutron Ports for specific configuration required to connect to HWVTEP (Using REST).
109 ${port_id}= Get Port Id ${port_name} ${devstack_conn_id}
111 ${json_data}= Get Neutron Port Rest ${port_id}
112 Should Contain ${json_data} ${STR_VIF_TYPE}
113 Should Contain ${json_data} ${STR_VNIC_TYPE}
114 ${json_data}= Replace String ${json_data} ${STR_VIF_TYPE} ${STR_VIF_REPLACE}
115 ${json_data}= Replace String ${json_data} ${STR_VNIC_TYPE} ${STR_VNIC_REPLACE}
116 ${return}= OpenStackOperations.Update Port Rest ${port_id} ${json_data}
117 ${output}= OpenStackOperations.Get Neutron Port Rest ${port_id}
119 Should Contain ${output} ${STR_VIF_REPLACE}
120 Should Contain ${output} ${STR_VNIC_REPLACE}
121 Should Not Contain ${output} ${STR_VIF_TYPE}
122 Should Not Contain ${output} ${STR_VNIC_TYPE}
125 Attach Port To Hwvtep Namespace
126 [Arguments] ${port_mac} ${ns_name} ${tap_name} ${conn_id}=${hwvtep_conn_id}
127 [Documentation] Keyword to assign the ${port_mac} to the tap port ${tap_name} in namespace ${ns_name}
128 Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF} ${tap_name} ${HW_ETHER} ${port_mac}
129 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF}
130 Should Contain ${output} ${port_mac}
132 Namespace Dhclient Verify
133 [Arguments] ${ns_name} ${ns_tap} ${ns_port_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
134 [Documentation] Keyword to run dhclient for the tap port ${ns_tap} and verify if it has got assigned with ${ns_port_ip}.
135 Start Command In Hwvtep ${NETNS_EXEC} ${ns_name} dhclient ${ns_tap} ${hwvtep_ip}
136 Wait Until Keyword Succeeds 60s 2s Verify Strings In Command Output ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF} ${ns_port_ip}
138 Verify Strings In Command Output
139 [Arguments] ${conn_id} ${command} @{string_list}
140 [Documentation] Keyword to run the ${command} in ${conn_id} and verify if the output contains the list @{string_list}.
141 ${output}= Exec Command ${conn_id} ${command}
142 : FOR ${item} IN @{string_list}
143 \ Should Contain ${output} ${item}
145 Verify Ping In Namespace Extra Timeout
146 [Arguments] ${ns_name} ${ns_port_mac} ${vm_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
147 [Documentation] Keyword to ping the IP ${vm_ip} from ${ns_name} and verify MCAS Local Table contains ${ns_port_mac}.
148 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ${IFCONF}
150 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ping -c3 ${vm_ip} 30s
152 Should Not Contain ${output} ${PACKET_LOSS}
153 Wait Until Keyword Succeeds 30s 2s Verify Mcas Local Table While Ping ${ns_port_mac} ${conn_id}
155 Verify Ping Fails In Namespace
156 [Arguments] ${ns_name} ${ns_port_mac} ${vm_ip} ${conn_id}=${hwvtep_conn_id} ${hwvtep_ip}=${HWVTEP_IP}
157 [Documentation] Keyword to ping the IP ${vm_ip} from ${ns_name} and should verify that it fails
158 ${output}= Exec Command ${conn_id} ${NETNS_EXEC} ${ns_name} ping -c3 ${vm_ip} 30s
160 Should Contain ${output} ${PACKET_LOSS}
162 Verify Mcas Local Table While Ping
163 [Arguments] ${mac} ${conn_id}
164 [Documentation] Keyword to check if ${mac} is available under UCAST_MACS_LOCALE_TABLE of HWVTEP dump table.
165 Verify Vtep List ${conn_id} ${UCAST_MACS_LOCALE_TABLE} ${mac}
168 [Arguments] ${vm_name}
169 [Documentation] Keyword to verify if the VM has received IP, and to vefiry it is not null.
170 ${vm_ip} ${dhcp_ip} Collect VM IP Addresses false ${vm_name}
172 Should Not Contain ${vm_ip} None
176 [Documentation] Keyword to collect the general debug information required for HWVTEP Test Suite.
177 Exec Command ${hwvtep_conn_id} ${OVSDB_CLIENT_DUMP}
178 OpenStackOperations.Get Test Teardown Debugs
179 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/itm-state:external-tunnel-list/
181 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/network-topology:network-topology/topology/hwvtep:1
183 ${resp} = RequestsLibrary.Get Request session ${OPERATIONAL_API}/network-topology:network-topology/topology/hwvtep:1
185 Exec Command ${devstack_conn_id} cat /etc/neutron/neutron.conf
186 Exec Command ${devstack_conn_id} cat /etc/neutron/l2gw_plugin.ini
187 Exec Command ${devstack_conn_id} ps -ef | grep neutron-server
189 Start Command In Hwvtep
190 [Arguments] ${command} ${hwvtep_ip}
191 [Documentation] Keyword to execute Start Command in HWVTEP IP.
192 ${conn_id}= SSHLibrary.Open Connection ${hwvtep_ip} prompt=${DEFAULT_LINUX_PROMPT} timeout=30s
194 Flexible SSH Login ${DEFAULT_USER} ${DEFAULT_PASSWORD}
195 Start Command ${command}
196 ${output}= Exec Command ${conn_id} sudo ovs-ofctl dump-flows br-int -O Openflow13
201 [Arguments] ${conn_id} ${table_name} @{list}
202 [Documentation] Keyword to run vtep-ctl list for the table ${table_name} and verify the list @{list} contents exists in output.
203 ${output}= Exec Command ${conn_id} ${VTEP LIST} ${table_name}
204 : FOR ${item} IN @{list}
205 \ Should Contain ${output} ${item}
208 [Arguments] ${table_name} ${conn_id}=${hwvtep_conn_id}
209 [Documentation] Keyword to return the contents of vtep-ctl list for table ${table_name}.
210 ${output}= Exec Command ${conn_id} ${VTEP LIST} ${table_name}
214 [Arguments] ${conn_id}
215 [Documentation] Keyword to return DPN ID in decimal for the br-int in IP connected via ${conn_id}.
216 ${output}= Exec Command ${conn_id} ${GET_DPNID}
218 ${splitted_output}= Split String ${output} ${EMPTY}
219 ${dpn_id}= Get from List ${splitted_output} 0
224 [Arguments] ${hwvtep_ip} ${ovs_ip} ${seg_id}=${NET_1_SEGID} ${conn_id}=${hwvtep_conn_id}
225 [Documentation] Keyword to verify that the OVS tunnel entries are configured for OVS and HWVTEP.
226 ${output}= Exec Command ${conn_id} ${OVS_SHOW}
228 Should Contain ${output} key="${seg_id}", remote_ip="${ovs_ip}"
229 ${output}= Exec Command ${ovs_conn_id} ${OVS_SHOW}
231 Should Contain ${output} key=flow, local_ip="${ovs_ip}", remote_ip="${hwvtep_ip}"
233 Get Vtep Field Values From Table
234 [Arguments] ${table_name} ${column_name} ${conn_id}=${hwvtep_conn_id}
235 [Documentation] Keyword to return specific field value received in ${column_name} from the vtep-ctl list for ${table_name}.
236 ${output}= Exec Command ${conn_id} ${VTEP_LIST_COLUMN}${column_name} list ${table_name} | awk '{print $3}'
238 @{keys}= Split String ${output}
242 Validate Regexp In String
243 [Arguments] ${string} ${regexp} ${verify_count}=1
244 @{occr}= Get Regexp Matches ${string} ${regexp}
245 ${count}= Get Length ${occr}
246 Should Be Equal As Integers ${count} ${verify_count}
249 [Arguments] ${conn_id} ${command} ${timeout}=10s
250 Switch Connection ${conn_id}
251 ${output}= DevstackUtils.Write Commands Until Prompt ${command} ${timeout}
255 Verify Elan Flow Entries
256 [Arguments] ${ip} ${srcMacAddrs} ${destMacAddrs}
257 [Documentation] Verify Flows Are Present For ELAN service
258 ${flow_output} = Run Command On Remote System ${ip} sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
260 Should Contain ${flow_output} table=50
261 ${sMac_output} = Get Lines Containing String ${flow_output} table=50
263 : FOR ${sMacAddr} IN @{srcMacAddrs}
264 \ ${resp}= Should Contain ${sMac_output} dl_src=${sMacAddr}
265 Should Contain ${flow_output} table=51
266 ${dMac_output} = Get Lines Containing String ${flow_output} table=51
268 : FOR ${dMacAddr} IN @{destMacAddrs}
269 \ ${resp}= Should Contain ${dMac_output} dl_dst=${dMacAddr}
270 Should Contain ${flow_output} table=52
271 ${sMac_output} = Get Lines Containing String ${flow_output} table=52