DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation The main interface for interacting with APP-C. It handles low level stuff like managing the http request library and APP-C required fields |
| 3 | Library RequestsLibrary |
| 4 | Library UUID |
| 5 | Library OperatingSystem |
| 6 | Library StringTemplater |
| 7 | Resource 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 |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 14 | ${APPC_ENDPOINT} ${GLOBAL_APPC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_APPC_IP_ADDR}:${GLOBAL_APPC_SERVER_PORT} |
| 15 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 16 | |
| 17 | *** Keywords *** |
| 18 | Run APPC Health Check |
| 19 | [Documentation] Runs an APPC healthcheck |
| 20 | ${resp}= Run APPC Post Request ${APPC_INDEX PATH}${APPC_HEALTHCHECK_OPERATION_PATH} ${None} |
| 21 | Should Be Equal As Strings ${resp.status_code} 200 |
| 22 | Should Be Equal As Strings ${resp.json()['output']['response-code']} 200 |
| 23 | |
| 24 | Run APPC Post Request |
| 25 | [Documentation] Runs an APPC post request |
| 26 | [Arguments] ${data_path} ${data} ${content}=json |
| 27 | ${auth}= Create List ${GLOBAL_APPC_USERNAME} ${GLOBAL_APPC_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 28 | Log Creating session ${APPC_ENDPOINT} |
| 29 | ${session}= Create Session appc ${APPC_ENDPOINT} auth=${auth} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 30 | ${uuid}= Generate UUID |
| 31 | ${headers}= Create Dictionary Accept=application/${content} Content-Type=application/${content} X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 32 | ${resp}= Post Request appc ${data_path} data=${data} headers=${headers} |
| 33 | Log Received response from appc ${resp.text} |
| 34 | [Return] ${resp} |
| 35 | |
| 36 | Run APPC Put Request |
| 37 | [Documentation] Runs an APPC post request |
| 38 | [Arguments] ${data_path} ${data} ${content}=xml |
| 39 | ${auth}= Create List ${GLOBAL_APPC_USERNAME} ${GLOBAL_APPC_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 40 | Log Creating session ${APPC_ENDPOINT} |
| 41 | ${session}= Create Session appc ${APPC_ENDPOINT} auth=${auth} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 42 | ${uuid}= Generate UUID |
| 43 | ${headers}= Create Dictionary Accept=application/${content} Content-Type=application/${content} X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 44 | ${resp}= Put Request appc ${data_path} data=${data} headers=${headers} |
| 45 | Log Received response from appc ${resp.text} |
| 46 | [Return] ${resp} |
| 47 | |
| 48 | Create Mount Point In APPC |
| 49 | [Documentation] Go tell APPC about the PGN we just spun up... |
| 50 | [Arguments] ${nodeid} ${host} ${port}=${GLOBAL_PGN_PORT} ${username}=admin ${password}=admin |
| 51 | ${dict}= Create Dictionary nodeid=${nodeid} host=${host} port=${port} username=${username} password=${password} |
| 52 | ${template}= OperatingSystem.Get File ${APPC_MOUNT_XML} |
| 53 | ${data}= Template String ${template} ${dict} |
| 54 | ${resp}= Run APPC Put Request ${APPC_INDEX PATH}${APPC_CREATE_MOUNTPOINT_PATH}${nodeid} ${data} |
| 55 | Should Be Equal As Strings ${resp.status_code} 200 |
| 56 | [Return] ${resp} |