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