4 Library OperatingSystem
5 Library RequestsLibrary
8 Resource ClusterManagement.robot
10 Resource ${CURDIR}/TemplatedRequests.robot
11 Resource ../variables/Variables.robot
12 Resource ../variables/netvirt/Variables.robot
15 ${OVSDB_CONFIG_DIR} ${CURDIR}/../variables/ovsdb
16 ${OVSDB_NODE_PORT} 6634
17 ${SOUTHBOUND_CONFIG_API} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F
18 ${SOUTHBOUND_NODE_CONFIG_API} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F${TOOLS_SYSTEM_IP}:${OVSDB_NODE_PORT}
22 [Arguments] ${resp_content}
23 ${resp_json} = BuiltIn.Run Keyword If '''${resp_content}''' != '${EMPTY}' RequestsLibrary.To Json ${resp_content} pretty_print=True
24 ... ELSE BuiltIn.Set Variable ${EMPTY}
25 BuiltIn.Log ${resp_json}
29 [Arguments] ${node_ip} ${port}=${OVSDB_NODE_PORT}
30 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_node.json
31 ${body} = Replace String ${body} 127.0.0.1 ${node_ip}
32 ${body} = Replace String ${body} 61644 ${port}
33 ${uri} = Builtin.Set Variable ${CONFIG_TOPO_API}/topology/ovsdb:1/
34 BuiltIn.Log URI is ${uri}
35 BuiltIn.Log data: ${body}
36 ${resp} = RequestsLibrary.Post Request session ${uri} data=${body}
37 OVSDB.Log Request ${resp.content}
38 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
41 [Arguments] ${node_ip} ${port}=${OVSDB_NODE_PORT}
42 [Documentation] This will Initiate the connection to OVSDB node from controller
43 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/connect.json
44 ${body} = String.Replace String ${body} 127.0.0.1 ${node_ip}
45 ${body} = String.Replace String ${body} 61644 ${port}
46 ${uri} = BuiltIn.Set Variable ${SOUTHBOUND_CONFIG_API}${node_ip}:${port}
47 BuiltIn.Log URI is ${uri}
48 BuiltIn.Log data: ${body}
49 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
50 OVSDB.Log Request ${resp.content}
51 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
53 Disconnect From Ovsdb Node
54 [Arguments] ${node_ip} ${port}=${OVSDB_NODE_PORT}
55 [Documentation] This request will disconnect the OVSDB node from the controller
56 ${resp} = RequestsLibrary.Delete Request session ${SOUTHBOUND_CONFIG_API}${node_ip}:${port}
57 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
59 Add Bridge To Ovsdb Node
60 [Arguments] ${node_id} ${node_ip} ${bridge} ${datapath_id} ${port}=${OVSDB_NODE_PORT}
61 [Documentation] This will create a bridge and add it to the OVSDB node.
62 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_bridge.json
63 ${body} = String.Replace String ${body} ovsdb://127.0.0.1:61644 ovsdb://${node_id}
64 ${body} = String.Replace String ${body} tcp:127.0.0.1:6633 tcp:${ODL_SYSTEM_IP}:6633
65 ${body} = String.Replace String ${body} 127.0.0.1 ${node_ip}
66 ${body} = String.Replace String ${body} br01 ${bridge}
67 ${body} = String.Replace String ${body} 61644 ${port}
68 ${body} = String.Replace String ${body} 0000000000000001 ${datapath_id}
69 ${node_id_} = BuiltIn.Evaluate """${node_id}""".replace("/","%2F")
70 ${uri} = BuiltIn.Set Variable ${SOUTHBOUND_CONFIG_API}${node_id_}%2Fbridge%2F${bridge}
71 BuiltIn.Log URI is ${uri}
72 BuiltIn.Log data: ${body}
73 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
74 OVSDB.Log Request ${resp.content}
75 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
77 Delete Bridge From Ovsdb Node
78 [Arguments] ${node_id} ${bridge}
79 [Documentation] This request will delete the bridge node from the OVSDB
80 ${resp} = RequestsLibrary.Delete Request session ${SOUTHBOUND_CONFIG_API}${node_id}%2Fbridge%2F${bridge}
81 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
84 [Arguments] ${node_id} ${bridge} ${tp_name} ${remote_ip}=${TOOLS_SYSTEM_IP}
85 [Documentation] Using the json data body file as a template, a REST config request is made to
86 ... create a termination-point ${tp_name} on ${bridge} for the given ${node_id}. The ports
87 ... remote-ip defaults to ${TOOLS_SYSTEM_IP}
88 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_port.json
89 ${body} = String.Replace String ${body} 192.168.0.21 ${remote_ip}
90 ${body} = String.Replace String ${body} vxlanport ${tp_name}
91 ${node_id_} = BuiltIn.Evaluate """${node_id}""".replace("/","%2F")
92 ${uri} = BuiltIn.Set Variable ${SOUTHBOUND_CONFIG_API}${node_id_}%2Fbridge%2F${bridge}
93 ${resp} = RequestsLibrary.Put Request session ${uri}/termination-point/${tp_name}/ data=${body}
94 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
97 [Arguments] ${node_ip} ${bridge} ${vxlan_port} ${remote_ip} ${port}=${OVSDB_NODE_PORT}
98 [Documentation] This request will create vxlan port for vxlan tunnel and attach it to the specific bridge
99 OVSDB.Add Termination Point ${node_ip}:${port} ${bridge} ${vxlan_port} ${remote_ip}
101 Verify OVS Reports Connected
102 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP}
103 [Documentation] Uses "vsctl show" to check for string "is_connected"
104 ${output} = Verify Ovs-vsctl Output show is_connected ${tools_system}
107 Verify Ovs-vsctl Output
108 [Arguments] ${vsctl_args} ${expected_output} ${ovs_system}=${TOOLS_SYSTEM_IP} ${should_match}=True
109 [Documentation] A wrapper keyword to make it easier to validate ovs-vsctl output, and gives an easy
110 ... way to check this output in a WUKS. The argument ${should_match} can control if the match should
111 ... exist (True} or not (False) or don't care (anything but True or False). ${should_match} is True by default
112 ${output} = Utils.Run Command On Mininet ${ovs_system} sudo ovs-vsctl ${vsctl_args}
113 BuiltIn.Log ${output}
114 BuiltIn.Run Keyword If "${should_match}" == "True" BuiltIn.Should Contain ${output} ${expected_output}
115 BuiltIn.Run Keyword If "${should_match}" == "False" BuiltIn.Should Not Contain ${output} ${expected_output}
119 [Arguments] ${ovs_system_ip}=${TOOLS_SYSTEM_IP} ${controller_http_session}=session
120 [Documentation] Queries the topology in the operational datastore and searches for the node that has
121 ... the ${ovs_system_ip} argument as the "remote-ip". If found, the value returned will be the value of
122 ... node-id stripped of "ovsdb://uuid/". If not found, ${EMPTY} will be returned.
123 ${uuid} = Set Variable ${EMPTY}
124 ${resp} = RequestsLibrary.Get Request ${controller_http_session} ${OPERATIONAL_TOPO_API}/topology/ovsdb:1
125 OVSDB.Log Request ${resp.content}
126 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
127 ${resp_json} = RequestsLibrary.To Json ${resp.content}
128 ${topologies} = Collections.Get From Dictionary ${resp_json} topology
129 ${topology} = Collections.Get From List ${topologies} 0
130 ${node_list} = Collections.Get From Dictionary ${topology} node
131 BuiltIn.Log ${node_list}
132 # Since bridges are also listed as nodes, but will not have the extra "ovsdb:connection-info data,
133 # we need to use "Run Keyword And Ignore Error" below.
134 FOR ${node} IN @{node_list}
135 ${node_id} = Collections.Get From Dictionary ${node} node-id
136 ${node_uuid} = String.Replace String ${node_id} ovsdb://uuid/ ${EMPTY}
137 ${status} ${connection_info} = BuiltIn.Run Keyword And Ignore Error Collections.Get From Dictionary ${node} ovsdb:connection-info
138 ${status} ${remote_ip} = BuiltIn.Run Keyword And Ignore Error Collections.Get From Dictionary ${connection_info} remote-ip
139 ${uuid} = Set Variable If '${remote_ip}' == '${ovs_system_ip}' ${node_uuid} ${uuid}
144 [Arguments] ${switch}=${INTEGRATION_BRIDGE}
145 [Documentation] Used to log useful test debugs for OVSDB related system tests.
146 ${output} = Utils.Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-vsctl show
147 BuiltIn.Log ${output}
148 ${output} = Utils.Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-ofctl -O OpenFlow13 dump-flows ${switch} | cut -d',' -f3-
149 BuiltIn.Log ${output}
151 Clean OVSDB Test Environment
152 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP}
153 [Documentation] General Use Keyword attempting to sanitize test environment for OVSDB related
154 ... tests. Not every step will always be neccessary, but should not cause any problems for
155 ... any new ovsdb test suites.
156 Utils.Clean Mininet System ${tools_system}
157 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl del-manager
158 Utils.Run Command On Mininet ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl stop
159 Utils.Run Command On Mininet ${tools_system} sudo rm -rf /etc/openvswitch/conf.db
160 Utils.Run Command On Mininet ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl start
163 [Arguments] ${ovs_ip}
164 [Documentation] Restart the OVS node without cleaning the current configuration.
165 ${output} = Utils.Run Command On Mininet ${ovs_ip} sudo systemctl restart openvswitch
166 BuiltIn.Log ${output}
168 Set Controller In OVS Bridge
169 [Arguments] ${tools_system} ${bridge} ${controller_opt} ${ofversion}=13
170 [Documentation] Sets controller for the OVS bridge ${bridge} using ${controller_opt} and OF version ${ofversion}.
171 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl set bridge ${bridge} protocols=OpenFlow${ofversion}
172 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl set-controller ${bridge} ${controller_opt}
174 Check OVS OpenFlow Connections
175 [Arguments] ${tools_system} ${of_connections}
176 [Documentation] Check OVS instance with IP ${tools_system} has ${of_connections} OpenFlow connections.
177 ${output} = Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl show
178 BuiltIn.Log ${output}
179 BuiltIn.Should Contain X Times ${output} is_connected ${of_connections}
181 Add Multiple Managers to OVS
182 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP} ${controller_index_list}=${EMPTY} ${ovs_mgr_port}=6640
183 [Documentation] Connect OVS to the list of controllers in the ${controller_index_list} or all if no list is provided.
184 ${index_list} = ClusterManagement.List Indices Or All given_list=${controller_index_list}
185 Utils.Clean Mininet System ${tools_system}
186 ${ovs_opt} = BuiltIn.Set Variable
187 FOR ${index} IN @{index_list}
188 ${ovs_opt} = BuiltIn.Catenate ${ovs_opt} ${SPACE}tcp:${ODL_SYSTEM_${index}_IP}:${ovs_mgr_port}
189 BuiltIn.Log ${ovs_opt}
191 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl set-manager ${ovs_opt}
192 ${output} = BuiltIn.Wait Until Keyword Succeeds 5s 1s Verify OVS Reports Connected ${tools_system}
193 BuiltIn.Log ${output}
194 ${controller_index} = Collections.Get_From_List ${index_list} 0
195 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${controller_index}
196 ${ovsdb_uuid} = BuiltIn.Wait Until Keyword Succeeds 30s 2s OVSDB.Get OVSDB UUID controller_http_session=${session}
197 [Return] ${ovsdb_uuid}
201 [Documentation] Returns the dpnid from the system at the given ip address using ovs-ofctl assuming br-int is present.
202 ${output} = Utils.Run Command On Remote System ${ip} sudo ovs-ofctl show -O Openflow13 ${INTEGRATION_BRIDGE} | head -1 | awk -F "dpid:" '{print $2}'
203 ${dpnid} = BuiltIn.Convert To Integer ${output} 16
209 [Documentation] Return the subnet from the system at the given ip address and interface
210 ${output} = Utils.Run Command On Remote System ${ip} /usr/sbin/ip addr show | grep ${ip} | cut -d' ' -f6
211 ${interface} = ipaddress.ip_interface ${output}
212 ${network} = BuiltIn.Set Variable ${interface.network.__str__()}
217 [Documentation] Returns the ethernet adapter name from the system at the given ip address using ip addr show.
218 ${adapter} = Utils.Run Command On Remote System ${ip} /usr/sbin/ip addr show | grep ${ip} | cut -d " " -f 11
219 BuiltIn.Log ${adapter}
224 [Documentation] Returns the default gateway at the given ip address using route command.
225 ${gateway} = Utils.Run Command On Remote System ${ip} /usr/sbin/route -n | grep '^0.0.0.0' | cut -d " " -f 10
226 BuiltIn.Log ${gateway}
230 [Arguments] ${subportid} ${ip_addr}
231 [Documentation] Get the port number for the given sub-port id
232 ${command} = Set Variable sudo ovs-ofctl -O OpenFlow13 show ${INTEGRATION_BRIDGE} | grep ${subportid} | awk '{print$1}'
233 BuiltIn.Log sudo ovs-ofctl -O OpenFlow13 show ${INTEGRATION_BRIDGE} | grep ${subportid} | awk '{print$1}'
234 ${output} = Utils.Run Command On Remote System ${ip_addr} ${command}
235 ${port_number} = BuiltIn.Should Match Regexp ${output} [0-9]+
236 [Return] ${port_number}
239 [Arguments] ${ip_addr} ${port}
240 [Documentation] Get the Metadata for a given port
241 ${cmd} = Set Variable sudo ovs-ofctl dump-flows -O Openflow13 ${INTEGRATION_BRIDGE} | grep table=0 | grep in_port=${port}
242 ${output} = Utils.Run Command On Remote System ${ip_addr} ${cmd}
243 @{list_any_matches} = String.Get_Regexp_Matches ${output} metadata:(\\w{12}) 1
244 ${metadata} = Builtin.Convert To String @{list_any_matches}
245 ${output} = String.Get Substring ${metadata} 2
248 Log Config And Operational Topology
249 [Documentation] For debugging purposes, this will log both config and operational topo data stores
250 ${resp} RequestsLibrary.Get Request session ${CONFIG_TOPO_API}
251 OVSDB.Log Request ${resp.content}
252 ${resp} = RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
253 OVSDB.Log Request ${resp.content}
255 Config and Operational Topology Should Be Empty
256 [Documentation] This will check that only the expected output is there for both operational and config
257 ... topology data stores. Empty probably means that only ovsdb:1 is there.
258 ${config_resp} RequestsLibrary.Get Request session ${CONFIG_TOPO_API}
259 ${operational_resp} RequestsLibrary.Get Request session ${OPERATIONAL_TOPO_API}
260 BuiltIn.Should Contain ${config_resp.content} {"topology-id":"ovsdb:1"}
261 BuiltIn.Should Contain ${operational_resp.content} {"topology-id":"ovsdb:1"}
263 Modify Multi Port Body
264 [Arguments] ${ovs_1_port_name} ${ovs_2_port_name} ${bridge}
265 [Documentation] Updates two port names for the given ${bridge} in config store
266 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/bug_7414/create_multiple_ports.json
267 ${ovs_1_ovsdb_uuid} = Get OVSDB UUID ${TOOLS_SYSTEM_IP}
268 ${ovs_2_ovsdb_uuid} = Get OVSDB UUID ${TOOLS_SYSTEM_2_IP}
269 ${body} = Replace String ${body} OVS_1_UUID ${ovs_1_ovsdb_uuid}
270 ${body} = Replace String ${body} OVS_2_UUID ${ovs_2_ovsdb_uuid}
271 ${body} = Replace String ${body} OVS_1_BRIDGE_NAME ${bridge}
272 ${body} = Replace String ${body} OVS_2_BRIDGE_NAME ${bridge}
273 ${body} = Replace String ${body} OVS_1_IP ${TOOLS_SYSTEM_IP}
274 ${body} = Replace String ${body} OVS_2_IP ${TOOLS_SYSTEM_2_IP}
275 ${body} = Replace String ${body} OVS_1_PORT_NAME ${ovs_1_port_name}
276 ${body} = Replace String ${body} OVS_2_PORT_NAME ${ovs_2_port_name}
277 ${uri} = Builtin.Set Variable ${CONFIG_TOPO_API}
278 BuiltIn.Log URI is ${uri}
279 BuiltIn.Log data: ${body}
280 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
281 OVSDB.Log Request ${resp.content}
282 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
287 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_qos.json
288 ${uri} = BuiltIn.Set Variable ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1/ovsdb:qos-entries/${qos}/
289 ${body} = Replace String ${body} QOS-1 ${qos}
290 BuiltIn.Log URI is ${uri}
291 BuiltIn.Log data: ${body}
292 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
293 OVSDB.Log Request ${resp.content}
294 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
298 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_qoslinkedqueue.json
299 ${body} = Replace String ${body} QUEUE-1 ${queue}
300 ${uri} = BuiltIn.Set Variable ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1/ovsdb:queues/${queue}/
301 BuiltIn.Log URI is ${uri}
302 BuiltIn.Log data: ${body}
303 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
304 OVSDB.Log Request ${resp.content}
305 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
309 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/update_existingqos.json
310 ${uri} = BuiltIn.Set Variable ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1/ovsdb:qos-entries/${QOS}/
311 BuiltIn.Log URL is ${uri}
312 BuiltIn.Log data: ${body}
313 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
314 OVSDB.Log Request ${resp.content}
315 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
317 Create Qos Linked Queue
318 ${body} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/bug_7160/create_qoslinkedqueue.json
319 ${resp} RequestsLibrary.Put Request session ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:HOST1 data=${body}
320 OVSDB.Log Request ${resp.content}
321 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
324 [Arguments] ${conn_id}
325 [Documentation] Add higher levels of OVS logging
326 SSHLibrary.Switch Connection ${conn_id}
327 @{modules} = BuiltIn.Create List bridge:file:dbg connmgr:file:dbg inband:file:dbg ofp_actions:file:dbg ofp_errors:file:dbg
328 ... ofp_msgs:file:dbg ovsdb_error:file:dbg rconn:file:dbg tunnel:file:dbg vconn:file:dbg
329 FOR ${module} IN @{modules}
330 Utils.Write Commands Until Expected Prompt sudo ovs-appctl --target ovs-vswitchd vlog/set ${module} ${DEFAULT_LINUX_PROMPT_STRICT}
332 Utils.Write Commands Until Expected Prompt sudo ovs-appctl --target ovs-vswitchd vlog/list ${DEFAULT_LINUX_PROMPT_STRICT}
335 [Arguments] ${conn_id}
336 [Documentation] Reset the OVS logging
337 SSHLibrary.Switch Connection ${conn_id}
338 ${output} = Utils.Write Commands Until Expected Prompt sudo ovs-appctl --target ovs-vswitchd vlog/set :file:info ${DEFAULT_LINUX_PROMPT_STRICT}
341 SetupUtils.Setup_Utils_For_Setup_And_Teardown
342 KarafKeywords.Open Controller Karaf Console On Background
343 RequestsLibrary.Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
344 OVSDB.Log Config And Operational Topology
347 [Arguments] ${uris}=@{EMPTY}
348 [Documentation] Cleans up test environment, close existing sessions.
349 OVSDB.Clean OVSDB Test Environment ${TOOLS_SYSTEM_IP}
350 FOR ${uri} IN @{uris}
351 RequestsLibrary.Delete Request session ${uri}
353 ${resp} = RequestsLibrary.Get Request session ${CONFIG_TOPO_API}
354 OVSDB.Log Config And Operational Topology
355 RequestsLibrary.Delete All Sessions
357 Get DumpFlows And Ovsconfig
358 [Arguments] ${conn_id} ${bridge}
359 [Documentation] Get the OvsConfig and Flow entries from OVS
360 SSHLibrary.Switch Connection ${conn_id}
361 Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
362 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
363 Write Commands Until Expected Prompt sudo ovs-ofctl show ${bridge} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
364 Write Commands Until Expected Prompt sudo ovs-ofctl dump-flows ${bridge} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
365 Write Commands Until Expected Prompt sudo ovs-ofctl dump-groups ${bridge} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
366 Write Commands Until Expected Prompt sudo ovs-ofctl dump-group-stats ${bridge} -OOpenFlow13 ${DEFAULT_LINUX_PROMPT_STRICT}
367 Write Commands Until Expected Prompt sudo ovs-vsctl list interface ${DEFAULT_LINUX_PROMPT_STRICT}
370 [Arguments] ${ovs_ip}
371 [Documentation] start the OVS node.
372 ${output} = Utils.Run Command On Mininet ${ovs_ip} sudo /usr/share/openvswitch/scripts/ovs-ctl start
373 BuiltIn.Log ${output}
376 [Arguments] ${ovs_ip}
377 [Documentation] Stop the OVS node.
378 ${output} = Utils.Run Command On Mininet ${ovs_ip} sudo /usr/share/openvswitch/scripts/ovs-ctl stop
379 BuiltIn.Log ${output}
382 [Documentation] This keyword returns first bridge name and UUID from list of bridges.
383 ${result} = SSHLibrary.Execute Command sudo ovs-vsctl show
384 ${uuid} = String.Get Line ${result} 0
385 ${line} ${bridge_name} Builtin.Should Match Regexp ${result} Bridge ([\\w-]+)
386 [Return] ${uuid} ${bridge_name}
388 Delete OVS Controller
389 [Arguments] ${ovs_ip} ${bridge}=${INTEGRATION_BRIDGE}
390 [Documentation] Delete controller from OVS
391 ${del_ctr} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl del-controller ${bridge}
392 BuiltIn.Log ${del_ctr}
395 [Arguments] ${ovs_ip}
396 [Documentation] Delete manager from OVS
397 ${del_mgr} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl del-manager
398 BuiltIn.Log ${del_mgr}
400 Delete Groups On Bridge
401 [Arguments] ${ovs_ip} ${br}=${INTEGRATION_BRIDGE}
402 [Documentation] Delete OVS groups from ${br}
403 ${del_grp} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-ofctl -O Openflow13 del-groups ${br}
404 BuiltIn.Log ${del_grp}
406 Get Ports From Bridge By Type
407 [Arguments] ${ovs_ip} ${br} ${type}
408 [Documentation] Get ${type} ports for a bridge ${br} on node ${ovs_ip}.
409 ${ports} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl list-ports ${br} | grep "${type}"
410 ${ports_list} = String.Split to lines ${ports}
411 [Return] ${ports_list}
413 Delete Ports On Bridge By Type
414 [Arguments] ${ovs_ip} ${br} ${type}
415 [Documentation] List all ports of ${br} and delete ${type} ports
416 ${ports_present} = Get Ports From Bridge By Type ${ovs_ip} ${br} ${type}
417 FOR ${port} IN @{ports_present}
418 ${del-ports} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl del-port ${br} ${port}
419 BuiltIn.Log ${del-ports}
421 ${ports_present_after_delete} = Get Ports From Bridge By Type ${ovs_ip} ${br} ${type}
422 BuiltIn.Log ${ports_present_after_delete}
424 Get Tunnel Id And Packet Count
425 [Arguments] ${conn_id} ${table_id} ${tun_id} ${mac}=""
426 [Documentation] Get tunnel id and packet count from specified table id
427 ... Using regex get the n_packet and the tunnel_id from the table flow.
428 ${tun_id} = BuiltIn.Convert To Hex ${tun_id} prefix=0x lowercase=yes
429 ${cmd} = BuiltIn.Run Keyword If "${table_id}" == "${INTERNAL_TUNNEL_TABLE}" BuiltIn.Set Variable sudo ovs-ofctl dump-flows br-int -OOpenFlow13 | grep table=${table_id} | grep ${mac} | grep tun_id=${tun_id} | grep goto_table:${ELAN_DMACTABLE}
430 ... ELSE BuiltIn.Set Variable sudo ovs-ofctl dump-flows br-int -OOpenFlow13 | grep table=${table_id} | grep ${mac}
431 SSHLibrary.Switch Connection ${conn_id}
432 ${output} = Utils.Write Commands Until Expected Prompt ${cmd} ${DEFAULT_LINUX_PROMPT_STRICT}
433 @{list}= Split to lines ${output}
434 ${output} = Set Variable ${list}[0]
435 ${output} = String.Get Regexp Matches ${output} n_packets=([0-9]+),.*set_field:(0x[0-9a-z]+)|n_packets=([0-9]+),.*tun_id=(0x[0-9a-z]+) 1 2 3
437 ${output} = BuiltIn.Set Variable ${output}[0]
438 ${output} Convert To List ${output}
439 ${packet_count} ${tunnel_id} = BuiltIn.Run Keyword If "${table_id}" == "${ELAN_DMACTABLE}" BuiltIn.Set Variable ${output}[0] ${output}[1]
440 ... ELSE IF "${table_id}" == "${INTERNAL_TUNNEL_TABLE}" BuiltIn.Set Variable ${output}[2] ${output}[3]
441 ... ELSE IF "${table_id}" == "${L3_TABLE}" BuiltIn.Set Variable ${output}[0] ${output}[1]
442 ${tunnel_id} = Convert To Integer ${tunnel_id} 16
443 [Return] ${tunnel_id} ${packet_count}
445 Verify Dump Flows For Specific Table
446 [Arguments] ${compute_ip} ${table_num} ${flag} ${additional_args}=${EMPTY} @{matching_paras}
447 [Documentation] To Verify flows are present for the corresponding table Number
448 ${flow_output} = Utils.Run Command On Remote System ${compute_ip} sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}|grep table=${table_num} ${additional_args}
450 FOR ${matching_str} IN @{matching_paras}
451 BuiltIn.Run Keyword If ${flag}==True BuiltIn.Should Contain ${flow_output} ${matching_str}
452 ... ELSE BuiltIn.Should Not Contain ${flow_output} ${matching_str}
455 Verify Vni Segmentation Id and Tunnel Id
456 [Arguments] ${port1} ${port2} ${net1} ${net2} ${vm1_ip} ${vm2_ip}
458 [Documentation] Get tunnel id and packet count from specified table id and destination port mac address
459 ${port_mac1} = OpenStackOperations.Get Port Mac ${port1}
460 ${port_mac2} = OpenStackOperations.Get Port Mac ${port2}
461 ${segmentation_id1} = OpenStackOperations.Get Network Segmentation Id ${net1}
462 ${segmentation_id2} = OpenStackOperations.Get Network Segmentation Id ${net2}
463 ${egress_tun_id} ${before_count_egress_port1} = OVSDB.Get Tunnel Id And Packet Count ${OS_CMP1_CONN_ID} ${L3_TABLE} tun_id=${segmentation_id2} mac=${port_mac2}
464 BuiltIn.Should Be Equal As Numbers ${segmentation_id2} ${egress_tun_id}
465 ${egress_tun_id} ${before_count_egress_port2} = OVSDB.Get Tunnel Id And Packet Count ${OS_CMP2_CONN_ID} ${L3_TABLE} tun_id=${segmentation_id1} mac=${port_mac1}
466 BuiltIn.Should Be Equal As Numbers ${segmentation_id1} ${egress_tun_id}
467 ${ingress_tun_id} ${before_count_ingress_port1} = OVSDB.Get Tunnel Id And Packet Count ${OS_CMP1_CONN_ID} ${INTERNAL_TUNNEL_TABLE} tun_id=${segmentation_id1}
468 BuiltIn.Should Be Equal As Numbers ${segmentation_id1} ${ingress_tun_id}
469 ${ingress_tun_id} ${before_count_ingress_port2} = OVSDB.Get Tunnel Id And Packet Count ${OS_CMP2_CONN_ID} ${INTERNAL_TUNNEL_TABLE} tun_id=${segmentation_id2}
470 BuiltIn.Should Be Equal As Numbers ${segmentation_id2} ${ingress_tun_id}
471 ${ping_cmd} = BuiltIn.Run Keyword If '${ip}'=='ipv4' BuiltIn.Set Variable ping -c ${DEFAULT_PING_COUNT} ${vm2_ip}
472 ... ELSE BuiltIn.Set Variable ping6 -c ${DEFAULT_PING_COUNT} ${vm2_ip}
473 ${output} = OpenStackOperations.Execute Command on VM Instance ${net1} ${vm1_ip} ${ping_cmd}
474 BuiltIn.Should Contain ${output} 64 bytes
475 BuiltIn.Wait Until Keyword Succeeds 60s 5s OVSDB.Verify Vni Packet Count After Traffic ${before_count_egress_port1} ${before_count_egress_port2} ${before_count_ingress_port1}
476 ... ${before_count_ingress_port2} ${segmentation_id1} ${segmentation_id2} ${port_mac1} ${port_mac2}
478 Verify Vni Packet Count After Traffic
479 [Arguments] ${before_count_egress_port1} ${before_count_egress_port2} ${before_count_ingress_port1} ${before_count_ingress_port2} ${segmentation_id1} ${segmentation_id2}
480 ... ${port_mac1} ${port_mac2}
481 [Documentation] Verify the packet count after the traffic sent
482 ${tun_id} ${after_count_egress_port2} = OVSDB.Get Tunnel Id And Packet Count ${OS_CMP2_CONN_ID} ${L3_TABLE} tun_id=${segmentation_id1} mac=${port_mac1}
483 ${tun_id} ${after_count_ingress_port2} = OVSDB.Get Tunnel Id And Packet Count ${OS_CMP2_CONN_ID} ${INTERNAL_TUNNEL_TABLE} tun_id=${segmentation_id2}
484 ${tun_id} ${after_count_egress_port1} = OVSDB.Get Tunnel Id And Packet Count ${OS_CMP1_CONN_ID} ${L3_TABLE} tun_id=${segmentation_id2} mac=${port_mac2}
485 ${tun_id} ${after_count_ingress_port1} = OVSDB.Get Tunnel Id And Packet Count ${OS_CMP1_CONN_ID} ${INTERNAL_TUNNEL_TABLE} tun_id=${segmentation_id1}
486 ${diff_count_egress_port1} = BuiltIn.Evaluate ${after_count_egress_port1} - ${before_count_egress_port1}
487 ${diff_count_ingress_port1} = BuiltIn.Evaluate ${after_count_ingress_port1} - ${before_count_ingress_port1}
488 ${diff_count_egress_port2} = BuiltIn.Evaluate ${after_count_egress_port2} - ${before_count_egress_port2}
489 ${diff_count_ingress_port2} = BuiltIn.Evaluate ${after_count_ingress_port2} - ${before_count_ingress_port2}
490 BuiltIn.Should Be True ${diff_count_egress_port1} >= ${DEFAULT_PING_COUNT}
491 BuiltIn.Should Be True ${diff_count_ingress_port1} >= ${DEFAULT_PING_COUNT}
492 BuiltIn.Should Be True ${diff_count_egress_port2} >= ${DEFAULT_PING_COUNT}
493 BuiltIn.Should Be True ${diff_count_ingress_port2} >= ${DEFAULT_PING_COUNT}
495 Get Flow Entries On Node
496 [Arguments] ${conn_id} ${switch}=${INTEGRATION_BRIDGE}
497 [Documentation] Return flow entries on the given Node.
498 SSHLibrary.Switch Connection ${conn_id}
499 ${output} = Utils.Write Commands Until Expected Prompt sudo ovs-ofctl -O OpenFlow13 dump-flows ${switch} ${DEFAULT_LINUX_PROMPT_STRICT}
500 BuiltIn.Log ${output}
504 [Arguments] ${dpn_ip} ${state}=ACTIVE
505 [Documentation] Verify ovsdb state for the given DPN
506 ${output} = Utils.Run Command On Remote System And Log ${dpn_ip} sudo ovsdb-client dump -f list Open_vSwitch Controller | grep state
507 BuiltIn.Log ${output}
508 BuiltIn.Should Contain ${output} state=${state}
510 Verify Flows Are Present On Node
511 [Arguments] ${conn_id} ${match}
512 [Documentation] Verify Flows Are Present On The Given Node
513 ${output} = OVSDB.Get Flow Entries On Node ${conn_id}
514 BuiltIn.Should Contain ${output} ${match}