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