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