5 Library RequestsLibrary
7 Resource ClusterManagement.robot
8 Resource ${CURDIR}/TemplatedRequests.robot
9 Variables ../variables/Variables.py
12 ${OVSDB_CONFIG_DIR} ../variables/ovsdb
13 ${SOUTHBOUND_CONFIG_API} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F
17 [Arguments] ${mininet_ip}
18 [Documentation] This will Initiate the connection to OVSDB node from controller
19 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/connect.json
20 ${sample1} Replace String ${sample} 127.0.0.1 ${mininet_ip}
21 ${body} Replace String ${sample1} 61644 ${OVSDB_PORT}
22 Log URL is ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}
24 ${resp} RequestsLibrary.Put Request session ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT} data=${body}
26 Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
28 Disconnect From Ovsdb Node
29 [Arguments] ${mininet_ip}
30 [Documentation] This request will disconnect the OVSDB node from the controller
31 ${resp} RequestsLibrary.Delete Request session ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}
32 Should Be Equal As Strings ${resp.status_code} 200
34 Add Bridge To Ovsdb Node
35 [Arguments] ${mininet_ip} ${bridge_num} ${datapath_id}
36 [Documentation] This will create a bridge and add it to the OVSDB node.
37 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_bridge.json
38 ${sample1} Replace String ${sample} tcp:127.0.0.1:6633 tcp:${ODL_SYSTEM_IP}:6633
39 ${sample2} Replace String ${sample1} 127.0.0.1 ${mininet_ip}
40 ${sample3} Replace String ${sample2} br01 ${bridge_num}
41 ${sample4} Replace String ${sample3} 61644 ${OVSDB_PORT}
42 ${body} Replace String ${sample4} 0000000000000001 ${datapath_id}
43 Log URL is ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}
45 ${resp} RequestsLibrary.Put Request session ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num} data=${body}
47 Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
49 Delete Bridge From Ovsdb Node
50 [Arguments] ${mininet_ip} ${bridge_num}
51 [Documentation] This request will delete the bridge node from the OVSDB
52 ${resp} RequestsLibrary.Delete Request session ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}
53 Should Be Equal As Strings ${resp.status_code} 200
56 [Arguments] ${mininet_ip} ${bridge_num} ${vxlan_port} ${remote_ip} ${custom_port}=create_port.json
57 [Documentation] This request will create vxlan port for vxlan tunnel and attach it to the specific bridge
58 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/${custom_port}
59 ${body} Replace String ${sample} 192.168.0.21 ${remote_ip}
60 Log URL is ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}/termination-point/${vxlan_port}/
62 ${resp} RequestsLibrary.Put Request session ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}/termination-point/${vxlan_port}/ data=${body}
64 Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
66 Verify OVS Reports Connected
67 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP}
68 [Documentation] Uses "vsctl show" to check for string "is_connected"
69 ${output}= Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl show
70 Should Contain ${output} is_connected
74 [Arguments] ${ovs_system_ip}=${TOOLS_SYSTEM_IP} ${controller_http_session}=session
75 [Documentation] Queries the topology in the operational datastore and searches for the node that has
76 ... the ${ovs_system_ip} argument as the "remote-ip". If found, the value returned will be the value of
77 ... node-id stripped of "ovsdb://uuid/". If not found, ${EMPTY} will be returned.
78 ${uuid}= Set Variable ${EMPTY}
79 ${resp}= RequestsLibrary.Get Request ${controller_http_session} ${OPERATIONAL_TOPO_API}/topology/ovsdb:1
81 Should Be Equal As Strings ${resp.status_code} 200
82 ${resp_json}= To Json ${resp.content}
83 ${topologies}= Get From Dictionary ${resp_json} topology
84 ${topology}= Get From List ${topologies} 0
85 ${node_list}= Get From Dictionary ${topology} node
87 # Since bridges are also listed as nodes, but will not have the extra "ovsdb:connection-info data,
88 # we need to use "Run Keyword And Ignore Error" below.
89 : FOR ${node} IN @{node_list}
90 \ ${node_id}= Get From Dictionary ${node} node-id
91 \ ${node_uuid}= Replace String ${node_id} ovsdb://uuid/ ${EMPTY}
92 \ ${status} ${connection_info} Run Keyword And Ignore Error Get From Dictionary ${node} ovsdb:connection-info
93 \ ${status} ${remote_ip} Run Keyword And Ignore Error Get From Dictionary ${connection_info} remote-ip
94 \ ${uuid}= Set Variable If '${remote_ip}' == '${ovs_system_ip}' ${node_uuid} ${uuid}
98 [Arguments] ${switch}=br-int
99 [Documentation] Used to log useful test debugs for OVSDB related system tests.
100 ${output}= Utils.Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-vsctl show
102 ${output}= Utils.Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-ofctl -O OpenFlow13 dump-flows ${switch} | cut -d',' -f3-
105 Clean OVSDB Test Environment
106 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP}
107 [Documentation] General Use Keyword attempting to sanitize test environment for OVSDB related
108 ... tests. Not every step will always be neccessary, but should not cause any problems for
109 ... any new ovsdb test suites.
110 Utils.Clean Mininet System ${tools_system}
111 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl del-manager
112 Utils.Run Command On Mininet ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl stop
113 Utils.Run Command On Mininet ${tools_system} sudo rm -rf /etc/openvswitch/conf.db
114 Utils.Run Command On Mininet ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl start
116 Set Controller In OVS Bridge
117 [Arguments] ${tools_system} ${bridge} ${controller_opt}
118 [Documentation] Sets controller for a given OVS ${bridge} using controller options in ${controller_opt}
119 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl del-controller ${bridge}
120 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl set-controller ${bridge} ${controller_opt}
122 Add Multiple Managers to OVS
123 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP} ${controller_index_list}=${EMPTY} ${ovs_mgr_port}=6640
124 [Documentation] Connect OVS to the list of controllers in the ${controller_index_list} or all if no list is provided.
125 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${controller_index_list}
126 Log Clear any existing mininet
127 Utils.Clean Mininet System ${tools_system}
128 ${ovs_opt}= Set Variable
129 : FOR ${index} IN @{index_list}
130 \ ${ovs_opt}= Catenate ${ovs_opt} ${SPACE}tcp:${ODL_SYSTEM_${index}_IP}:${ovs_mgr_port}
132 Log Configure OVS Managers in the OVS
133 Utils.Run Command On Mininet ${tools_system} sudo ovs-vsctl set-manager ${ovs_opt}
134 Log Check OVS configuration
135 ${output}= Wait Until Keyword Succeeds 5s 1s Verify OVS Reports Connected ${tools_system}
137 ${controller_index}= Collections.Get_From_List ${index_list} 0
138 ${session}= ClusterManagement.Resolve_Http_Session_For_Member member_index=${controller_index}
139 ${ovsdb_uuid}= Wait Until Keyword Succeeds 30s 2s Get OVSDB UUID controller_http_session=${session}
140 [Return] ${ovsdb_uuid}