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
13 Resource ../variables/netvirt/Variables.robot
17 ${OVSDB_CONFIG_DIR} ${CURDIR}/../variables/ovsdb
22 [Arguments] ${resp_content}
23 IF '''${resp_content}''' != '${EMPTY}'
24 ${resp_json} = RequestsLibrary.To Json ${resp_content} pretty_print=True
26 ${resp_json} = BuiltIn.Set Variable ${EMPTY}
28 BuiltIn.Log ${resp_json}
32 [Arguments] ${node_ip} ${port}=${OVSDB_NODE_PORT}
33 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_node.json
34 ${body} = Replace String ${body} 127.0.0.1 ${node_ip}
35 ${body} = Replace String ${body} 61644 ${port}
36 ${uri} = Builtin.Set Variable ${RFC8040_TOPO_OVSDB1_API}
37 BuiltIn.Log URI is ${uri}
38 BuiltIn.Log data: ${body}
39 ${resp} = RequestsLibrary.Post Request session ${uri} data=${body}
40 OVSDB.Log Request ${resp.text}
41 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
44 [Documentation] This will Initiate the connection to OVSDB node from controller
45 [Arguments] ${node_ip} ${port}=${OVSDB_NODE_PORT}
46 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/connect.json
47 ${body} = String.Replace String ${body} 127.0.0.1 ${node_ip}
48 ${body} = String.Replace String ${body} 61644 ${port}
49 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_API}${node_ip}%3A${port}
50 BuiltIn.Log URI is ${uri}
51 BuiltIn.Log data: ${body}
52 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
53 OVSDB.Log Request ${resp.text}
54 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
56 Disconnect From Ovsdb Node
57 [Documentation] This request will disconnect the OVSDB node from the controller
58 [Arguments] ${node_ip} ${port}=${OVSDB_NODE_PORT}
59 ${resp} = RequestsLibrary.Delete Request session ${RFC8040_SOUTHBOUND_NODE_API}${node_ip}%3A${port}
60 BuiltIn.Should Be Equal As Strings ${resp.status_code} 204
62 Add Bridge To Ovsdb Node
63 [Documentation] This will create a bridge and add it to the OVSDB node.
64 [Arguments] ${node_id} ${node_ip} ${bridge} ${datapath_id} ${port}=${OVSDB_NODE_PORT}
65 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_bridge.json
66 ${body} = String.Replace String ${body} ovsdb://127.0.0.1:61644 ovsdb://${node_id}
67 ${body} = String.Replace String ${body} tcp:127.0.0.1:6633 tcp:${ODL_SYSTEM_IP}:6633
68 ${body} = String.Replace String ${body} 127.0.0.1 ${node_ip}
69 ${body} = String.Replace String ${body} br01 ${bridge}
70 ${body} = String.Replace String ${body} 61644 ${port}
71 ${body} = String.Replace String ${body} 0000000000000001 ${datapath_id}
72 ${node_id_} = BuiltIn.Evaluate """${node_id}""".replace("/","%2F").replace(":","%3A")
73 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_API}${node_id_}%2Fbridge%2F${bridge}
74 BuiltIn.Log URI is ${uri}
75 BuiltIn.Log data: ${body}
76 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
77 OVSDB.Log Request ${resp.text}
78 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
80 Delete Bridge From Ovsdb Node
81 [Documentation] This request will delete the bridge node from the OVSDB
82 [Arguments] ${node_id} ${bridge}
83 ${resp} = RequestsLibrary.Delete Request
85 ... ${RFC8040_SOUTHBOUND_NODE_API}${node_id}%2Fbridge%2F${bridge}
86 BuiltIn.Should Be Equal As Strings ${resp.status_code} 204
89 [Documentation] Using the json data body file as a template, a REST config request is made to
90 ... create a termination-point ${tp_name} on ${bridge} for the given ${node_id}. The ports
91 ... remote-ip defaults to ${TOOLS_SYSTEM_IP}
92 [Arguments] ${node_id} ${bridge} ${tp_name} ${remote_ip}=${TOOLS_SYSTEM_IP}
93 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_port.json
94 ${body} = String.Replace String ${body} 192.168.0.21 ${remote_ip}
95 ${body} = String.Replace String ${body} vxlanport ${tp_name}
96 ${node_id_} = BuiltIn.Evaluate """${node_id}""".replace("/","%2F").replace(":","%3A")
97 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_API}${node_id_}%2Fbridge%2F${bridge}
98 ${resp} = RequestsLibrary.Put Request session ${uri}/termination-point=${tp_name} data=${body}
99 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
102 [Documentation] This request will create vxlan port for vxlan tunnel and attach it to the specific bridge
103 [Arguments] ${node_ip} ${bridge} ${vxlan_port} ${remote_ip} ${port}=${OVSDB_NODE_PORT}
104 OVSDB.Add Termination Point ${node_ip}:${port} ${bridge} ${vxlan_port} ${remote_ip}
106 Verify OVS Reports Connected
107 [Documentation] Uses "vsctl show" to check for string "is_connected"
108 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP}
109 ${output} = Verify Ovs-vsctl Output show is_connected ${tools_system}
112 Verify Ovs-vsctl Output
113 [Documentation] A wrapper keyword to make it easier to validate ovs-vsctl output, and gives an easy
114 ... way to check this output in a WUKS. The argument ${should_match} can control if the match should
115 ... exist (True} or not (False) or don't care (anything but True or False). ${should_match} is True by default
116 [Arguments] ${vsctl_args} ${expected_output} ${ovs_system}=${TOOLS_SYSTEM_IP} ${should_match}=True
117 ${output} = Utils.Run Command On Mininet ${ovs_system} sudo ovs-vsctl ${vsctl_args}
118 BuiltIn.Log ${output}
119 IF "${should_match}" == "True"
120 BuiltIn.Should Contain ${output} ${expected_output}
122 IF "${should_match}" == "False"
123 BuiltIn.Should Not Contain ${output} ${expected_output}
128 [Documentation] Queries the topology in the operational datastore and searches for the node that has
129 ... the ${ovs_system_ip} argument as the "remote-ip". If found, the value returned will be the value of
130 ... node-id stripped of "ovsdb://uuid/". If not found, ${EMPTY} will be returned.
131 [Arguments] ${ovs_system_ip}=${TOOLS_SYSTEM_IP} ${controller_http_session}=session
132 ${uuid} = Set Variable ${EMPTY}
133 ${resp} = RequestsLibrary.Get Request ${controller_http_session} ${RFC8040_OPERATIONAL_TOPO_OVSDB1_API}
134 OVSDB.Log Request ${resp.text}
135 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
136 ${resp_json} = RequestsLibrary.To Json ${resp.text}
137 ${topologies} = Collections.Get From Dictionary ${resp_json} network-topology:topology
138 ${topology} = Collections.Get From List ${topologies} 0
139 ${node_list} = Collections.Get From Dictionary ${topology} node
140 BuiltIn.Log ${node_list}
141 # Since bridges are also listed as nodes, but will not have the extra "ovsdb:connection-info data,
142 # we need to use "Run Keyword And Ignore Error" below.
143 FOR ${node} IN @{node_list}
144 ${node_id} = Collections.Get From Dictionary ${node} node-id
145 ${node_uuid} = String.Replace String ${node_id} ovsdb://uuid/ ${EMPTY}
146 ${status} ${connection_info} = BuiltIn.Run Keyword And Ignore Error
147 ... Collections.Get From Dictionary
149 ... ovsdb:connection-info
150 ${status} ${remote_ip} = BuiltIn.Run Keyword And Ignore Error
151 ... Collections.Get From Dictionary
152 ... ${connection_info}
154 ${uuid} = Set Variable If '${remote_ip}' == '${ovs_system_ip}' ${node_uuid} ${uuid}
159 [Documentation] Used to log useful test debugs for OVSDB related system tests.
160 [Arguments] ${switch}=${INTEGRATION_BRIDGE}
161 ${output} = Utils.Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-vsctl show
162 BuiltIn.Log ${output}
163 ${output} = Utils.Run Command On Mininet
164 ... ${TOOLS_SYSTEM_IP}
165 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${switch} | cut -d',' -f3-
166 BuiltIn.Log ${output}
168 Clean OVSDB Test Environment
169 [Documentation] General Use Keyword attempting to sanitize test environment for OVSDB related
170 ... tests. Not every step will always be neccessary, but should not cause any problems for
171 ... any new ovsdb test suites.
172 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP}
173 Utils.Clean Mininet System ${tools_system}
174 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl del-manager
175 Utils.Run Command On Mininet ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl stop
176 Utils.Run Command On Mininet ${tools_system} sudo rm -rf /etc/openvswitch/conf.db
177 Utils.Run Command On Mininet ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl start
180 [Documentation] Restart the OVS node without cleaning the current configuration.
181 [Arguments] ${ovs_ip}
182 ${output} = Utils.Run Command On Mininet ${ovs_ip} sudo systemctl restart openvswitch
183 BuiltIn.Log ${output}
185 Set Controller In OVS Bridge
186 [Documentation] Sets controller for the OVS bridge ${bridge} using ${controller_opt} and OF version ${ofversion}.
187 [Arguments] ${tools_system} ${bridge} ${controller_opt} ${ofversion}=13
188 Utils.Run Command On Mininet
190 ... sudo ovs-vsctl set bridge ${bridge} protocols=OpenFlow${ofversion}
191 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl set-controller ${bridge} ${controller_opt}
193 Check OVS OpenFlow Connections
194 [Documentation] Check OVS instance with IP ${tools_system} has ${of_connections} OpenFlow connections.
195 [Arguments] ${tools_system} ${of_connections}
196 ${output} = Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl show
197 BuiltIn.Log ${output}
198 BuiltIn.Should Contain X Times ${output} is_connected ${of_connections}
200 Add Multiple Managers to OVS
201 [Documentation] Connect OVS to the list of controllers in the ${controller_index_list} or all if no list is provided.
202 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP} ${controller_index_list}=${EMPTY} ${ovs_mgr_port}=6640
203 ${index_list} = ClusterManagement.List Indices Or All given_list=${controller_index_list}
204 Utils.Clean Mininet System ${tools_system}
205 ${ovs_opt} = BuiltIn.Set Variable
206 FOR ${index} IN @{index_list}
207 ${ovs_opt} = BuiltIn.Catenate ${ovs_opt} ${SPACE}tcp:${ODL_SYSTEM_${index}_IP}:${ovs_mgr_port}
208 BuiltIn.Log ${ovs_opt}
210 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl set-manager ${ovs_opt}
211 ${output} = BuiltIn.Wait Until Keyword Succeeds 5s 1s Verify OVS Reports Connected ${tools_system}
212 BuiltIn.Log ${output}
213 ${controller_index} = Collections.Get_From_List ${index_list} 0
214 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${controller_index}
215 ${ovsdb_uuid} = BuiltIn.Wait Until Keyword Succeeds
218 ... OVSDB.Get OVSDB UUID
219 ... controller_http_session=${session}
223 [Documentation] Returns the dpnid from the system at the given ip address using ovs-ofctl assuming br-int is present.
225 ${output} = Utils.Run Command On Remote System
227 ... sudo ovs-ofctl show -O Openflow13 ${INTEGRATION_BRIDGE} | head -1 | awk -F "dpid:" '{print $2}'
228 ${dpnid} = BuiltIn.Convert To Integer ${output} 16
233 [Documentation] Return the subnet from the system at the given ip address and interface
235 ${output} = Utils.Run Command On Remote System ${ip} /usr/sbin/ip addr show | grep ${ip} | cut -d' ' -f6
236 ${interface} = ipaddress.ip_interface ${output}
237 ${network} = BuiltIn.Set Variable ${interface.network.__str__()}
241 [Documentation] Returns the ethernet adapter name from the system at the given ip address using ip addr show.
243 ${adapter} = Utils.Run Command On Remote System
245 ... /usr/sbin/ip addr show | grep ${ip} | cut -d " " -f 11
246 BuiltIn.Log ${adapter}
250 [Documentation] Returns the default gateway at the given ip address using route command.
252 ${gateway} = Utils.Run Command On Remote System
254 ... /usr/sbin/route -n | grep '^0.0.0.0' | cut -d " " -f 10
255 BuiltIn.Log ${gateway}
259 [Documentation] Get the port number for the given sub-port id
260 [Arguments] ${subportid} ${ip_addr}
261 ${command} = Set Variable
262 ... sudo ovs-ofctl -O OpenFlow13 show ${INTEGRATION_BRIDGE} | grep ${subportid} | awk '{print$1}'
263 BuiltIn.Log sudo ovs-ofctl -O OpenFlow13 show ${INTEGRATION_BRIDGE} | grep ${subportid} | awk '{print$1}'
264 ${output} = Utils.Run Command On Remote System ${ip_addr} ${command}
265 ${port_number} = BuiltIn.Should Match Regexp ${output} [0-9]+
266 RETURN ${port_number}
269 [Documentation] Get the Metadata for a given port
270 [Arguments] ${ip_addr} ${port}
271 ${cmd} = Set Variable
272 ... sudo ovs-ofctl dump-flows -O Openflow13 ${INTEGRATION_BRIDGE} | grep table=0 | grep in_port=${port}
273 ${output} = Utils.Run Command On Remote System ${ip_addr} ${cmd}
274 @{list_any_matches} = String.Get_Regexp_Matches ${output} metadata:(\\w{12}) 1
275 ${metadata} = Builtin.Convert To String @{list_any_matches}
276 ${output} = String.Get Substring ${metadata} 2
279 Log Config And Operational Topology
280 [Documentation] For debugging purposes, this will log both config and operational topo data stores
281 ${resp} = RequestsLibrary.Get Request session ${RFC8040_CONFIG_TOPO_API}
282 OVSDB.Log Request ${resp.text}
283 ${resp} = RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_TOPO_API}
284 OVSDB.Log Request ${resp.text}
286 Config and Operational Topology Should Be Empty
287 [Documentation] This will check that only the expected output is there for both operational and config
288 ... topology data stores. Empty probably means that only ovsdb:1 is there.
289 ${config_resp} = RequestsLibrary.Get Request session ${RFC8040_CONFIG_TOPO_API}
290 ${operational_resp} = RequestsLibrary.Get Request session ${RFC8040_OPERATIONAL_TOPO_API}
291 BuiltIn.Should Contain ${config_resp.text} {"topology-id":"ovsdb:1"}
292 BuiltIn.Should Contain ${operational_resp.text} {"topology-id":"ovsdb:1"}
294 Modify Multi Port Body
295 [Documentation] Updates two port names for the given ${bridge} in config store
296 [Arguments] ${ovs_1_port_name} ${ovs_2_port_name} ${bridge}
297 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/bug_7414/create_multiple_ports.json
298 ${ovs_1_ovsdb_uuid} = Get OVSDB UUID ${TOOLS_SYSTEM_IP}
299 ${ovs_2_ovsdb_uuid} = Get OVSDB UUID ${TOOLS_SYSTEM_2_IP}
300 ${body} = Replace String ${body} OVS_1_UUID ${ovs_1_ovsdb_uuid}
301 ${body} = Replace String ${body} OVS_2_UUID ${ovs_2_ovsdb_uuid}
302 ${body} = Replace String ${body} OVS_1_BRIDGE_NAME ${bridge}
303 ${body} = Replace String ${body} OVS_2_BRIDGE_NAME ${bridge}
304 ${body} = Replace String ${body} OVS_1_IP ${TOOLS_SYSTEM_IP}
305 ${body} = Replace String ${body} OVS_2_IP ${TOOLS_SYSTEM_2_IP}
306 ${body} = Replace String ${body} OVS_1_PORT_NAME ${ovs_1_port_name}
307 ${body} = Replace String ${body} OVS_2_PORT_NAME ${ovs_2_port_name}
308 ${uri} = Builtin.Set Variable ${RFC8040_TOPO_API}
309 BuiltIn.Log URI is ${uri}
310 BuiltIn.Log data: ${body}
311 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
312 OVSDB.Log Request ${resp.text}
313 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
318 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_qos.json
319 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_HOST1_API}/ovsdb:qos-entries=${qos}
320 ${body} = Replace String ${body} QOS-1 ${qos}
321 BuiltIn.Log URI is ${uri}
322 BuiltIn.Log data: ${body}
323 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
324 OVSDB.Log Request ${resp.text}
325 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
329 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_qoslinkedqueue.json
330 ${body} = Replace String ${body} QUEUE-1 ${queue}
331 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_HOST1_API}/ovsdb:queues=${queue}
332 BuiltIn.Log URI is ${uri}
333 BuiltIn.Log data: ${body}
334 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
335 OVSDB.Log Request ${resp.text}
336 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
340 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/update_existingqos.json
341 ${uri} = BuiltIn.Set Variable ${RFC8040_SOUTHBOUND_NODE_HOST1_API}/ovsdb:qos-entries=${QOS}
342 BuiltIn.Log URL is ${uri}
343 BuiltIn.Log data: ${body}
344 ${resp} = RequestsLibrary.Put Request session ${uri} data=${body}
345 OVSDB.Log Request ${resp.text}
346 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
348 Create Qos Linked Queue
349 ${body} = OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/bug_7160/create_qoslinkedqueue.json
350 ${resp} = RequestsLibrary.Put Request session ${RFC8040_SOUTHBOUND_NODE_HOST1_API} data=${body}
351 OVSDB.Log Request ${resp.text}
352 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
355 [Documentation] Add higher levels of OVS logging
356 [Arguments] ${conn_id}
357 SSHLibrary.Switch Connection ${conn_id}
358 @{modules} = BuiltIn.Create List
362 ... ofp_actions:file:dbg
363 ... ofp_errors:file:dbg
364 ... ofp_msgs:file:dbg
365 ... ovsdb_error:file:dbg
369 FOR ${module} IN @{modules}
370 Utils.Write Commands Until Expected Prompt
371 ... sudo ovs-appctl --target ovs-vswitchd vlog/set ${module}
372 ... ${DEFAULT_LINUX_PROMPT_STRICT}
374 Utils.Write Commands Until Expected Prompt
375 ... sudo ovs-appctl --target ovs-vswitchd vlog/list
376 ... ${DEFAULT_LINUX_PROMPT_STRICT}
379 [Documentation] Reset the OVS logging
380 [Arguments] ${conn_id}
381 SSHLibrary.Switch Connection ${conn_id}
382 ${output} = Utils.Write Commands Until Expected Prompt
383 ... sudo ovs-appctl --target ovs-vswitchd vlog/set :file:info
384 ... ${DEFAULT_LINUX_PROMPT_STRICT}
387 SetupUtils.Setup_Utils_For_Setup_And_Teardown
388 KarafKeywords.Open Controller Karaf Console On Background
389 RequestsLibrary.Create Session
391 ... http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
393 ... headers=${HEADERS}
394 OVSDB.Log Config And Operational Topology
397 [Documentation] Cleans up test environment, close existing sessions.
398 [Arguments] ${uris}=@{EMPTY}
399 OVSDB.Clean OVSDB Test Environment ${TOOLS_SYSTEM_IP}
400 FOR ${uri} IN @{uris}
401 RequestsLibrary.Delete Request session ${uri}
403 ${resp} = RequestsLibrary.Get Request session ${RFC8040_CONFIG_TOPO_API}
404 OVSDB.Log Config And Operational Topology
405 RequestsLibrary.Delete All Sessions
407 Get DumpFlows And Ovsconfig
408 [Documentation] Get the OvsConfig and Flow entries from OVS
409 [Arguments] ${conn_id} ${bridge}
410 SSHLibrary.Switch Connection ${conn_id}
411 Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
412 Write Commands Until Expected Prompt sudo ovs-vsctl list Open_vSwitch ${DEFAULT_LINUX_PROMPT_STRICT}
413 Write Commands Until Expected Prompt
414 ... sudo ovs-ofctl show ${bridge} -OOpenFlow13
415 ... ${DEFAULT_LINUX_PROMPT_STRICT}
416 Write Commands Until Expected Prompt
417 ... sudo ovs-ofctl dump-flows ${bridge} -OOpenFlow13
418 ... ${DEFAULT_LINUX_PROMPT_STRICT}
419 Write Commands Until Expected Prompt
420 ... sudo ovs-ofctl dump-groups ${bridge} -OOpenFlow13
421 ... ${DEFAULT_LINUX_PROMPT_STRICT}
422 Write Commands Until Expected Prompt
423 ... sudo ovs-ofctl dump-group-stats ${bridge} -OOpenFlow13
424 ... ${DEFAULT_LINUX_PROMPT_STRICT}
425 Write Commands Until Expected Prompt sudo ovs-vsctl list interface ${DEFAULT_LINUX_PROMPT_STRICT}
428 [Documentation] start the OVS node.
429 [Arguments] ${ovs_ip}
430 ${output} = Utils.Run Command On Mininet ${ovs_ip} sudo /usr/share/openvswitch/scripts/ovs-ctl start
431 BuiltIn.Log ${output}
434 [Documentation] Stop the OVS node.
435 [Arguments] ${ovs_ip}
436 ${output} = Utils.Run Command On Mininet ${ovs_ip} sudo /usr/share/openvswitch/scripts/ovs-ctl stop
437 BuiltIn.Log ${output}
440 [Documentation] This keyword returns first bridge name and UUID from list of bridges.
441 ${result} = SSHLibrary.Execute Command sudo ovs-vsctl show
442 ${uuid} = String.Get Line ${result} 0
443 ${line} ${bridge_name} = Builtin.Should Match Regexp ${result} Bridge ([\\w-]+)
444 RETURN ${uuid} ${bridge_name}
446 Delete OVS Controller
447 [Documentation] Delete controller from OVS
448 [Arguments] ${ovs_ip} ${bridge}=${INTEGRATION_BRIDGE}
449 ${del_ctr} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl del-controller ${bridge}
450 BuiltIn.Log ${del_ctr}
453 [Documentation] Delete manager from OVS
454 [Arguments] ${ovs_ip}
455 ${del_mgr} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl del-manager
456 BuiltIn.Log ${del_mgr}
458 Delete Groups On Bridge
459 [Documentation] Delete OVS groups from ${br}
460 [Arguments] ${ovs_ip} ${br}=${INTEGRATION_BRIDGE}
461 ${del_grp} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-ofctl -O Openflow13 del-groups ${br}
462 BuiltIn.Log ${del_grp}
464 Get Ports From Bridge By Type
465 [Documentation] Get ${type} ports for a bridge ${br} on node ${ovs_ip}.
466 [Arguments] ${ovs_ip} ${br} ${type}
467 ${ports} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl list-ports ${br} | grep "${type}"
468 ${ports_list} = String.Split to lines ${ports}
471 Delete Ports On Bridge By Type
472 [Documentation] List all ports of ${br} and delete ${type} ports
473 [Arguments] ${ovs_ip} ${br} ${type}
474 ${ports_present} = Get Ports From Bridge By Type ${ovs_ip} ${br} ${type}
475 FOR ${port} IN @{ports_present}
476 ${del-ports} = Utils.Run Command On Remote System ${ovs_ip} sudo ovs-vsctl del-port ${br} ${port}
477 BuiltIn.Log ${del-ports}
479 ${ports_present_after_delete} = Get Ports From Bridge By Type ${ovs_ip} ${br} ${type}
480 BuiltIn.Log ${ports_present_after_delete}
482 Get Tunnel Id And Packet Count
483 [Documentation] Get tunnel id and packet count from specified table id
484 ... Using regex get the n_packet and the tunnel_id from the table flow.
485 [Arguments] ${conn_id} ${table_id} ${tun_id} ${mac}=""
486 ${tun_id} = BuiltIn.Convert To Hex ${tun_id} prefix=0x lowercase=yes
487 IF "${table_id}" == "${INTERNAL_TUNNEL_TABLE}"
488 ${cmd} = BuiltIn.Set Variable
489 ... sudo ovs-ofctl dump-flows br-int -OOpenFlow13 | grep table=${table_id} | grep ${mac} | grep tun_id=${tun_id} | grep goto_table:${ELAN_DMACTABLE}
491 ${cmd} = BuiltIn.Set Variable
492 ... sudo ovs-ofctl dump-flows br-int -OOpenFlow13 | grep table=${table_id} | grep ${mac}
494 SSHLibrary.Switch Connection ${conn_id}
495 ${output} = Utils.Write Commands Until Expected Prompt ${cmd} ${DEFAULT_LINUX_PROMPT_STRICT}
496 @{list} = Split to lines ${output}
497 ${output} = Set Variable ${list}[0]
498 ${output} = String.Get Regexp Matches
500 ... n_packets=([0-9]+),.*set_field:(0x[0-9a-z]+)|n_packets=([0-9]+),.*tun_id=(0x[0-9a-z]+)
505 ${output} = BuiltIn.Set Variable ${output}[0]
506 ${output} = Convert To List ${output}
507 IF "${table_id}" == "${ELAN_DMACTABLE}"
508 ${packet_count} ${tunnel_id} = BuiltIn.Set Variable ${output}[0] ${output}[1]
509 ELSE IF "${table_id}" == "${INTERNAL_TUNNEL_TABLE}"
510 ${packet_count} ${tunnel_id} = BuiltIn.Set Variable ${output}[2] ${output}[3]
511 ELSE IF "${table_id}" == "${L3_TABLE}"
512 ${packet_count} ${tunnel_id} = BuiltIn.Set Variable ${output}[0] ${output}[1]
514 ${packet_count} ${tunnel_id} = Set Variable ${None} ${None}
516 ${tunnel_id} = Convert To Integer ${tunnel_id} 16
517 RETURN ${tunnel_id} ${packet_count}
519 Verify Dump Flows For Specific Table
520 [Documentation] To Verify flows are present for the corresponding table Number
521 [Arguments] ${compute_ip} ${table_num} ${flag} ${additional_args}=${EMPTY} @{matching_paras}
522 ${flow_output} = Utils.Run Command On Remote System
524 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${INTEGRATION_BRIDGE}|grep table=${table_num} ${additional_args}
526 FOR ${matching_str} IN @{matching_paras}
528 BuiltIn.Should Contain ${flow_output} ${matching_str}
530 BuiltIn.Should Not Contain ${flow_output} ${matching_str}
534 Verify Vni Segmentation Id and Tunnel Id
535 [Documentation] Get tunnel id and packet count from specified table id and destination port mac address
536 [Arguments] ${port1} ${port2} ${net1} ${net2} ${vm1_ip} ${vm2_ip}
538 ${port_mac1} = OpenStackOperations.Get Port Mac ${port1}
539 ${port_mac2} = OpenStackOperations.Get Port Mac ${port2}
540 ${segmentation_id1} = OpenStackOperations.Get Network Segmentation Id ${net1}
541 ${segmentation_id2} = OpenStackOperations.Get Network Segmentation Id ${net2}
542 ${egress_tun_id} ${before_count_egress_port1} = OVSDB.Get Tunnel Id And Packet Count
543 ... ${OS_CMP1_CONN_ID}
545 ... tun_id=${segmentation_id2}
547 BuiltIn.Should Be Equal As Numbers ${segmentation_id2} ${egress_tun_id}
548 ${egress_tun_id} ${before_count_egress_port2} = OVSDB.Get Tunnel Id And Packet Count
549 ... ${OS_CMP2_CONN_ID}
551 ... tun_id=${segmentation_id1}
553 BuiltIn.Should Be Equal As Numbers ${segmentation_id1} ${egress_tun_id}
554 ${ingress_tun_id} ${before_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 BuiltIn.Should Be Equal As Numbers ${segmentation_id1} ${ingress_tun_id}
559 ${ingress_tun_id} ${before_count_ingress_port2} = OVSDB.Get Tunnel Id And Packet Count
560 ... ${OS_CMP2_CONN_ID}
561 ... ${INTERNAL_TUNNEL_TABLE}
562 ... tun_id=${segmentation_id2}
563 BuiltIn.Should Be Equal As Numbers ${segmentation_id2} ${ingress_tun_id}
565 ${ping_cmd} = BuiltIn.Set Variable ping -c ${DEFAULT_PING_COUNT} ${vm2_ip}
567 ${ping_cmd} = BuiltIn.Set Variable ping6 -c ${DEFAULT_PING_COUNT} ${vm2_ip}
569 ${output} = OpenStackOperations.Execute Command on VM Instance ${net1} ${vm1_ip} ${ping_cmd}
570 BuiltIn.Should Contain ${output} 64 bytes
571 BuiltIn.Wait Until Keyword Succeeds
574 ... OVSDB.Verify Vni Packet Count After Traffic
575 ... ${before_count_egress_port1}
576 ... ${before_count_egress_port2}
577 ... ${before_count_ingress_port1}
578 ... ${before_count_ingress_port2}
579 ... ${segmentation_id1}
580 ... ${segmentation_id2}
584 Verify Vni Packet Count After Traffic
585 [Documentation] Verify the packet count after the traffic sent
586 [Arguments] ${before_count_egress_port1} ${before_count_egress_port2} ${before_count_ingress_port1} ${before_count_ingress_port2} ${segmentation_id1} ${segmentation_id2}
587 ... ${port_mac1} ${port_mac2}
588 ${tun_id} ${after_count_egress_port2} = OVSDB.Get Tunnel Id And Packet Count
589 ... ${OS_CMP2_CONN_ID}
591 ... tun_id=${segmentation_id1}
593 ${tun_id} ${after_count_ingress_port2} = OVSDB.Get Tunnel Id And Packet Count
594 ... ${OS_CMP2_CONN_ID}
595 ... ${INTERNAL_TUNNEL_TABLE}
596 ... tun_id=${segmentation_id2}
597 ${tun_id} ${after_count_egress_port1} = OVSDB.Get Tunnel Id And Packet Count
598 ... ${OS_CMP1_CONN_ID}
600 ... tun_id=${segmentation_id2}
602 ${tun_id} ${after_count_ingress_port1} = OVSDB.Get Tunnel Id And Packet Count
603 ... ${OS_CMP1_CONN_ID}
604 ... ${INTERNAL_TUNNEL_TABLE}
605 ... tun_id=${segmentation_id1}
606 ${diff_count_egress_port1} = BuiltIn.Evaluate ${after_count_egress_port1} - ${before_count_egress_port1}
607 ${diff_count_ingress_port1} = BuiltIn.Evaluate ${after_count_ingress_port1} - ${before_count_ingress_port1}
608 ${diff_count_egress_port2} = BuiltIn.Evaluate ${after_count_egress_port2} - ${before_count_egress_port2}
609 ${diff_count_ingress_port2} = BuiltIn.Evaluate ${after_count_ingress_port2} - ${before_count_ingress_port2}
610 BuiltIn.Should Be True ${diff_count_egress_port1} >= ${DEFAULT_PING_COUNT}
611 BuiltIn.Should Be True ${diff_count_ingress_port1} >= ${DEFAULT_PING_COUNT}
612 BuiltIn.Should Be True ${diff_count_egress_port2} >= ${DEFAULT_PING_COUNT}
613 BuiltIn.Should Be True ${diff_count_ingress_port2} >= ${DEFAULT_PING_COUNT}
615 Get Flow Entries On Node
616 [Documentation] Return flow entries on the given Node.
617 [Arguments] ${conn_id} ${switch}=${INTEGRATION_BRIDGE}
618 SSHLibrary.Switch Connection ${conn_id}
619 ${output} = Utils.Write Commands Until Expected Prompt
620 ... sudo ovs-ofctl -O OpenFlow13 dump-flows ${switch}
621 ... ${DEFAULT_LINUX_PROMPT_STRICT}
622 BuiltIn.Log ${output}
626 [Documentation] Verify ovsdb state for the given DPN
627 [Arguments] ${dpn_ip} ${state}=ACTIVE
628 ${output} = Utils.Run Command On Remote System And Log
630 ... sudo ovsdb-client dump -f list Open_vSwitch Controller | grep state
631 BuiltIn.Log ${output}
632 BuiltIn.Should Contain ${output} state=${state}
634 Verify Flows Are Present On Node
635 [Documentation] Verify Flows Are Present On The Given Node
636 [Arguments] ${conn_id} ${match}
637 ${output} = OVSDB.Get Flow Entries On Node ${conn_id}
638 BuiltIn.Should Contain ${output} ${match}