2 Documentation Cluster Ovsdb library. So far this library is only to be used by Ovsdb cluster test as it is very specific for this test.
3 Library RequestsLibrary
4 Resource ClusterKeywords.robot
5 Resource MininetKeywords.robot
8 Variables ../variables/Variables.py
11 Check Ovsdb Shards Status
12 [Arguments] ${controller_index_list}
13 [Documentation] Check Status for all shards in Ovsdb application.
14 ${topo_conf_leader} ${topo_conf_followers_list} Get Cluster Shard Status ${controller_index_list} config topology
15 ${topo_oper_leader} ${topo_oper_followers_list} Get Cluster Shard Status ${controller_index_list} operational topology
16 ${owner_oper_leader} ${owner_oper_followers_list} Get Cluster Shard Status ${controller_index_list} operational entity-ownership
17 Log config topology Leader is ${topo_conf_leader} and followers are ${topo_conf_followers_list}
18 Log operational topology Leader is ${topo_oper_leader} and followers are ${topo_oper_followers_list}
19 Log operational entity-ownership Leader is ${owner_oper_leader} and followers are ${owner_oper_followers_list}
21 Check Ovsdb Shards Status After Cluster Event
22 [Arguments] ${controller_index_list}
23 [Documentation] Check Shard Status after some cluster event.
24 Wait Until Keyword Succeeds 90s 1s Check Ovsdb Shards Status ${controller_index_list}
26 Get Ovsdb Entity Owner Status For One Device
27 [Arguments] ${controller_index_list}
28 [Documentation] Check Entity Owner Status and identify owner and candidate.
29 ${owner} ${candidates_list} Wait Until Keyword Succeeds 20s 1s Get Cluster Entity Owner For Ovsdb ${controller_index_list}
31 [Return] ${owner} ${candidates_list}
33 Get Cluster Entity Owner For Ovsdb
34 [Arguments] ${controller_index_list} ${device_type} ${device}
35 [Documentation] Checks Entity Owner status for a ${device} and returns owner index and list of candidates from a ${controller_index_list}.
36 ... ${device_type} is openflow, ovsdb, etc...
37 ${length}= Get Length ${controller_index_list}
38 ${candidates_list}= Create List
39 ${data}= Get Data From URI controller@{controller_index_list}[0] /restconf/operational/entity-owners:entity-owners
41 ${data}= Replace String ${data} /network-topology:network-topology/network-topology:topology[network-topology:topology-id=' ${EMPTY}
42 # the UUID will not always be the same so need to use regexp to remove this string
43 ${data}= Replace String Using Regexp ${data} \/network-topology:node\\[network-topology:node-id='ovsdb://uuid/........-....-....-....-............ ${EMPTY}
45 ${clear_data}= Replace String ${data} '] ${EMPTY}
47 ${json}= To Json ${clear_data}
48 ${entity_type_list}= Get From Dictionary &{json}[entity-owners] entity-type
49 ${entity_type_index}= Get Index From List Of Dictionaries ${entity_type_list} type ${device_type}
50 Should Not Be Equal ${entity_type_index} -1 No Entity Owner found for ${device_type}
51 ${entity_list}= Get From Dictionary @{entity_type_list}[${entity_type_index}] entity
52 ${entity_index}= Get Index From List Of Dictionaries ${entity_list} id ${device}
53 Should Not Be Equal ${entity_index} -1 Device ${device} not found in Entity Owner ${device_type}
54 ${entity_owner}= Get From Dictionary @{entity_list}[${entity_index}] owner
55 Should Not Be Empty ${entity_owner} No owner found for ${device}
56 ${owner}= Replace String ${entity_owner} member- ${EMPTY}
57 ${owner}= Convert To Integer ${owner}
58 List Should Contain Value ${controller_index_list} ${owner} Owner ${owner} not exisiting in ${controller_index_list}
59 ${entity_candidates_list}= Get From Dictionary @{entity_list}[${entity_index}] candidate
60 ${list_length}= Get Length ${entity_candidates_list}
61 : FOR ${entity_candidate} IN @{entity_candidates_list}
62 \ ${candidate}= Replace String &{entity_candidate}[name] member- ${EMPTY}
63 \ ${candidate}= Convert To Integer ${candidate}
64 \ Append To List ${candidates_list} ${candidate}
65 List Should Contain Sublist ${candidates_list} ${controller_index_list} Candidates are missing in ${candidates_list}
66 Remove Values From List ${candidates_list} ${owner}
67 [Return] ${owner} ${candidates_list}
69 Create Bridge And Verify
70 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
71 [Documentation] Create bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
72 # need to get UUID which should be the same on all controllers in cluster, so asking controller1
73 ${ovsdb_uuid}= Get OVSDB UUID controller_http_session=controller${controller_index}
74 Set Suite Variable ${ovsdb_uuid}
75 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/ovsdb/create_bridge_3node.json
76 ${body} Replace String ${body} ovsdb://127.0.0.1:61644 ovsdb://uuid/${ovsdb_uuid}
77 ${body} Replace String ${body} tcp:controller1:6633 tcp:${ODL_SYSTEM_1_IP}:6640
78 ${body} Replace String ${body} tcp:controller2:6633 tcp:${ODL_SYSTEM_2_IP}:6640
79 ${body} Replace String ${body} tcp:controller3:6633 tcp:${ODL_SYSTEM_3_IP}:6640
80 ${body} Replace String ${body} 127.0.0.1 ${TOOLS_SYSTEM_IP}
81 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
83 ${body} Replace String ${body} br01 ${BRIDGE}
84 ${body} Replace String ${body} 61644 ${OVSDB_PORT}
86 ${TOOLS_SYSTEM_IP1} Replace String ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_IP} "${TOOLS_SYSTEM_IP}"
87 ${dictionary}= Create Dictionary ${TOOLS_SYSTEM_IP1}=1 ${OVSDBPORT}=4 ${BRIDGE}=1
88 Wait Until Keyword Succeeds 20s 1s Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}
90 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
92 Create Bridge Manually And Verify
93 [Arguments] ${controller_index_list} ${controller_index}
94 [Documentation] Create bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
95 Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-vsctl add-br br-s1
96 ${dictionary_operational}= Create Dictionary br-s1=5
97 ${dictionary_config}= Create Dictionary br-s1=0
98 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_config} ${CONFIG_TOPO_API}
99 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_operational} ${OPERATIONAL_TOPO_API}
101 Delete Bridge Manually And Verify
102 [Arguments] ${controller_index_list} ${controller_index}
103 [Documentation] Delete bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
104 Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-vsctl del-br br-s1
105 ${dictionary}= Create Dictionary br-s1=0
106 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
108 Delete Bridge Via Rest Call And Verify
109 [Arguments] ${controller_index_list} ${controller_index}
110 [Documentation] Delete bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
111 # need to get UUID which should be the same on all controllers in cluster, so asking controller1
112 ${ovsdb_uuid}= Get OVSDB UUID controller_http_session=controller${controller_index}
113 ${dictionary}= Create Dictionary ${BRIDGE}=0
114 Wait Until Keyword Succeeds 20s 1s Delete And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}
115 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
117 Create Port Via Controller
118 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
119 [Documentation] This will add port/interface to the config datastore
120 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_port_3node.json
121 ${body} Replace String ${sample} 192.168.1.10 ${TOOLS_SYSTEM_IP}
123 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
125 Log URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
126 ${port_dictionary}= Create Dictionary ${BRIDGE}=7 vx2=3
127 Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/ ${body}
128 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${port_dictionary} ${OPERATIONAL_TOPO_API}
130 Modify the destination IP of Port
131 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
132 [Documentation] This will modify the dst ip of existing port
133 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_port_3node.json
134 ${body} Replace String ${sample} 192.168.1.10 10.0.0.19
135 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
136 Log URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
138 Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/ ${body}
140 Delete Port And Verify
141 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
142 [Documentation] Delete port in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
143 ${dictionary}= Create Dictionary vx2=0
144 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
145 Delete And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
146 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
148 Add Port To The Manual Bridge And Verify
149 [Arguments] ${controller_index_list} ${controller_index}
150 [Documentation] Add Port in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
151 Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-vsctl add-port br-s1 vx1 -- set Interface vx1 type=vxlan
152 ${dictionary_operational}= Create Dictionary vx1=2
153 ${dictionary_config}= Create Dictionary vx1=0
154 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_config} ${CONFIG_TOPO_API}
155 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_operational} ${OPERATIONAL_TOPO_API}
157 Get Operational Topology with modified Port
158 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
159 [Documentation] This request will fetch the operational topology after the Port is added to the bridge
160 ${port_dictionary_before_fail} Create Dictionary br01=7 vx2=3 10.0.0.19=1
161 ${port_dictionary_after_fail} Create Dictionary br02=7 vx2=3 10.0.0.19=1
162 ${port_dictionary}= Set Variable If "${status}"=="AfterFail" ${port_dictionary_after_fail} ${port_dictionary_before_fail}
163 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${port_dictionary} ${OPERATIONAL_TOPO_API}
165 Verify Bridge in Restarted Node
166 [Arguments] ${controller_index_list} ${status}=${NONE}
167 [Documentation] Verify Bridge in Restarted node, which is created when the node is down.
168 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateRecover" br04 br02
169 ${dictionary} Create Dictionary ${BRIDGE}=6
170 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
172 Verify Port in Restarted Node
173 [Arguments] ${controller_index_list} ${status}=${NONE}
174 [Documentation] Verify Port in Restarted node, which is created when the node is down.
175 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateRecover" br04 br02
176 ${dictionary} Create Dictionary ${BRIDGE}=6 vx2=3
177 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
179 Create Bridge In Candidate
180 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
181 [Documentation] Create bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
182 # need to get UUID which should be the same on all controllers in cluster, so asking controller1
183 ${ovsdb_uuid}= Get OVSDB UUID controller_http_session=controller${controller_index}
184 Set Suite Variable ${ovsdb_uuid}
185 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/ovsdb/create_bridge_3node.json
186 ${body} Replace String ${body} ovsdb://127.0.0.1:61644 ovsdb://uuid/${ovsdb_uuid}
187 ${body} Replace String ${body} tcp:controller1:6633 tcp:${ODL_SYSTEM_1_IP}:6640
188 ${body} Replace String ${body} tcp:controller2:6633 tcp:${ODL_SYSTEM_2_IP}:6640
189 ${body} Replace String ${body} tcp:controller3:6633 tcp:${ODL_SYSTEM_3_IP}:6640
190 ${body} Replace String ${body} 127.0.0.1 ${MININET}
191 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateFail" br04 br03
193 ${body} Replace String ${body} br01 ${BRIDGE}
194 ${body} Replace String ${body} 61644 ${OVSDB_PORT}
196 ${TOOLS_SYSTEM_IP1} Replace String ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_IP} "${TOOLS_SYSTEM_IP}"
197 ${dictionary}= Create Dictionary ${TOOLS_SYSTEM_IP1}=1 ${OVSDBPORT}=4 ${BRIDGE}=1
198 Wait Until Keyword Succeeds 20s 1s Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}
200 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
202 Create Port Vxlan in Candidate
203 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
204 [Documentation] This will add port/interface to the config datastore
205 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_port_3node.json
206 ${body} Replace String ${sample} 192.168.1.10 ${TOOLS_SYSTEM_IP}
208 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateFail" br04 br03
210 Log URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
211 ${port_dictionary}= Create Dictionary ${BRIDGE}=7 vx2=3
212 Put And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/ ${body}
213 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${port_dictionary} ${OPERATIONAL_TOPO_API}
215 Delete Bridge in Candidate
216 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
217 [Documentation] Delete bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
218 # need to get UUID which should be the same on all controllers in cluster, so asking controller1
219 ${ovsdb_uuid}= Get OVSDB UUID controller_http_session=controller${controller_index}
220 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateFail" br04 br03
221 ${dictionary}= Create Dictionary ${BRIDGE}=0
222 Wait Until Keyword Succeeds 20s 1s Delete And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}
223 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
225 Delete Port In Candidate
226 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
227 [Documentation] Delete port in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
228 ${dictionary}= Create Dictionary vx2=0
229 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateFail" br04 br03
230 Delete And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
231 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
233 Configure Exit OVSDB Connection
234 [Arguments] ${controller_index_list} ${controller_index}
235 [Documentation] Cleans up test environment, close existing sessions.
236 Clean OVSDB Test Environment ${TOOLS_SYSTEM_IP}
237 ${dictionary}= Create Dictionary ovsdb://uuid=0
238 Delete And Check At URI In Cluster ${controller_index_list} ${controller_index} ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}
239 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}