2 Documentation Robot keyword library (Resource) for performing PCEP operations via restconf calls.
4 ... Copyright (c) 2015 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
9 Library RequestsLibrary
10 Library ${CURDIR}/norm_json.py
11 Variables ${CURDIR}/../variables/Variables.py
15 [Documentation] Creates Requests session to be used by subsequent keywords.
16 # Do not append slash at the end uf URL, Requests would add another, resulting in error.
17 Create_Session pcep_session http://${ODL_SYSTEM_IP}:${RESTCONFPORT}/restconf/operations headers=${HEADERS_XML} auth=${AUTH}
19 Teardown_Pcep_Operations
20 [Documentation] Teardown to pair with Setup (otherwise no-op).
21 Log TODO: The following line does not seem to be implemented by RequestsLibrary. Look for a workaround.
22 # Delete_Session pcep_session
24 Add_Xml_Lsp_Return_Json
25 [Arguments] ${xml_data}
26 [Documentation] Instantiate LSP according to XML data and return response (json) text.
28 ${response}= Operate_Xml_Lsp_Return_Json network-topology-pcep:add-lsp ${xml_data}
31 Update_Xml_Lsp_Return_Json
32 [Arguments] ${xml_data}
33 [Documentation] Update LSP according to XML data and return response (json) text.
35 ${response}= Operate_Xml_Lsp_Return_Json network-topology-pcep:update-lsp ${xml_data}
38 Remove_Xml_Lsp_Return_Json
39 [Arguments] ${xml_data}
40 [Documentation] Remove LSP according to XML data and return response (json) text.
42 ${response}= Operate_Xml_Lsp_Return_Json network-topology-pcep:remove-lsp ${xml_data}
45 Operate_Xml_Lsp_Return_Json
46 [Arguments] ${uri_part} ${xml_data}
47 [Documentation] Post XML data to given pcep-operations URI, check status_code is 200 and return response text (JSON).
48 ${response}= RequestsLibrary.Post Request pcep_session ${uri_part} data=${xml_data}
49 Should_Be_Equal_As_Strings ${response.status_code} 200
50 [Return] ${response.text}
54 [Documentation] Given text should be equal to successfull json response.
55 Should_Be_Equal_As_Strings ${text} {"output":{}}
58 [Arguments] ${actual_raw}
59 [Documentation] Given text should be equal to json response when device refuses tunnel removal.
60 ${expected_raw}= BuiltIn.Set_Variable {"output":{"error":[{"error-object":{"ignore":false,"processing-rule":false,"type":19,"value":9}}],"failure":"failed"}}
61 # TODO: Is that JSON worth referencing pcepuser variables from this library?
62 ${expected_normalized}= norm_json.normalize_json_text ${expected_raw}
63 ${actual_normalized}= norm_json.normalize_json_text ${actual_raw}
64 BuiltIn.Should_Be_Equal ${actual_normalized} ${expected_normalized}
65 # TODO: Would the diff approach be more useful?