5 Library RequestsLibrary
8 Resource ClusterManagement.robot
9 Resource ${CURDIR}/TemplatedRequests.robot
10 Variables ../variables/Variables.py
13 ${OVSDB_CONFIG_DIR} ../variables/ovsdb
14 ${SOUTHBOUND_CONFIG_API} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F
18 [Arguments] ${mininet_ip}
19 [Documentation] This will Initiate the connection to OVSDB node from controller
20 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/connect.json
21 ${sample1} Replace String ${sample} 127.0.0.1 ${mininet_ip}
22 ${body} Replace String ${sample1} 61644 ${OVSDB_PORT}
23 Log URL is ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}
25 ${resp} RequestsLibrary.Put Request session ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT} data=${body}
27 Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
29 Disconnect From Ovsdb Node
30 [Arguments] ${mininet_ip}
31 [Documentation] This request will disconnect the OVSDB node from the controller
32 ${resp} RequestsLibrary.Delete Request session ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}
33 Should Be Equal As Strings ${resp.status_code} 200
35 Add Bridge To Ovsdb Node
36 [Arguments] ${mininet_ip} ${bridge_num} ${datapath_id}
37 [Documentation] This will create a bridge and add it to the OVSDB node.
38 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_bridge.json
39 ${sample1} Replace String ${sample} tcp:127.0.0.1:6633 tcp:${ODL_SYSTEM_IP}:6633
40 ${sample2} Replace String ${sample1} 127.0.0.1 ${mininet_ip}
41 ${sample3} Replace String ${sample2} br01 ${bridge_num}
42 ${sample4} Replace String ${sample3} 61644 ${OVSDB_PORT}
43 ${body} Replace String ${sample4} 0000000000000001 ${datapath_id}
44 Log URL is ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}
46 ${resp} RequestsLibrary.Put Request session ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num} data=${body}
48 Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
50 Delete Bridge From Ovsdb Node
51 [Arguments] ${mininet_ip} ${bridge_num}
52 [Documentation] This request will delete the bridge node from the OVSDB
53 ${resp} RequestsLibrary.Delete Request session ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}
54 Should Be Equal As Strings ${resp.status_code} 200
57 [Arguments] ${mininet_ip} ${bridge_num} ${vxlan_port} ${remote_ip} ${custom_port}=create_port.json
58 [Documentation] This request will create vxlan port for vxlan tunnel and attach it to the specific bridge
59 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/${custom_port}
60 ${body} Replace String ${sample} 192.168.0.21 ${remote_ip}
61 Log URL is ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}/termination-point/${vxlan_port}/
63 ${resp} RequestsLibrary.Put Request session ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}/termination-point/${vxlan_port}/ data=${body}
65 Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
67 Verify OVS Reports Connected
68 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP}
69 [Documentation] Uses "vsctl show" to check for string "is_connected"
70 ${output}= Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl show
71 Should Contain ${output} is_connected
75 [Arguments] ${ovs_system_ip}=${TOOLS_SYSTEM_IP} ${controller_http_session}=session
76 [Documentation] Queries the topology in the operational datastore and searches for the node that has
77 ... the ${ovs_system_ip} argument as the "remote-ip". If found, the value returned will be the value of
78 ... node-id stripped of "ovsdb://uuid/". If not found, ${EMPTY} will be returned.
79 ${uuid}= Set Variable ${EMPTY}
80 ${resp}= RequestsLibrary.Get Request ${controller_http_session} ${OPERATIONAL_TOPO_API}/topology/ovsdb:1
82 Should Be Equal As Strings ${resp.status_code} 200
83 ${resp_json}= To Json ${resp.content}
84 ${topologies}= Get From Dictionary ${resp_json} topology
85 ${topology}= Get From List ${topologies} 0
86 ${node_list}= Get From Dictionary ${topology} node
88 # Since bridges are also listed as nodes, but will not have the extra "ovsdb:connection-info data,
89 # we need to use "Run Keyword And Ignore Error" below.
90 : FOR ${node} IN @{node_list}
91 \ ${node_id}= Get From Dictionary ${node} node-id
92 \ ${node_uuid}= Replace String ${node_id} ovsdb://uuid/ ${EMPTY}
93 \ ${status} ${connection_info} Run Keyword And Ignore Error Get From Dictionary ${node} ovsdb:connection-info
94 \ ${status} ${remote_ip} Run Keyword And Ignore Error Get From Dictionary ${connection_info} remote-ip
95 \ ${uuid}= Set Variable If '${remote_ip}' == '${ovs_system_ip}' ${node_uuid} ${uuid}
99 [Arguments] ${switch}=br-int
100 [Documentation] Used to log useful test debugs for OVSDB related system tests.
101 ${output}= Utils.Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-vsctl show
103 ${output}= Utils.Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-ofctl -O OpenFlow13 dump-flows ${switch} | cut -d',' -f3-
106 Clean OVSDB Test Environment
107 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP}
108 [Documentation] General Use Keyword attempting to sanitize test environment for OVSDB related
109 ... tests. Not every step will always be neccessary, but should not cause any problems for
110 ... any new ovsdb test suites.
111 Utils.Clean Mininet System ${tools_system}
112 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl del-manager
113 Utils.Run Command On Mininet ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl stop
114 Utils.Run Command On Mininet ${tools_system} sudo rm -rf /etc/openvswitch/conf.db
115 Utils.Run Command On Mininet ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl start
118 [Arguments] ${ovs_ip}
119 [Documentation] Restart the OVS node without cleaning the current configuration.
120 ${output} = Utils.Run Command On Mininet ${ovs_ip} sudo /usr/share/openvswitch/scripts/ovs-ctl stop
122 ${output} = Utils.Run Command On Mininet ${ovs_ip} sudo /usr/share/openvswitch/scripts/ovs-ctl start
125 Set Controller In OVS Bridge
126 [Arguments] ${tools_system} ${bridge} ${controller_opt}
127 [Documentation] Sets controller for a given OVS ${bridge} using controller options in ${controller_opt}
128 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl set-controller ${bridge} ${controller_opt}
130 Check OVS OpenFlow Connections
131 [Arguments] ${tools_system} ${of_connections}
132 [Documentation] Check OVS instance with IP ${tools_system} has ${of_connections} OpenFlow connections.
133 ${output}= Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl show
135 BuiltIn.Should Contain X Times ${output} is_connected ${of_connections}
137 Add Multiple Managers to OVS
138 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP} ${controller_index_list}=${EMPTY} ${ovs_mgr_port}=6640
139 [Documentation] Connect OVS to the list of controllers in the ${controller_index_list} or all if no list is provided.
140 ${index_list} = ClusterManagement.List Indices Or All given_list=${controller_index_list}
141 Log Clear any existing mininet
142 Utils.Clean Mininet System ${tools_system}
143 ${ovs_opt}= Set Variable
144 : FOR ${index} IN @{index_list}
145 \ ${ovs_opt}= Catenate ${ovs_opt} ${SPACE}tcp:${ODL_SYSTEM_${index}_IP}:${ovs_mgr_port}
147 Log Configure OVS Managers in the OVS
148 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl set-manager ${ovs_opt}
149 Log Check OVS configuration
150 ${output}= Wait Until Keyword Succeeds 5s 1s Verify OVS Reports Connected ${tools_system}
152 ${controller_index}= Collections.Get_From_List ${index_list} 0
153 ${session}= ClusterManagement.Resolve_Http_Session_For_Member member_index=${controller_index}
154 ${ovsdb_uuid}= Wait Until Keyword Succeeds 30s 2s Get OVSDB UUID controller_http_session=${session}
155 [Return] ${ovsdb_uuid}
159 [Documentation] Returns the dpnid from the system at the given ip address using ovs-ofctl assuming br-int is present.
160 ${output} = Run Command On Remote System ${ip} sudo ovs-ofctl show -O Openflow13 br-int | head -1 | awk -F "dpid:" '{print $2}'
161 ${dpnid} = Convert To Integer ${output} 16
167 [Documentation] Return the subnet from the system at the given ip address and interface
168 ${output} = Run Command On Remote System ${ip} /usr/sbin/ip addr show | grep ${ip} | cut -d' ' -f6
169 ${interface} = ipaddress.ip_interface ${output}
170 ${network}= Set Variable ${interface.network.__str__()}
175 [Documentation] Returns the ethernet adapter name from the system at the given ip address using ip addr show.
176 ${adapter} = Run Command On Remote System ${ip} /usr/sbin/ip addr show | grep ${ip} | cut -d " " -f 11
182 [Documentation] Returns the default gateway at the given ip address using route command.
183 ${gateway} = Run Command On Remote System ${ip} /usr/sbin/route -n | grep '^0.0.0.0' | cut -d " " -f 10