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
10 ... TODO: Remove all old keywords, update pcepuser.robot accordingly
11 ... TODO: Add new KWs, update all pcep tests to use them.
13 Library RequestsLibrary
15 Resource ../variables/Variables.robot
16 Resource TemplatedRequests.robot
20 ${PCEP_VAR_FOLDER} ${CURDIR}/../variables/tcpmd5user
25 [Documentation] Creates Requests session to be used by subsequent keywords.
26 RequestsLibrary.Create_Session
27 ... alias=pcep_session
28 ... url=http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
29 ... headers=${HEADERS_XML}
32 Teardown_Pcep_Operations
33 [Documentation] Teardown to pair with Setup (otherwise no-op).
34 RequestsLibrary.Delete_All_Sessions
36 Add_Xml_Lsp_Return_Json
37 [Documentation] Instantiate LSP according to XML data and return response (json) text.
38 [Arguments] ${xml_data}
40 ${response}= Operate_Xml_Lsp_Return_Json network-topology-pcep:add-lsp ${xml_data}
43 Update_Xml_Lsp_Return_Json
44 [Documentation] Update LSP according to XML data and return response (json) text.
45 [Arguments] ${xml_data}
47 ${response}= Operate_Xml_Lsp_Return_Json network-topology-pcep:update-lsp ${xml_data}
50 Remove_Xml_Lsp_Return_Json
51 [Documentation] Remove LSP according to XML data and return response (json) text.
52 [Arguments] ${xml_data}
54 ${response}= Operate_Xml_Lsp_Return_Json network-topology-pcep:remove-lsp ${xml_data}
57 Operate_Xml_Lsp_Return_Json
58 [Documentation] Post XML data to given pcep-operations URI, check status_code is 200 and return response text (JSON).
59 [Arguments] ${uri_part} ${xml_data}
60 ${uri_path}= BuiltIn.Set_Variable /rests/operations/${uri_part}
61 ${response}= RequestsLibrary.POST On Session
62 ... alias=pcep_session
65 ... expected_status=any
67 Should Contain ${ALLOWED_STATUS_CODES} ${response.status_code}
68 RETURN ${response.text}
71 [Documentation] Given text should be equal to successfull json response.
73 Should_Be_Equal_As_Strings ${text} {"output":{}}
76 [Documentation] Given text should be equal to json response when device refuses tunnel removal.
77 [Arguments] ${actual_raw}
78 ${expected_raw}= BuiltIn.Set_Variable
79 ... {"network-topology-pcep:output":{"error":[{"error-object":{"ignore":false,"processing-rule":false,"type":19,"value":9}}],"failure":"failed"}}
80 # TODO: Is that JSON worth referencing pcepuser variables from this library?
81 ${expected_normalized}= norm_json.normalize_json_text ${expected_raw}
82 ${actual_normalized}= norm_json.normalize_json_text ${actual_raw}
83 BuiltIn.Should_Be_Equal ${actual_normalized} ${expected_normalized}
84 # TODO: Would the diff approach be more useful?
86 Pcep_Topology_Precondition
87 [Documentation] Compare current pcep-topology to empty one.
88 ... Timeout is long enough to see that pcep is ready.
89 [Arguments] ${session}
90 BuiltIn.Wait_Until_Keyword_Succeeds
93 ... TemplatedRequests.Get_As_Json_Templated
94 ... ${PCEP_VAR_FOLDER}/default_off
95 ... session=${session}