blob: 2dbd979bf4aaa499336f4b5c80f9b7639bddc9f8 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The main interface for interacting with APP-C. It handles low level stuff like managing the http request library and APP-C required fields
3Library RequestsLibrary
4Library UUID
5Library OperatingSystem
6Library StringTemplater
7Resource global_properties.robot
8
9*** Variables ***
10${APPC_INDEX_PATH} /restconf
11${APPC_HEALTHCHECK_OPERATION_PATH} /operations/SLI-API:healthcheck
12${APPC_CREATE_MOUNTPOINT_PATH} /config/network-topology:network-topology/topology/topology-netconf/node/
13${APPC_MOUNT_XML} robot/assets/templates/appc/vnf_mount.template
14
15*** Keywords ***
16Run APPC Health Check
17 [Documentation] Runs an APPC healthcheck
18 ${resp}= Run APPC Post Request ${APPC_INDEX PATH}${APPC_HEALTHCHECK_OPERATION_PATH} ${None}
19 Should Be Equal As Strings ${resp.status_code} 200
20 Should Be Equal As Strings ${resp.json()['output']['response-code']} 200
21
22Run APPC Post Request
23 [Documentation] Runs an APPC post request
24 [Arguments] ${data_path} ${data} ${content}=json
25 ${auth}= Create List ${GLOBAL_APPC_USERNAME} ${GLOBAL_APPC_PASSWORD}
26 Log Creating session ${GLOBAL_APPC_SERVER}
27 ${session}= Create Session appc ${GLOBAL_APPC_SERVER} auth=${auth}
28 ${uuid}= Generate UUID
29 ${headers}= Create Dictionary Accept=application/${content} Content-Type=application/${content} X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
30 ${resp}= Post Request appc ${data_path} data=${data} headers=${headers}
31 Log Received response from appc ${resp.text}
32 [Return] ${resp}
33
34Run APPC Put Request
35 [Documentation] Runs an APPC post request
36 [Arguments] ${data_path} ${data} ${content}=xml
37 ${auth}= Create List ${GLOBAL_APPC_USERNAME} ${GLOBAL_APPC_PASSWORD}
38 Log Creating session ${GLOBAL_APPC_SERVER}
39 ${session}= Create Session appc ${GLOBAL_APPC_SERVER} auth=${auth}
40 ${uuid}= Generate UUID
41 ${headers}= Create Dictionary Accept=application/${content} Content-Type=application/${content} X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
42 ${resp}= Put Request appc ${data_path} data=${data} headers=${headers}
43 Log Received response from appc ${resp.text}
44 [Return] ${resp}
45
46Create Mount Point In APPC
47 [Documentation] Go tell APPC about the PGN we just spun up...
48 [Arguments] ${nodeid} ${host} ${port}=${GLOBAL_PGN_PORT} ${username}=admin ${password}=admin
49 ${dict}= Create Dictionary nodeid=${nodeid} host=${host} port=${port} username=${username} password=${password}
50 ${template}= OperatingSystem.Get File ${APPC_MOUNT_XML}
51 ${data}= Template String ${template} ${dict}
52 ${resp}= Run APPC Put Request ${APPC_INDEX PATH}${APPC_CREATE_MOUNTPOINT_PATH}${nodeid} ${data}
53 Should Be Equal As Strings ${resp.status_code} 200
54 [Return] ${resp}