DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation The main interface for interacting with MSO. It handles low level stuff like managing the http request library and MSO required fields |
| 3 | Library RequestsLibrary |
| 4 | Library UUID |
| 5 | Library OperatingSystem |
| 6 | Library Collections |
| 7 | Resource global_properties.robot |
| 8 | Resource ../resources/json_templater.robot |
| 9 | *** Variables *** |
| 10 | ${MSO_HEALTH_CHECK_PATH} /ecomp/mso/infra/globalhealthcheck |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 11 | ${MSO_ENDPOINT} ${GLOBAL_MSO_SERVER_PROTOCOL}://${GLOBAL_INJECTED_MSO_IP_ADDR}:${GLOBAL_MSO_SERVER_PORT} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 12 | |
| 13 | *** Keywords *** |
| 14 | Run MSO Health Check |
| 15 | [Documentation] Runs an MSO global health check |
| 16 | ${auth}= Create List ${GLOBAL_MSO_USERNAME} ${GLOBAL_MSO_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 17 | ${session}= Create Session mso ${MSO_ENDPOINT} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 18 | ${uuid}= Generate UUID |
| 19 | ${headers}= Create Dictionary Accept=text/html Content-Type=text/html X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 20 | ${resp}= Get Request mso ${MSO_HEALTH_CHECK_PATH} headers=${headers} |
| 21 | Should Be Equal As Strings ${resp.status_code} 200 |
| 22 | |
| 23 | Run MSO Get Request |
| 24 | [Documentation] Runs an MSO get request |
| 25 | [Arguments] ${data_path} ${accept}=application/json |
| 26 | ${auth}= Create List ${GLOBAL_MSO_USERNAME} ${GLOBAL_MSO_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 27 | Log Creating session ${MSO_ENDPOINT} |
| 28 | ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 29 | ${uuid}= Generate UUID |
| 30 | ${headers}= Create Dictionary Accept=${accept} Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 31 | ${resp}= Get Request mso ${data_path} headers=${headers} |
| 32 | Log Received response from mso ${resp.text} |
| 33 | [Return] ${resp} |
| 34 | |
| 35 | Poll MSO Get Request |
| 36 | [Documentation] Runs an MSO get request until a certain status is received. valid values are COMPLETE |
| 37 | [Arguments] ${data_path} ${status} |
| 38 | ${auth}= Create List ${GLOBAL_MSO_USERNAME} ${GLOBAL_MSO_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 39 | Log Creating session ${MSO_ENDPOINT} |
| 40 | ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 41 | ${uuid}= Generate UUID |
| 42 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 43 | #do this until it is done |
| 44 | :FOR ${i} IN RANGE 20 |
| 45 | \ ${resp}= Get Request mso ${data_path} headers=${headers} |
| 46 | \ Should Not Contain ${resp.text} FAILED |
| 47 | \ Log ${resp.json()['request']['requestStatus']['requestState']} |
| 48 | \ ${exit_loop}= Evaluate "${resp.json()['request']['requestStatus']['requestState']}" == "${status}" |
| 49 | \ Exit For Loop If ${exit_loop} |
| 50 | \ Sleep 15s |
| 51 | Log Received response from mso ${resp.text} |
| 52 | [Return] ${resp} |
| 53 | |
Mor Dabastany | 186c358 | 2017-08-07 16:14:19 +0300 | [diff] [blame] | 54 | Run MSO Post request |
| 55 | [Documentation] Runs an MSO post request |
| 56 | [Arguments] ${data_path} ${data} |
| 57 | ${auth}= Create List ${GLOBAL_MSO_USERNAME} ${GLOBAL_MSO_PASSWORD} |
| 58 | Log Creating session ${MSO_ENDPOINT} |
| 59 | ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth} |
| 60 | ${uuid}= Generate UUID |
| 61 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 62 | ${resp}= Post Request mso ${data_path} data=${data} headers=${headers} |
Mor Dabastany | 262d9d4 | 2017-08-14 15:27:36 +0300 | [diff] [blame] | 63 | Log Received response from mso ${resp.text} |
Mor Dabastany | 186c358 | 2017-08-07 16:14:19 +0300 | [diff] [blame] | 64 | [Return] ${resp} |