4 Library OperatingSystem
5 Library RequestsLibrary
8 Resource ClusterManagement.robot
10 Resource ${CURDIR}/TemplatedRequests.robot
11 Resource ../variables/Variables.robot
12 Resource ../variables/ovsdb/Variables.robot
16 ${OVSDB_CONFIG_DIR} ${CURDIR}/../variables/ovsdb
17 ${INTEGRATION_BRIDGE} br-int
18 ${INTERNAL_TUNNEL_TABLE} 36
20 ${DEFAULT_PING_COUNT} 3
24 [Arguments] ${resp_content}
25 IF '''${resp_content}''' != '${EMPTY}'
26 ${resp_json} = RequestsLibrary.To Json ${resp_content} pretty_print=True
28 ${resp_json} = BuiltIn.Set Variable ${EMPTY}
30 BuiltIn.Log ${resp_json}
34 [Arguments] ${node_ip} ${port}=${OVSDB_NODE_PORT}
35 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_node.json
36 ${body} = Replace String ${body} 127.0.0.1 ${node_ip}
37 ${body} = Replace String ${body} 61644 ${port}
38 ${uri} = Builtin.Set Variable ${RFC8040_TOPO_OVSDB1_API}
39 BuiltIn.Log URI is ${uri}
40 BuiltIn.Log data: ${body}
41 ${resp} = RequestsLibrary.Post Request session ${uri} data=${body}
42 OVSDB.Log Request ${resp.text}
43 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
46 [Documentation] This will Initiate the connection to OVSDB node from controller
47 [Arguments] ${node_ip} ${port}=${OVSDB_NODE_PORT}
48 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/connect.json
49 ${body} = String.Replace String ${body} 127.0.0.1 ${node_ip}
50 ${body} = String.Replace String ${body} 61644 ${port}
51 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_API}${node_ip}%3A${port}
52 BuiltIn.Log URI is ${uri}
53 BuiltIn.Log data: ${body}
54 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
55 OVSDB.Log Request ${resp.text}
56 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
58 Disconnect From Ovsdb Node
59 [Documentation] This request will disconnect the OVSDB node from the controller
60 [Arguments] ${node_ip} ${port}=${OVSDB_NODE_PORT}
61 ${resp} = RequestsLibrary.Delete Request session ${RFC8040_SOUTHBOUND_NODE_API}${node_ip}%3A${port}
62 BuiltIn.Should Be Equal As Strings ${resp.status_code} 204
64 Add Bridge To Ovsdb Node
65 [Documentation] This will create a bridge and add it to the OVSDB node.
66 [Arguments] ${node_id} ${node_ip} ${bridge} ${datapath_id} ${port}=${OVSDB_NODE_PORT}
67 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_bridge.json
68 ${body} = String.Replace String ${body} ovsdb://127.0.0.1:61644 ovsdb://${node_id}
69 ${body} = String.Replace String ${body} tcp:127.0.0.1:6633 tcp:${ODL_SYSTEM_IP}:6633
70 ${body} = String.Replace String ${body} 127.0.0.1 ${node_ip}
71 ${body} = String.Replace String ${body} br01 ${bridge}
72 ${body} = String.Replace String ${body} 61644 ${port}
73 ${body} = String.Replace String ${body} 0000000000000001 ${datapath_id}
74 ${node_id_} = BuiltIn.Evaluate """${node_id}""".replace("/","%2F").replace(":","%3A")
75 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_API}${node_id_}%2Fbridge%2F${bridge}
76 BuiltIn.Log URI is ${uri}
77 BuiltIn.Log data: ${body}
78 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
79 OVSDB.Log Request ${resp.text}
80 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
82 Delete Bridge From Ovsdb Node
83 [Documentation] This request will delete the bridge node from the OVSDB
84 [Arguments] ${node_id} ${bridge}
85 ${resp} = RequestsLibrary.Delete Request
87 ... ${RFC8040_SOUTHBOUND_NODE_API}${node_id}%2Fbridge%2F${bridge}
88 BuiltIn.Should Be Equal As Strings ${resp.status_code} 204
91 [Documentation] Using the json data body file as a template, a REST config request is made to
92 ... create a termination-point ${tp_name} on ${bridge} for the given ${node_id}. The ports
93 ... remote-ip defaults to ${TOOLS_SYSTEM_IP}
94 [Arguments] ${node_id} ${bridge} ${tp_name} ${remote_ip}=${TOOLS_SYSTEM_IP}
95 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_port.json
96 ${body} = String.Replace String ${body} 192.168.0.21 ${remote_ip}
97 ${body} = String.Replace String ${body} vxlanport ${tp_name}
98 ${node_id_} = BuiltIn.Evaluate """${node_id}""".replace("/","%2F").replace(":","%3A")
99 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_API}${node_id_}%2Fbridge%2F${bridge}
100 ${resp} = RequestsLibrary.Put Request session ${uri}/termination-point=${tp_name} data=${body}
101 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
104 [Documentation] This request will create vxlan port for vxlan tunnel and attach it to the specific bridge
105 [Arguments] ${node_ip} ${bridge} ${vxlan_port} ${remote_ip} ${port}=${OVSDB_NODE_PORT}
106 OVSDB.Add Termination Point ${node_ip}:${port} ${bridge} ${vxlan_port} ${remote_ip}
108 Verify OVS Reports Connected
109 [Documentation] Uses "vsctl show" to check for string "is_connected"
110 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP}
111 ${output} = Verify Ovs-vsctl Output show is_connected ${tools_system}
114 Verify Ovs-vsctl Output
115 [Documentation] A wrapper keyword to make it easier to validate ovs-vsctl output, and gives an easy
116 ... way to check this output in a WUKS. The argument ${should_match} can control if the match should
117 ... exist (True} or not (False) or don't care (anything but True or False). ${should_match} is True by default
118 [Arguments] ${vsctl_args} ${expected_output} ${ovs_system}=${TOOLS_SYSTEM_IP} ${should_match}=True
119 ${output} = Utils.Run Command On Mininet ${ovs_system} sudo ovs-vsctl ${vsctl_args}
120 BuiltIn.Log ${output}
121 IF "${should_match}" == "True"
122 BuiltIn.Should Contain ${output} ${expected_output}
124 IF "${should_match}" == "False"
125 BuiltIn.Should Not Contain ${output} ${expected_output}
130 [Documentation] Queries the topology in the operational datastore and searches for the node that has
131 ... the ${ovs_system_ip} argument as the "remote-ip". If found, the value returned will be the value of
132 ... node-id stripped of "ovsdb://uuid/". If not found, ${EMPTY} will be returned.
133 [Arguments] ${ovs_system_ip}=${TOOLS_SYSTEM_IP} ${controller_http_session}=session
134 ${uuid} = Set Variable ${EMPTY}
135 ${resp} = RequestsLibrary.Get Request ${controller_http_session} ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
136 OVSDB.Log Request ${resp.text}
137 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
138 ${resp_json} = RequestsLibrary.To Json ${resp.text}
139 ${topologies} = Collections.Get From Dictionary ${resp_json} network-topology:topology
140 ${topology} = Collections.Get From List ${topologies} 0
141 ${node_list} = Collections.Get From Dictionary ${topology} node
142 BuiltIn.Log ${node_list}
143 # Since bridges are also listed as nodes, but will not have the extra "ovsdb:connection-info data,
144 # we need to use "Run Keyword And Ignore Error" below.
145 FOR ${node} IN @{node_list}
146 ${node_id} = Collections.Get From Dictionary ${node} node-id
147 ${node_uuid} = String.Replace String ${node_id} ovsdb://uuid/ ${EMPTY}
148 ${status} ${connection_info} = BuiltIn.Run Keyword And Ignore Error
149 ... Collections.Get From Dictionary
151 ... ovsdb:connection-info
152 ${status} ${remote_ip} = BuiltIn.Run Keyword And Ignore Error
153 ... Collections.Get From Dictionary
154 ... ${connection_info}
156 ${uuid} = Set Variable If '${remote_ip}' == '${ovs_system_ip}' ${node_uuid} ${uuid}
161 [Documentation] Used to log useful test debugs for OVSDB related system tests.
162 [Arguments] ${switch}=${INTEGRATION_BRIDGE}
163 ${output} = Utils.Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-vsctl show
164 BuiltIn.Log ${output}
165 ${output} = Utils.Run Command On Mininet
166 ... ${TOOLS_SYSTEM_IP}
167 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${switch} | cut -d',' -f3-
168 BuiltIn.Log ${output}
170 Clean OVSDB Test Environment
171 [Documentation] General Use Keyword attempting to sanitize test environment for OVSDB related
172 ... tests. Not every step will always be neccessary, but should not cause any problems for
173 ... any new ovsdb test suites.
174 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP}
175 Utils.Clean Mininet System ${tools_system}
176 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl del-manager
177 Utils.Run Command On Mininet ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl stop
178 Utils.Run Command On Mininet ${tools_system} sudo rm -rf /etc/openvswitch/conf.db
179 Utils.Run Command On Mininet ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl start
182 [Documentation] Restart the OVS node without cleaning the current configuration.
183 [Arguments] ${ovs_ip}
184 ${output} = Utils.Run Command On Mininet ${ovs_ip} sudo systemctl restart openvswitch
185 BuiltIn.Log ${output}
187 Set Controller In OVS Bridge
188 [Documentation] Sets controller for the OVS bridge ${bridge} using ${controller_opt} and OF version ${ofversion}.
189 [Arguments] ${tools_system} ${bridge} ${controller_opt} ${ofversion}=13
190 Utils.Run Command On Mininet
192 ... sudo ovs-vsctl set bridge ${bridge} protocols=OpenFlow${ofversion}
193 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl set-controller ${bridge} ${controller_opt}
195 Check OVS OpenFlow Connections
196 [Documentation] Check OVS instance with IP ${tools_system} has ${of_connections} OpenFlow connections.
197 [Arguments] ${tools_system} ${of_connections}
198 ${output} = Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl show
199 BuiltIn.Log ${output}
200 BuiltIn.Should Contain X Times ${output} is_connected ${of_connections}
202 Add Multiple Managers to OVS
203 [Documentation] Connect OVS to the list of controllers in the ${controller_index_list} or all if no list is provided.
204 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP} ${controller_index_list}=${EMPTY} ${ovs_mgr_port}=6640
205 ${index_list} = ClusterManagement.List Indices Or All given_list=${controller_index_list}
206 Utils.Clean Mininet System ${tools_system}
207 ${ovs_opt} = BuiltIn.Set Variable
208 FOR ${index} IN @{index_list}
209 ${ovs_opt} = BuiltIn.Catenate ${ovs_opt} ${SPACE}tcp:${ODL_SYSTEM_${index}_IP}:${ovs_mgr_port}
210 BuiltIn.Log ${ovs_opt}
212 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl set-manager ${ovs_opt}
213 ${output} = BuiltIn.Wait Until Keyword Succeeds 5s 1s Verify OVS Reports Connected ${tools_system}
214 BuiltIn.Log ${output}
215 ${controller_index} = Collections.Get_From_List ${index_list} 0
216 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${controller_index}
217 ${ovsdb_uuid} = BuiltIn.Wait Until Keyword Succeeds
220 ... OVSDB.Get OVSDB UUID
221 ... controller_http_session=${session}
225 [Documentation] Returns the dpnid from the system at the given ip address using ovs-ofctl assuming br-int is present.
227 ${output} = Utils.Run Command On Remote System
229 ... sudo ovs-ofctl show -O Openflow13 ${INTEGRATION_BRIDGE} | head -1 | awk -F "dpid:" '{print $2}'
230 ${dpnid} = BuiltIn.Convert To Integer ${output} 16
235 [Documentation] Return the subnet from the system at the given ip address and interface
237 ${output} = Utils.Run Command On Remote System ${ip} /usr/sbin/ip addr show | grep ${ip} | cut -d' ' -f6
238 ${interface} = ipaddress.ip_interface ${output}
239 ${network} = BuiltIn.Set Variable ${interface.network.__str__()}
243 [Documentation] Returns the ethernet adapter name from the system at the given ip address using ip addr show.
245 ${adapter} = Utils.Run Command On Remote System
247 ... /usr/sbin/ip addr show | grep ${ip} | cut -d " " -f 11
248 BuiltIn.Log ${adapter}
252 [Documentation] Returns the default gateway at the given ip address using route command.
254 ${gateway} = Utils.Run Command On Remote System
256 ... /usr/sbin/route -n | grep '^0.0.0.0' | cut -d " " -f 10
257 BuiltIn.Log ${gateway}
261 [Documentation] Get the port number for the given sub-port id
262 [Arguments] ${subportid} ${ip_addr}
263 ${command} = Set Variable
264 ... sudo ovs-ofctl -O OpenFlow13 show ${INTEGRATION_BRIDGE} | grep ${subportid} | awk '{print$1}'
265 BuiltIn.Log sudo ovs-ofctl -O OpenFlow13 show ${INTEGRATION_BRIDGE} | grep ${subportid} | awk '{print$1}'
266 ${output} = Utils.Run Command On Remote System ${ip_addr} ${command}
267 ${port_number} = BuiltIn.Should Match Regexp ${output} [0-9]+
268 RETURN ${port_number}
271 [Documentation] Get the Metadata for a given port
272 [Arguments] ${ip_addr} ${port}
273 ${cmd} = Set Variable
274 ... sudo ovs-ofctl dump-flows -O Openflow13 ${INTEGRATION_BRIDGE} | grep table=0 | grep in_port=${port}
275 ${output} = Utils.Run Command On Remote System ${ip_addr} ${cmd}
276 @{list_any_matches} = String.Get_Regexp_Matches ${output} metadata:(\\w{12}) 1
277 ${metadata} = Builtin.Convert To String @{list_any_matches}
278 ${output} = String.Get Substring ${metadata} 2
281 Log Config And Operational Topology
282 [Documentation] For debugging purposes, this will log both config and operational topo data stores
283 ${resp} = RequestsLibrary.Get Request session ${RFC8040_CONFIG_TOPO_API}
284 OVSDB.Log Request ${resp.text}
285 ${resp} = RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_TOPO_API}
286 OVSDB.Log Request ${resp.text}
288 Config and Operational Topology Should Be Empty
289 [Documentation] This will check that only the expected output is there for both operational and config
290 ... topology data stores. Empty probably means that only ovsdb:1 is there.
291 ${config_resp} = RequestsLibrary.Get Request session ${RFC8040_CONFIG_TOPO_API}
292 ${operational_resp} = RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_TOPO_API}
293 BuiltIn.Should Contain ${config_resp.text} {"topology-id":"ovsdb:1"}
294 BuiltIn.Should Contain ${operational_resp.text} {"topology-id":"ovsdb:1"}
296 Modify Multi Port Body
297 [Documentation] Updates two port names for the given ${bridge} in config store
298 [Arguments] ${ovs_1_port_name} ${ovs_2_port_name} ${bridge}
299 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/bug_7414/create_multiple_ports.json
300 ${ovs_1_ovsdb_uuid} = Get OVSDB UUID ${TOOLS_SYSTEM_IP}
301 ${ovs_2_ovsdb_uuid} = Get OVSDB UUID ${TOOLS_SYSTEM_2_IP}
302 ${body} = Replace String ${body} OVS_1_UUID ${ovs_1_ovsdb_uuid}
303 ${body} = Replace String ${body} OVS_2_UUID ${ovs_2_ovsdb_uuid}
304 ${body} = Replace String ${body} OVS_1_BRIDGE_NAME ${bridge}
305 ${body} = Replace String ${body} OVS_2_BRIDGE_NAME ${bridge}
306 ${body} = Replace String ${body} OVS_1_IP ${TOOLS_SYSTEM_IP}
307 ${body} = Replace String ${body} OVS_2_IP ${TOOLS_SYSTEM_2_IP}
308 ${body} = Replace String ${body} OVS_1_PORT_NAME ${ovs_1_port_name}
309 ${body} = Replace String ${body} OVS_2_PORT_NAME ${ovs_2_port_name}
310 ${uri} = Builtin.Set Variable ${RFC8040_TOPO_API}
311 BuiltIn.Log URI is ${uri}
312 BuiltIn.Log data: ${body}
313 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
314 OVSDB.Log Request ${resp.text}
315 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
320 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_qos.json
321 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_HOST1_API}/ovsdb:qos-entries=${qos}
322 ${body} = Replace String ${body} QOS-1 ${qos}
323 BuiltIn.Log URI is ${uri}
324 BuiltIn.Log data: ${body}
325 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
326 OVSDB.Log Request ${resp.text}
327 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
331 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_qoslinkedqueue.json
332 ${body} = Replace String ${body} QUEUE-1 ${queue}
333 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_HOST1_API}/ovsdb:queues=${queue}
334 BuiltIn.Log URI is ${uri}
335 BuiltIn.Log data: ${body}
336 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
337 OVSDB.Log Request ${resp.text}
338 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
342 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/update_existingqos.json
343 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_HOST1_API}/ovsdb:qos-entries=${QOS}
344 BuiltIn.Log URL is ${uri}
345 BuiltIn.Log data: ${body}
346 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
347 OVSDB.Log Request ${resp.text}
348 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
350 Create Qos Linked Queue
351 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/bug_7160/create_qoslinkedqueue.json
352 ${resp} = RequestsLibrary.Put Request session ${RFC8040_SOUTHBOUND_NODE_HOST1_API} data=${body}
353 OVSDB.Log Request ${resp.text}
354 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
357 [Documentation] Add higher levels of OVS logging
358 [Arguments] ${conn_id}
359 SSHLibrary.Switch Connection ${conn_id}
360 @{modules} = BuiltIn.Create List
364 ... ofp_actions:file:dbg
365 ... ofp_errors:file:dbg
366 ... ofp_msgs:file:dbg
367 ... ovsdb_error:file:dbg
371 FOR ${module} IN @{modules}
372 Utils.Write Commands Until Expected Prompt
373 ... sudo ovs-appctl --target ovs-vswitchd vlog/set ${module}
374 ... ${DEFAULT_LINUX_PROMPT_STRICT}
376 Utils.Write Commands Until Expected Prompt
377 ... sudo ovs-appctl --target ovs-vswitchd vlog/list
378 ... ${DEFAULT_LINUX_PROMPT_STRICT}
381 [Documentation] Reset the OVS logging
382 [Arguments] ${conn_id}
383 SSHLibrary.Switch Connection ${conn_id}
384 ${output} = Utils.Write Commands Until Expected Prompt
385 ... sudo ovs-appctl --target ovs-vswitchd vlog/set :file:info
386 ... ${DEFAULT_LINUX_PROMPT_STRICT}
389 SetupUtils.Setup_Utils_For_Setup_And_Teardown
390 KarafKeywords.Open Controller Karaf Console On Background
391 RequestsLibrary.Create Session
393 ... http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
395 ... headers=${HEADERS}
396 OVSDB.Log Config And Operational Topology
399 [Documentation] Cleans up test environment, close existing sessions.
400 [Arguments] ${uris}=@{EMPTY}
401 OVSDB.Clean OVSDB Test Environment ${TOOLS_SYSTEM_IP}
402 FOR ${uri} IN @{uris}
403 RequestsLibrary.Delete Request session ${uri}
405 ${resp} = RequestsLibrary.Get Request session ${RFC8040_CONFIG_TOPO_API}
406 OVSDB.Log Config And Operational Topology
407 RequestsLibrary.Delete All Sessions
409 Get DumpFlows And Ovsconfig
410 [Documentation] Get the OvsConfig and Flow entries from OVS
411 [Arguments] ${conn_id} ${bridge}
412 SSHLibrary.Switch Connection ${conn_id}
413 Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
414 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
415 Write Commands Until Expected Prompt
416 ... sudo ovs-ofctl show ${bridge} -OOpenFlow13
417 ... ${DEFAULT_LINUX_PROMPT_STRICT}
418 Write Commands Until Expected Prompt
419 ... sudo ovs-ofctl dump-flows ${bridge} -OOpenFlow13
420 ... ${DEFAULT_LINUX_PROMPT_STRICT}
421 Write Commands Until Expected Prompt
422 ... sudo ovs-ofctl dump-groups ${bridge} -OOpenFlow13
423 ... ${DEFAULT_LINUX_PROMPT_STRICT}
424 Write Commands Until Expected Prompt
425 ... sudo ovs-ofctl dump-group-stats ${bridge} -OOpenFlow13
426 ... ${DEFAULT_LINUX_PROMPT_STRICT}
427 Write Commands Until Expected Prompt sudo ovs-vsctl list interface ${DEFAULT_LINUX_PROMPT_STRICT}
430 [Documentation] start the OVS node.
431 [Arguments] ${ovs_ip}
432 ${output} = Utils.Run Command On Mininet ${ovs_ip} sudo /usr/share/openvswitch/scripts/ovs-ctl start
433 BuiltIn.Log ${output}
436 [Documentation] Stop the OVS node.
437 [Arguments] ${ovs_ip}
438 ${output} = Utils.Run Command On Mininet ${ovs_ip} sudo /usr/share/openvswitch/scripts/ovs-ctl stop
439 BuiltIn.Log ${output}
442 [Documentation] This keyword returns first bridge name and UUID from list of bridges.
443 ${result} = SSHLibrary.Execute Command sudo ovs-vsctl show
444 ${uuid} = String.Get Line ${result} 0
445 ${line} ${bridge_name} = Builtin.Should Match Regexp ${result} Bridge ([\\w-]+)
446 RETURN ${uuid} ${bridge_name}
448 Delete OVS Controller
449 [Documentation] Delete controller from OVS
450 [Arguments] ${ovs_ip} ${bridge}=${INTEGRATION_BRIDGE}
451 ${del_ctr} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl del-controller ${bridge}
452 BuiltIn.Log ${del_ctr}
455 [Documentation] Delete manager from OVS
456 [Arguments] ${ovs_ip}
457 ${del_mgr} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl del-manager
458 BuiltIn.Log ${del_mgr}
460 Delete Groups On Bridge
461 [Documentation] Delete OVS groups from ${br}
462 [Arguments] ${ovs_ip} ${br}=${INTEGRATION_BRIDGE}
463 ${del_grp} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-ofctl -O Openflow13 del-groups ${br}
464 BuiltIn.Log ${del_grp}
466 Get Ports From Bridge By Type
467 [Documentation] Get ${type} ports for a bridge ${br} on node ${ovs_ip}.
468 [Arguments] ${ovs_ip} ${br} ${type}
469 ${ports} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl list-ports ${br} | grep "${type}"
470 ${ports_list} = String.Split to lines ${ports}
473 Delete Ports On Bridge By Type
474 [Documentation] List all ports of ${br} and delete ${type} ports
475 [Arguments] ${ovs_ip} ${br} ${type}
476 ${ports_present} = Get Ports From Bridge By Type ${ovs_ip} ${br} ${type}
477 FOR ${port} IN @{ports_present}
478 ${del-ports} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl del-port ${br} ${port}
479 BuiltIn.Log ${del-ports}
481 ${ports_present_after_delete} = Get Ports From Bridge By Type ${ovs_ip} ${br} ${type}
482 BuiltIn.Log ${ports_present_after_delete}
484 Get Tunnel Id And Packet Count
485 [Documentation] Get tunnel id and packet count from specified table id
486 ... Using regex get the n_packet and the tunnel_id from the table flow.
487 [Arguments] ${conn_id} ${table_id} ${tun_id} ${mac}=""
488 ${tun_id} = BuiltIn.Convert To Hex ${tun_id} prefix=0x lowercase=yes
489 IF "${table_id}" == "${INTERNAL_TUNNEL_TABLE}"
490 ${cmd} = BuiltIn.Set Variable
491 ... sudo ovs-ofctl dump-flows br-int -OOpenFlow13 | grep table=${table_id} | grep ${mac} | grep tun_id=${tun_id} | grep goto_table:${ELAN_DMACTABLE}
493 ${cmd} = BuiltIn.Set Variable
494 ... sudo ovs-ofctl dump-flows br-int -OOpenFlow13 | grep table=${table_id} | grep ${mac}
496 SSHLibrary.Switch Connection ${conn_id}
497 ${output} = Utils.Write Commands Until Expected Prompt ${cmd} ${DEFAULT_LINUX_PROMPT_STRICT}
498 @{list} = Split to lines ${output}
499 ${output} = Set Variable ${list}[0]
500 ${output} = String.Get Regexp Matches
502 ... n_packets=([0-9]+),.*set_field:(0x[0-9a-z]+)|n_packets=([0-9]+),.*tun_id=(0x[0-9a-z]+)
507 ${output} = BuiltIn.Set Variable ${output}[0]
508 ${output} = Convert To List ${output}
509 IF "${table_id}" == "${ELAN_DMACTABLE}"
510 ${packet_count} ${tunnel_id} = BuiltIn.Set Variable ${output}[0] ${output}[1]
511 ELSE IF "${table_id}" == "${INTERNAL_TUNNEL_TABLE}"
512 ${packet_count} ${tunnel_id} = BuiltIn.Set Variable ${output}[2] ${output}[3]
513 ELSE IF "${table_id}" == "${L3_TABLE}"
514 ${packet_count} ${tunnel_id} = BuiltIn.Set Variable ${output}[0] ${output}[1]
516 ${packet_count} ${tunnel_id} = Set Variable ${None} ${None}
518 ${tunnel_id} = Convert To Integer ${tunnel_id} 16
519 RETURN ${tunnel_id} ${packet_count}
521 Verify Dump Flows For Specific Table
522 [Documentation] To Verify flows are present for the corresponding table Number
523 [Arguments] ${compute_ip} ${table_num} ${flag} ${additional_args}=${EMPTY} @{matching_paras}
524 ${flow_output} = Utils.Run Command On Remote System
526 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}|grep table=${table_num} ${additional_args}
528 FOR ${matching_str} IN @{matching_paras}
530 BuiltIn.Should Contain ${flow_output} ${matching_str}
532 BuiltIn.Should Not Contain ${flow_output} ${matching_str}
536 Verify Vni Packet Count After Traffic
537 [Documentation] Verify the packet count after the traffic sent
538 [Arguments] ${before_count_egress_port1} ${before_count_egress_port2} ${before_count_ingress_port1} ${before_count_ingress_port2} ${segmentation_id1} ${segmentation_id2}
539 ... ${port_mac1} ${port_mac2}
540 ${tun_id} ${after_count_egress_port2} = OVSDB.Get Tunnel Id And Packet Count
541 ... ${OS_CMP2_CONN_ID}
543 ... tun_id=${segmentation_id1}
545 ${tun_id} ${after_count_ingress_port2} = OVSDB.Get Tunnel Id And Packet Count
546 ... ${OS_CMP2_CONN_ID}
547 ... ${INTERNAL_TUNNEL_TABLE}
548 ... tun_id=${segmentation_id2}
549 ${tun_id} ${after_count_egress_port1} = OVSDB.Get Tunnel Id And Packet Count
550 ... ${OS_CMP1_CONN_ID}
552 ... tun_id=${segmentation_id2}
554 ${tun_id} ${after_count_ingress_port1} = OVSDB.Get Tunnel Id And Packet Count
555 ... ${OS_CMP1_CONN_ID}
556 ... ${INTERNAL_TUNNEL_TABLE}
557 ... tun_id=${segmentation_id1}
558 ${diff_count_egress_port1} = BuiltIn.Evaluate ${after_count_egress_port1} - ${before_count_egress_port1}
559 ${diff_count_ingress_port1} = BuiltIn.Evaluate ${after_count_ingress_port1} - ${before_count_ingress_port1}
560 ${diff_count_egress_port2} = BuiltIn.Evaluate ${after_count_egress_port2} - ${before_count_egress_port2}
561 ${diff_count_ingress_port2} = BuiltIn.Evaluate ${after_count_ingress_port2} - ${before_count_ingress_port2}
562 BuiltIn.Should Be True ${diff_count_egress_port1} >= ${DEFAULT_PING_COUNT}
563 BuiltIn.Should Be True ${diff_count_ingress_port1} >= ${DEFAULT_PING_COUNT}
564 BuiltIn.Should Be True ${diff_count_egress_port2} >= ${DEFAULT_PING_COUNT}
565 BuiltIn.Should Be True ${diff_count_ingress_port2} >= ${DEFAULT_PING_COUNT}
567 Get Flow Entries On Node
568 [Documentation] Return flow entries on the given Node.
569 [Arguments] ${conn_id} ${switch}=${INTEGRATION_BRIDGE}
570 SSHLibrary.Switch Connection ${conn_id}
571 ${output} = Utils.Write Commands Until Expected Prompt
572 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${switch}
573 ... ${DEFAULT_LINUX_PROMPT_STRICT}
574 BuiltIn.Log ${output}
578 [Documentation] Verify ovsdb state for the given DPN
579 [Arguments] ${dpn_ip} ${state}=ACTIVE
580 ${output} = Utils.Run Command On Remote System And Log
582 ... sudo ovsdb-client dump -f list Open_vSwitch Controller | grep state
583 BuiltIn.Log ${output}
584 BuiltIn.Should Contain ${output} state=${state}
586 Verify Flows Are Present On Node
587 [Documentation] Verify Flows Are Present On The Given Node
588 [Arguments] ${conn_id} ${match}
589 ${output} = OVSDB.Get Flow Entries On Node ${conn_id}
590 BuiltIn.Should Contain ${output} ${match}