2 Documentation Keywords wrapping controller's odl-mdsal-lowlevel yang model rpcs.
4 ... Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
6 ... This program and the accompanying materials are made available under the
7 ... terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ... and is available at http://www.eclipse.org/legal/epl-v10.html
11 Resource ${CURDIR}/ClusterManagement.robot
12 Resource ${CURDIR}/TemplatedRequests.robot
16 ${LOWLEVEL_RPC_DIR} ${CURDIR}/../variables/mdsal/lowlevelrpc
17 ${BECOME_PREFIX_LEADER_DIR} ${LOWLEVEL_RPC_DIR}/become_prefix_leader
18 ${CHECK_PUBLISH_NOTIFICATIONS_DIR} ${LOWLEVEL_RPC_DIR}/check_publish_notifications
19 ${CREATE_PREFIX_SHARD_DIR} ${LOWLEVEL_RPC_DIR}/create_prefix_shard
20 ${GET_CONSTANT_DIR} ${LOWLEVEL_RPC_DIR}/get_constant
21 ${GET_CONTEXTED_CONSTANT_DIR} ${LOWLEVEL_RPC_DIR}/get_contexted_constant
22 ${GET_SINGLETON_CONSTANT_DIR} ${LOWLEVEL_RPC_DIR}/get_singleton_constant
23 ${PRODUCE_TRANSACTIONS_DIR} ${LOWLEVEL_RPC_DIR}/produce_transactions
24 ${REGISTER_BOUND_CONSTANT_DIR} ${LOWLEVEL_RPC_DIR}/register_bound_constant
25 ${REGISTER_CONSTANT_DIR} ${LOWLEVEL_RPC_DIR}/register_constant
26 ${REGISTER_FLAPPING_SINGLETON_DIR} ${LOWLEVEL_RPC_DIR}/register_flapping_singleton
27 ${REGISTER_SINGLETON_CONSTANT_DIR} ${LOWLEVEL_RPC_DIR}/register_singleton_constant
28 ${REMOVE_PREFIX_SHARD_DIR} ${LOWLEVEL_RPC_DIR}/remove_prefix_shard
29 ${SHUTDOWN_SHARD_REPLICA_DIR} ${LOWLEVEL_RPC_DIR}/shutdown_shard_replica
30 ${SHUTDOWN_PREFIX_SHARD_REPLICA_DIR} ${LOWLEVEL_RPC_DIR}/shutdown_prefix_shard_replica
31 ${START_PUBLISH_NOTIFICATIONS_DIR} ${LOWLEVEL_RPC_DIR}/start_publish_notifications
32 ${SUBSCRIBE_DDTL_DIR} ${LOWLEVEL_RPC_DIR}/subscribe_ddtl
33 ${SUBSCRIBE_DTCL_DIR} ${LOWLEVEL_RPC_DIR}/subscribe_dtcl
34 ${SUBSCRIBE_YNL_DIR} ${LOWLEVEL_RPC_DIR}/subscribe_ynl
35 ${UNREGISTER_BOUND_CONSTANT_DIR} ${LOWLEVEL_RPC_DIR}/unregister_bound_constant
36 ${UNREGISTER_CONSTANT_DIR} ${LOWLEVEL_RPC_DIR}/unregister_constant
37 ${UNREGISTER_FLAPPING_SINGLETON_DIR} ${LOWLEVEL_RPC_DIR}/unregister_flapping_singleton
38 ${UNREGISTER_SINGLETON_CONSTANT_DIR} ${LOWLEVEL_RPC_DIR}/unregister_singleton_constant
39 ${UNSUBSCRIBE_DDTL_DIR} ${LOWLEVEL_RPC_DIR}/unsubscribe_ddtl
40 ${UNSUBSCRIBE_DTCL_DIR} ${LOWLEVEL_RPC_DIR}/unsubscribe_dtcl
41 ${UNSUBSCRIBE_YNL_DIR} ${LOWLEVEL_RPC_DIR}/unsubscribe_ynl
42 ${WRITE_TRANSACTIONS_DIR} ${LOWLEVEL_RPC_DIR}/write_transactions
47 [Documentation] Invoke get-constant rpc on the requested member and return the registered constant unless explicit status code is expected.
48 ... The ${explicit_status_codes} is a list of http status codes for which the rpc call is considered as passed and is used for calls with
49 ... expected failures on odl's side, such as calling the rpc on isolated node etc.
50 [Arguments] ${member_index} ${explicit_status_codes}=${NO_STATUS_CODES}
51 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
52 ${text} = TemplatedRequests.Post_As_Xml_Templated
53 ... ${GET_CONSTANT_DIR}
54 ... session=${session}
55 ... explicit_status_codes=${explicit_status_codes}
56 IF """${explicit_status_codes}""" != """${NO_STATUS_CODES}""" RETURN
57 ${xml} = XML.Parse_Xml ${text}
58 ${constant} = XML.Get_Element_Text ${xml} xpath=constant
61 Get_Contexted_Constant
62 [Documentation] Invoke get-contexted-constant rpc on the requested member and return the registered constant. The argument ${context} is only the string part
63 ... of the whole instance identifier. The ${explicit_status_codes} is a list of http status codes for which the rpc call is considered as passed and is used for
64 ... calls with expected failures on odl's side, such as calling the rpc on isolated node etc.
65 [Arguments] ${member_index} ${context}
66 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
67 &{mapping} = BuiltIn.Create_Dictionary CONTEXT=${context}
68 ${text} = TemplatedRequests.Post_As_Xml_Templated
69 ... ${GET_CONTEXTED_CONSTANT_DIR}
70 ... mapping=${mapping}
71 ... session=${session}
72 ${xml} = XML.Parse_Xml ${text}
73 ${constant} = XML.Get_Element_Text ${xml} xpath=constant
76 Get_Singleton_Constant
77 [Documentation] Invoke get-singleton-constant rpc on the requested member and return the registered constant unless explicit status code is
78 ... expected. The ${explicit_status_codes} is a list of http status codes for which the rpc call is considered as passed and is used for calls
79 ... with expected failures on odl's side, such as calling the rpc on isolated node etc.
80 [Arguments] ${member_index} ${explicit_status_codes}=${NO_STATUS_CODES}
81 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
82 ${text} = TemplatedRequests.Post_As_Xml_Templated
83 ... ${GET_SINGLETON_CONSTANT_DIR}
84 ... session=${session}
85 ... explicit_status_codes=${explicit_status_codes}
86 IF """${explicit_status_codes}""" != """${NO_STATUS_CODES}""" RETURN
87 ${xml} = XML.Parse_Xml ${text}
88 ${constant} = XML.Get_Element_Text ${xml} xpath=constant
92 [Documentation] Register the get-constant rpc on the requested node with given constant.
93 [Arguments] ${member_index} ${constant}
94 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
95 &{mapping} = BuiltIn.Create_Dictionary CONSTANT=${constant}
96 TemplatedRequests.Post_As_Xml_Templated ${REGISTER_CONSTANT_DIR} mapping=${mapping} session=${session}
99 [Documentation] Unregister the get-constant rpc on the given node.
100 [Arguments] ${member_index}
101 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
102 TemplatedRequests.Post_As_Xml_Templated ${UNREGISTER_CONSTANT_DIR} session=${session}
104 Register_Singleton_Constant
105 [Documentation] Register singleton application on given node by invoking register-singleton-constant rpc.
106 [Arguments] ${member_index} ${constant}
107 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
108 &{mapping} = BuiltIn.Create_Dictionary CONSTANT=${constant}
109 TemplatedRequests.Post_As_Xml_Templated
110 ... ${REGISTER_SINGLETON_CONSTANT_DIR}
111 ... mapping=${mapping}
112 ... session=${session}
114 Unregister_Singleton_Constant
115 [Documentation] Unregister singleton application on given node by invoking unregister-singleton-constant rpc.
116 [Arguments] ${member_index}
117 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
118 TemplatedRequests.Post_As_Xml_Templated ${UNREGISTER_SINGLETON_CONSTANT_DIR} session=${session}
120 Register_Flapping_Singleton
121 [Documentation] Activate flapping application on given node by invoking register-flapping-singleton rpc.
122 [Arguments] ${member_index}
123 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
124 TemplatedRequests.Post_As_Xml_Templated ${REGISTER_FLAPPING_SINGLETON_DIR} session=${session}
126 Unregister_Flapping_Singleton
127 [Documentation] Deactivate flapping singleton application by invoking unregister-flapping-singleton rpc.
128 ... Return the successful re-registrations count.
129 [Arguments] ${member_index}
130 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
131 ${text} = TemplatedRequests.Post_As_Xml_Templated ${UNREGISTER_FLAPPING_SINGLETON_DIR} session=${session}
132 ${xml} = XML.Parse_Xml ${text}
133 ${count} = XML.Get_Element_Text ${xml} xpath=flap-count
137 [Documentation] Create transactions with given rate for given time for module-based shards.
138 [Arguments] ${member_index} ${identifier} ${seconds} ${trans_per_sec} ${chained_trans}=${True}
139 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
140 &{mapping} = BuiltIn.Create_Dictionary
142 ... DURATION=${seconds}
143 ... RATE=${trans_per_sec}
144 ... CHAINED_FLAG=${chained_trans}
145 TemplatedRequests.Post_As_Xml_Templated ${WRITE_TRANSACTIONS_DIR} mapping=${mapping} session=${session}
148 [Documentation] Create transactions with given rate for given time for prefix-based shards.
149 [Arguments] ${member_index} ${seconds} ${trans_per_sec} ${isolated_trans}=${True}
150 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
151 &{mapping} = BuiltIn.Create_Dictionary
152 ... SECONDS=${seconds}
153 ... TPS=${trans_per_sec}
154 ... ISOLATED_TRANSACTIONS=${chained_trans}
155 TemplatedRequests.Post_As_Xml_Templated ${PRODUCE_TRANSACTIONS_DIR} mapping=${mapping} session=${session}
158 [Documentation] Create prefix based shard. ${replicas} is a list of cluster node indexes, taken e.g. from ClusterManagement.List_Indices_Or_All.
159 [Arguments] ${member_index} ${prefix} ${replicas}
160 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
161 ${replicas_str} = BuiltIn.Set_Variable ${EMPTY}
162 FOR ${replica} IN @{replicas}
163 ${replicas_str} = BuiltIn.Set_Variable ${replicas_str}<replicas>member-${replica}</replicas>
165 &{mapping} = BuiltIn.Create_Dictionary PREFIX=${prefix} REPLICAS=${replicas_str}
166 ${text} = TemplatedRequests.Post_As_Xml_Templated
167 ... ${CREATE_PREFIX_SHARD_DIR}
168 ... mapping=${mapping}
169 ... session=${session}
172 [Documentation] Remove prefix based shard.
173 [Arguments] ${member_index} ${prefix}
174 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
175 &{mapping} = BuiltIn.Create_Dictionary PREFIX=${prefix}
176 ${text} = TemplatedRequests.Post_As_Xml_Templated
177 ... ${REMOVE_PREFIX_SHARD_DIR}
178 ... mapping=${mapping}
179 ... session=${session}
182 [Documentation] Given node ask to become a shard leader.
183 [Arguments] ${member_index} ${shard_name}
184 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
185 &{mapping} = BuiltIn.Create_Dictionary SHARD_NAME=${shard_name} ID=prefix-0
186 ${text} = TemplatedRequests.Post_As_Xml_Templated
187 ... ${BECOME_PREFIX_LEADER_DIR}
188 ... mapping=${mapping}
189 ... session=${session}
192 [Documentation] Subscribe a listener for data changes. Invoke subscribe-dtcl rpc.
193 [Arguments] ${member_index}
194 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
195 TemplatedRequests.Post_As_Xml_Templated ${SUBSCRIBE_DTCL_DIR} session=${session}
198 [Documentation] Invoke unsubscribe-dtcl rpc, return copy-matches field as boolean.
199 [Arguments] ${member_index}
200 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
201 ${text} = TemplatedRequests.Post_As_Xml_Templated ${UNSUBSCRIBE_DTCL_DIR} session=${session}
202 BuiltIn.Run_Keyword_And_Return MdsalLowLevel__Parse_Matches ${text}
204 Unsubscribe_Dtcl_No_Tx
205 [Documentation] Unsubscribe a listener from the data changes. Expect success no notifications received. Return boolean status.
206 [Arguments] ${member_index}
207 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
208 ${text} = TemplatedRequests.Post_As_Xml_Templated
209 ... ${UNSUBSCRIBE_DTCL_DIR}
210 ... session=${session}
211 ... additional_allowed_status_codes=${INTERNAL_SERVER_ERROR}
212 BuiltIn.Run_Keyword_And_Return MdsalLowLevel__Parse_Maybe_No_Tx ${text}
215 [Documentation] Subscribe DOMDataTreeListener to listen for the data changes.
216 [Arguments] ${member_index}
217 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
218 TemplatedRequests.Post_As_Xml_Templated ${SUBSCRIBE_DDTL_DIR} session=${session}
221 [Documentation] Invoke unsubscribe-ddtl rpc, return copy-matches field as boolean.
222 [Arguments] ${member_index}
223 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
224 ${text} = TemplatedRequests.Post_As_Xml_Templated ${UNSUBSCRIBE_DDTL_DIR} session=${session}
225 BuiltIn.Run_Keyword_And_Return MdsalLowLevel__Parse_Matches ${text}
227 Unsubscribe_Ddtl_No_Tx
228 [Documentation] Unsubscribe a listener from the data changes. Expect success no notifications received. Return boolean status.
229 [Arguments] ${member_index}
230 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
231 ${text} = TemplatedRequests.Post_As_Xml_Templated
232 ... ${UNSUBSCRIBE_DDTL_DIR}
233 ... session=${session}
234 ... additional_allowed_status_codes=${INTERNAL_SERVER_ERROR}
235 BuiltIn.Run_Keyword_And_Return MdsalLowLevel__Parse_Maybe_No_Tx ${text}
237 MdsalLowLevel__Parse_Matches
238 [Documentation] Interpret the \${text} as XML response to an unsubscribe call and return copy-matches as boolean.
240 ${xml} = XML.Parse_Xml ${text}
241 ${matches} = XML.Get_Element_Text ${xml} xpath=copy-matches
242 ${matches} = BuiltIn.Convert_To_Boolean ${matches}
245 MdsalLowLevel__Parse_Maybe_No_Tx
246 [Documentation] Attempt to parse the \${text} as successful unsubscribe. If that fails, extract the error message and expect no notifications.
248 ${status} ${message} = BuiltIn.Run_Keyword_And_Ignore_Error MdsalLowLevel__Parse_Matches ${text}
249 IF "${status}" == "PASS" RETURN ${message}
250 ${xml} = XML.Parse_Xml ${text}
251 ${message} = XML.Get_Element_Text ${xml} xpath=error/error-message
252 ${status} ${message} = BuiltIn.Run_Keyword_And_Ignore_Error
253 ... BuiltIn.Should_Contain
255 ... listener has not received
256 IF "${status}" == "PASS" RETURN ${TRUE}
259 Start_Publish_Notifications
260 [Documentation] Start publishing notifications by invoking publish-notifications rpc.
261 [Arguments] ${member_index} ${gid} ${seconds} ${notif_per_sec}
262 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
263 &{mapping} = BuiltIn.Create_Dictionary ID=${gid} DURATION=${seconds} RATE=${notif_per_sec}
264 TemplatedRequests.Post_As_Xml_Templated
265 ... ${START_PUBLISH_NOTIFICATIONS_DIR}
266 ... mapping=${mapping}
267 ... session=${session}
269 Check_Publish_Notifications
270 [Documentation] Publishing notifications check by invoking check-publish-notifications rpc. Return publising process state details.
271 [Arguments] ${member_index} ${gid}
272 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
273 &{mapping} = BuiltIn.Create_Dictionary ID=${gid}
274 ${text} = TemplatedRequests.Post_As_Xml_Templated
275 ... ${CHECK_PUBLISH_NOTIFICATIONS_DIR}
276 ... mapping=${mapping}
277 ... session=${session}
278 ${xml} = XML.Parse_Xml ${text}
279 ${active} = XML.Get_Element_Text ${xml} xpath=active
280 ${active} = BuiltIn.Convert_To_Boolean ${active}
281 ${status} ${publish_count} = BuiltIn.Run_Keyword_And_Ignore_Error
282 ... XML.Get_Element_Text
284 ... xpath=publish-count
285 IF """${status}""" == """FAIL""" and """${publish_count}""" != """No element matching 'publish-count' found."""
286 BuiltIn.Fail ${publish_count}
288 ${publish_count} = BuiltIn.Set_Variable_If """${status}""" == """FAIL""" ${EMPTY} ${publish_count}
289 ${status} ${last_error} = BuiltIn.Run_Keyword_And_Ignore_Error
290 ... XML.Get_Element_Text
293 IF """${status}""" == """FAIL""" and """${last_error}""" != """No element matching 'last-error' found."""
294 BuiltIn.Fail ${last_error}
296 ${last_error} = BuiltIn.Set_Variable_If """${status}""" == """FAIL""" ${EMPTY} ${last_error}
297 RETURN ${active} ${publish_count} ${last_error}
300 [Documentation] Subscribe listener for the notifications with identifier ${gid}.
301 [Arguments] ${member_index} ${gid}
302 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
303 &{mapping} = BuiltIn.Create_Dictionary ID=${gid}
304 TemplatedRequests.Post_As_Xml_Templated ${SUBSCRIBE_YNL_DIR} mapping=${mapping} session=${session}
307 [Documentation] Unsubscribe listener for the ${gid} identifier. Return statistics of the publishing process.
308 [Arguments] ${member_index} ${gid}
309 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
310 &{mapping} = BuiltIn.Create_Dictionary ID=${gid}
311 ${text} = TemplatedRequests.Post_As_Xml_Templated
312 ... ${UNSUBSCRIBE_YNL_DIR}
313 ... mapping=${mapping}
314 ... session=${session}
315 ${xml} = XML.Parse_Xml ${text}
316 ${all_not} = XML.Get_Element_Text ${xml} xpath=all-not
317 ${id_not} = XML.Get_Element_Text ${xml} xpath=id-not
318 ${err_not} = XML.Get_Element_Text ${xml} xpath=err-not
319 ${local_number} = XML.Get_Element_Text ${xml} xpath=local-number
320 RETURN ${all_not} ${id_not} ${err_not} ${local_number}
322 Register_Bound_Constant
323 [Documentation] Invoke register-bound-constant rpc and register get-contexted-constant rpc. The argument ${context} is only the string part
324 ... of the whole instance identifier.
325 [Arguments] ${member_index} ${context} ${constant}
326 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
327 &{mapping} = BuiltIn.Create_Dictionary CONTEXT=${context} CONSTANT=${constant}
328 ${text} = TemplatedRequests.Post_As_Xml_Templated
329 ... ${REGISTER_BOUND_CONSTANT_DIR}
330 ... mapping=${mapping}
331 ... session=${session}
333 Unregister_Bound_Constant
334 [Documentation] Invoke unregister-bound-constant rpc and unregister get-contexted-constant rpc. The argument ${context} is only the string part
335 ... of the whole instance identifier.
336 [Arguments] ${member_index} ${context}
337 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
338 &{mapping} = BuiltIn.Create_Dictionary CONTEXT=${context}
339 TemplatedRequests.Post_As_Xml_Templated
340 ... ${UNREGISTER_BOUND_CONSTANT_DIR}
341 ... mapping=${mapping}
342 ... session=${session}
344 Shutdown_Shard_Replica
345 [Documentation] Invoke shutdown-shard-replica rpc.
346 [Arguments] ${member_index} ${shard_name}
347 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
348 &{mapping} = BuiltIn.Create_Dictionary SHARD_NAME=${shard_name}
349 TemplatedRequests.Post_As_Xml_Templated
350 ... ${SHUTDOWN_SHARD_REPLICA_DIR}
351 ... mapping=${mapping}
352 ... session=${session}
354 Shutdown_Prefix_Shard_Replica
355 [Documentation] Invoke shutdown-prefix-shard-replica rpc.
356 [Arguments] ${member_index} ${shard_prefix}
357 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${member_index}
358 &{mapping} = BuiltIn.Create_Dictionary PREFIX=${shard_prefix}
359 TemplatedRequests.Post_As_Xml_Templated
360 ... ${SHUTDOWN_PREFIX_SHARD_REPLICA_DIR}
361 ... mapping=${mapping}
362 ... session=${session}