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 |
Jerry Flood | 176d1da | 2017-10-02 10:38:30 -0400 | [diff] [blame] | 4 | Library UUID |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 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 |
Jerry Flood | 176d1da | 2017-10-02 10:38:30 -0400 | [diff] [blame] | 11 | ${MSO_ENDPOINT} ${GLOBAL_MSO_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SO_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 | |
Brian Freeman | ca5e32e | 2018-07-23 12:47:21 -0500 | [diff] [blame] | 23 | Run MSO Get ModelInvariantId |
| 24 | [Documentation] Runs an MSO Get ModelInvariantID for ClosedLoop Polieis |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 25 | [Arguments] ${service_model_name} ${vf_module_label}=NULL |
Brian Freeman | ca5e32e | 2018-07-23 12:47:21 -0500 | [diff] [blame] | 26 | ${param_dict}= Create Dictionary serviceModelName ${service_model_name} |
| 27 | ${param}= Evaluate urllib.urlencode(${param_dict}) urllib |
| 28 | ${data_path}= Catenate SEPARATOR= /ecomp/mso/catalog/v2/serviceVnfs? ${param} |
| 29 | ${resp}= Run MSO Get Request ${data_path} |
| 30 | Log ${resp.json()} |
Brian Freeman | d65e2aa | 2018-07-26 11:13:46 -0500 | [diff] [blame] | 31 | # ${resp.json()['serviceVnfs'][0]['vfModules'][0]['vfModuleLabel'] should be 'base_vpkg' |
| 32 | ${model_invariant_id}= Set Variable NULL |
| 33 | @{ITEMS}= Copy List ${resp.json()['serviceVnfs']} |
| 34 | :FOR ${ELEMENT} IN @{ITEMS} |
| 35 | \ Log ${ELEMENT['vfModules']} |
| 36 | \ ${model_invariant_id} Set Variable If ('${vf_module_label}' in '${ELEMENT['vfModules'][0]['vfModuleLabel']}') ${ELEMENT['modelInfo']['modelInvariantUuid']} NULL |
| 37 | \ Exit For Loop If '${model_invariant_id}' != 'NULL' |
| 38 | [Return] ${model_invariant_id} |
Brian Freeman | ca5e32e | 2018-07-23 12:47:21 -0500 | [diff] [blame] | 39 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 40 | Run MSO Get Request |
| 41 | [Documentation] Runs an MSO get request |
| 42 | [Arguments] ${data_path} ${accept}=application/json |
| 43 | ${auth}= Create List ${GLOBAL_MSO_USERNAME} ${GLOBAL_MSO_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 44 | Log Creating session ${MSO_ENDPOINT} |
| 45 | ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 46 | ${uuid}= Generate UUID |
| 47 | ${headers}= Create Dictionary Accept=${accept} Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 48 | ${resp}= Get Request mso ${data_path} headers=${headers} |
| 49 | Log Received response from mso ${resp.text} |
| 50 | [Return] ${resp} |
Jerry Flood | 176d1da | 2017-10-02 10:38:30 -0400 | [diff] [blame] | 51 | |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 52 | Poll MSO Get Request |
| 53 | [Documentation] Runs an MSO get request until a certain status is received. valid values are COMPLETE |
| 54 | [Arguments] ${data_path} ${status} |
| 55 | ${auth}= Create List ${GLOBAL_MSO_USERNAME} ${GLOBAL_MSO_PASSWORD} |
DR695H | bf5a3a3 | 2017-06-30 13:09:57 -0400 | [diff] [blame] | 56 | Log Creating session ${MSO_ENDPOINT} |
| 57 | ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 58 | ${uuid}= Generate UUID |
| 59 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 60 | #do this until it is done |
| 61 | :FOR ${i} IN RANGE 20 |
| 62 | \ ${resp}= Get Request mso ${data_path} headers=${headers} |
| 63 | \ Should Not Contain ${resp.text} FAILED |
Jerry Flood | 176d1da | 2017-10-02 10:38:30 -0400 | [diff] [blame] | 64 | \ Log ${resp.json()['request']['requestStatus']['requestState']} |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 65 | \ ${exit_loop}= Evaluate "${resp.json()['request']['requestStatus']['requestState']}" == "${status}" |
| 66 | \ Exit For Loop If ${exit_loop} |
| 67 | \ Sleep 15s |
| 68 | Log Received response from mso ${resp.text} |
| 69 | [Return] ${resp} |
| 70 | |
Mor Dabastany | 186c358 | 2017-08-07 16:14:19 +0300 | [diff] [blame] | 71 | Run MSO Post request |
| 72 | [Documentation] Runs an MSO post request |
| 73 | [Arguments] ${data_path} ${data} |
| 74 | ${auth}= Create List ${GLOBAL_MSO_USERNAME} ${GLOBAL_MSO_PASSWORD} |
| 75 | Log Creating session ${MSO_ENDPOINT} |
| 76 | ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth} |
| 77 | ${uuid}= Generate UUID |
| 78 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 79 | ${resp}= Post Request mso ${data_path} data=${data} headers=${headers} |
Mor Dabastany | 262d9d4 | 2017-08-14 15:27:36 +0300 | [diff] [blame] | 80 | Log Received response from mso ${resp.text} |
Mor Dabastany | 186c358 | 2017-08-07 16:14:19 +0300 | [diff] [blame] | 81 | [Return] ${resp} |
Tal Karbachinsky | c3bf551 | 2018-01-25 10:27:17 +0200 | [diff] [blame] | 82 | |
| 83 | Run MSO Delete request |
| 84 | [Documentation] Runs an MSO Delete request |
| 85 | [Arguments] ${data_path} ${data} |
Tal Karbachinsky | c3bf551 | 2018-01-25 10:27:17 +0200 | [diff] [blame] | 86 | ${auth}= Create List ${GLOBAL_MSO_USERNAME} ${GLOBAL_MSO_PASSWORD} |
| 87 | Log Creating session ${MSO_ENDPOINT} |
| 88 | ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth} |
| 89 | ${uuid}= Generate UUID |
| 90 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
DR695H | b034c28 | 2018-02-23 18:33:19 -0500 | [diff] [blame] | 91 | ${resp}= Delete Request mso ${data_path} ${data} headers=${headers} |
Tal Karbachinsky | c3bf551 | 2018-01-25 10:27:17 +0200 | [diff] [blame] | 92 | Log Received response from mso ${resp.text} |
| 93 | [Return] ${resp} |