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:${CONTROLLER}: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}= 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
77 Should Be Equal As Strings ${resp.status_code} 200
78 ${resp_json}= To Json ${resp.content}
79 ${topologies}= Get From Dictionary ${resp_json} topology
80 ${topology}= Get From List ${topologies} 0
81 ${node_list}= Get From Dictionary ${topology} node
83 : FOR ${node} IN @{node_list}
84 \ ${node_id}= Get From Dictionary ${node} node-id
85 \ ${node_uuid}= Replace String ${node_id} ovsdb://uuid/ ${EMPTY}
86 \ # Since bridges are also listed as nodes, but will not have the extra "ovsdb:connection-info data, we need to
87 \ # use "Run Keyword And Ignore Error" below.
88 \ ${status} ${connection_info} Run Keyword And Ignore Error Get From Dictionary ${node} ovsdb:connection-info
89 \ ${status} ${remote_ip} Run Keyword And Ignore Error Get From Dictionary ${connection_info} remote-ip
90 \ ${uuid}= Set Variable If '${remote_ip}' == '${ovs_system_ip}' ${node_uuid} ${uuid}
94 [Arguments] ${switch}=br-int
95 [Documentation] Used to log useful test debugs for OVSDB related system tests.
96 ${output}= Run Command On Remote System ${TOOLS_SYSTEM_IP} sudo ovs-vsctl show
98 ${output}= Run Command On Remote System ${TOOLS_SYSTEM_IP} sudo ovs-ofctl -O OpenFlow13 dump-flows ${switch} | cut -d',' -f3-
101 Clean OVSDB Test Environment
102 [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP}
103 [Documentation] General Use Keyword attempting to sanitize test environment for OVSDB related
104 ... tests. Not every step will always be neccessary, but should not cause any problems for
105 ... any new ovsdb test suites.
106 Clean Mininet System ${tools_system}
107 Run Command On Remote System ${tools_system} sudo ovs-vsctl del-manager
108 Run Command On Remote System ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl stop
109 Run Command On Remote System ${tools_system} sudo rm -rf /etc/openvswitch/conf.db
110 Run Command On Remote System ${tools_system} sudo /usr/share/openvswitch/scripts/ovs-ctl start