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 |
| 14 | |
| 15 | *** Keywords *** |
| 16 | Run 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 | |
| 22 | Run 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 | |
| 34 | Run 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 | |
| 46 | Create 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} |