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 \ Run Keyword If '${candidate}' != '${owner}' Append To List ${candidates_list} ${candidate}
65 [Return] ${owner} ${candidates_list}
67 Create Bridge And Verify
68 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
69 [Documentation] Create bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
70 # need to get UUID which should be the same on all controllers in cluster, so asking controller1
71 ${ovsdb_uuid}= Get OVSDB UUID controller_http_session=controller${controller_index}
72 Set Suite Variable ${ovsdb_uuid}
73 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/ovsdb/create_bridge_3node.json
74 ${body} Replace String ${body} ovsdb://127.0.0.1:61644 ovsdb://uuid/${ovsdb_uuid}
75 ${body} Replace String ${body} tcp:controller1:6633 tcp:${ODL_SYSTEM_1_IP}:6640
76 ${body} Replace String ${body} tcp:controller2:6633 tcp:${ODL_SYSTEM_2_IP}:6640
77 ${body} Replace String ${body} tcp:controller3:6633 tcp:${ODL_SYSTEM_3_IP}:6640
78 ${body} Replace String ${body} 127.0.0.1 ${TOOLS_SYSTEM_IP}
79 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
81 ${body} Replace String ${body} br01 ${BRIDGE}
82 ${body} Replace String ${body} 61644 ${OVSDB_PORT}
84 ${TOOLS_SYSTEM_IP1} Replace String ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_IP} "${TOOLS_SYSTEM_IP}"
85 ${dictionary}= Create Dictionary ${TOOLS_SYSTEM_IP1}=1 ${OVSDBPORT}=4 ${BRIDGE}=1
86 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}
88 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}
90 Create Bridge Manually And Verify
91 [Arguments] ${controller_index_list} ${controller_index}
92 [Documentation] Create bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
93 Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-vsctl add-br br-s1
94 ${dictionary_operational}= Create Dictionary br-s1=5
95 ${dictionary_config}= Create Dictionary br-s1=0
96 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_config} ${CONFIG_TOPO_API}
97 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_operational} ${OPERATIONAL_TOPO_API}
99 Delete Bridge Manually And Verify
100 [Arguments] ${controller_index_list} ${controller_index}
101 [Documentation] Delete bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
102 Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-vsctl del-br br-s1
103 ${dictionary}= Create Dictionary br-s1=0
104 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
106 Delete Bridge Via Rest Call And Verify
107 [Arguments] ${controller_index_list} ${controller_index}
108 [Documentation] Delete bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
109 # need to get UUID which should be the same on all controllers in cluster, so asking controller1
110 ${ovsdb_uuid}= Get OVSDB UUID controller_http_session=controller${controller_index}
111 ${dictionary}= Create Dictionary ${BRIDGE}=0
112 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}
113 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}
115 Create Port Via Controller
116 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
117 [Documentation] This will add port/interface to the config datastore
118 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_port_3node.json
119 ${body} Replace String ${sample} 192.168.1.10 ${TOOLS_SYSTEM_IP}
121 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
123 Log URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
124 ${port_dictionary}= Create Dictionary ${BRIDGE}=7 vx2=3
125 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}
126 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${port_dictionary} ${OPERATIONAL_TOPO_API}
128 Modify the destination IP of Port
129 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
130 [Documentation] This will modify the dst ip of existing port
131 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_port_3node.json
132 ${body} Replace String ${sample} 192.168.1.10 10.0.0.19
133 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
134 Log URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
136 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}
138 Delete Port And Verify
139 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
140 [Documentation] Delete port in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
141 ${dictionary}= Create Dictionary vx2=0
142 ${BRIDGE}= Set Variable If "${status}"=="AfterFail" br02 br01
143 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/
144 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
146 Add Port To The Manual Bridge And Verify
147 [Arguments] ${controller_index_list} ${controller_index}
148 [Documentation] Add Port in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
149 Run Command On Mininet ${TOOLS_SYSTEM_IP} sudo ovs-vsctl add-port br-s1 vx1 -- set Interface vx1 type=vxlan
150 ${dictionary_operational}= Create Dictionary vx1=2
151 ${dictionary_config}= Create Dictionary vx1=0
152 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_config} ${CONFIG_TOPO_API}
153 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary_operational} ${OPERATIONAL_TOPO_API}
155 Get Operational Topology with modified Port
156 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
157 [Documentation] This request will fetch the operational topology after the Port is added to the bridge
158 ${port_dictionary_before_fail} Create Dictionary br01=7 vx2=3 10.0.0.19=1
159 ${port_dictionary_after_fail} Create Dictionary br02=7 vx2=3 10.0.0.19=1
160 ${port_dictionary}= Set Variable If "${status}"=="AfterFail" ${port_dictionary_after_fail} ${port_dictionary_before_fail}
161 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${port_dictionary} ${OPERATIONAL_TOPO_API}
163 Verify Bridge in Restarted Node
164 [Arguments] ${controller_index_list} ${status}=${NONE}
165 [Documentation] Verify Bridge in Restarted node, which is created when the node is down.
166 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateRecover" br04 br02
167 ${dictionary} Create Dictionary ${BRIDGE}=6
168 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
170 Verify Port in Restarted Node
171 [Arguments] ${controller_index_list} ${status}=${NONE}
172 [Documentation] Verify Port in Restarted node, which is created when the node is down.
173 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateRecover" br04 br02
174 ${dictionary} Create Dictionary ${BRIDGE}=6 vx2=3
175 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
177 Create Bridge In Candidate
178 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
179 [Documentation] Create bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
180 # need to get UUID which should be the same on all controllers in cluster, so asking controller1
181 ${ovsdb_uuid}= Get OVSDB UUID controller_http_session=controller${controller_index}
182 Set Suite Variable ${ovsdb_uuid}
183 ${body}= OperatingSystem.Get File ${CURDIR}/../variables/ovsdb/create_bridge_3node.json
184 ${body} Replace String ${body} ovsdb://127.0.0.1:61644 ovsdb://uuid/${ovsdb_uuid}
185 ${body} Replace String ${body} tcp:controller1:6633 tcp:${ODL_SYSTEM_1_IP}:6640
186 ${body} Replace String ${body} tcp:controller2:6633 tcp:${ODL_SYSTEM_2_IP}:6640
187 ${body} Replace String ${body} tcp:controller3:6633 tcp:${ODL_SYSTEM_3_IP}:6640
188 ${body} Replace String ${body} 127.0.0.1 ${MININET}
189 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateFail" br04 br03
191 ${body} Replace String ${body} br01 ${BRIDGE}
192 ${body} Replace String ${body} 61644 ${OVSDB_PORT}
194 ${TOOLS_SYSTEM_IP1} Replace String ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_IP} "${TOOLS_SYSTEM_IP}"
195 ${dictionary}= Create Dictionary ${TOOLS_SYSTEM_IP1}=1 ${OVSDBPORT}=4 ${BRIDGE}=1
196 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}
198 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}
200 Create Port Vxlan in Candidate
201 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
202 [Documentation] This will add port/interface to the config datastore
203 ${sample} OperatingSystem.Get File ${OVSDB_CONFIG_DIR}/create_port_3node.json
204 ${body} Replace String ${sample} 192.168.1.10 ${TOOLS_SYSTEM_IP}
206 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateFail" br04 br03
208 Log URL is ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2Fuuid%2F${ovsdb_uuid}%2Fbridge%2F${BRIDGE}/termination-point/vx2/
209 ${port_dictionary}= Create Dictionary ${BRIDGE}=7 vx2=3
210 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}
211 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${port_dictionary} ${OPERATIONAL_TOPO_API}
213 Delete Bridge in Candidate
214 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
215 [Documentation] Delete bridge in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
216 # need to get UUID which should be the same on all controllers in cluster, so asking controller1
217 ${ovsdb_uuid}= Get OVSDB UUID controller_http_session=controller${controller_index}
218 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateFail" br04 br03
219 ${dictionary}= Create Dictionary ${BRIDGE}=0
220 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}
221 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}
223 Delete Port In Candidate
224 [Arguments] ${controller_index_list} ${controller_index} ${status}=${NONE}
225 [Documentation] Delete port in ${controller_index} and verify it gets applied in all instances in ${controller_index_list}.
226 ${dictionary}= Create Dictionary vx2=0
227 ${BRIDGE}= Set Variable If "${status}"=="AfterCandidateFail" br04 br03
228 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/
229 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}
231 Configure Exit OVSDB Connection
232 [Arguments] ${controller_index_list} ${controller_index}
233 [Documentation] Cleans up test environment, close existing sessions.
234 Clean OVSDB Test Environment ${TOOLS_SYSTEM_IP}
235 ${dictionary}= Create Dictionary ovsdb://uuid=0
236 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}
237 Wait Until Keyword Succeeds 5s 1s Check Item Occurrence At URI In Cluster ${controller_index_list} ${dictionary} ${OPERATIONAL_TOPO_API}