blob: cf6aa6431b961c3c8c849ead5e7519be86094418 [file] [log] [blame]
DR695Hccff30b2017-02-17 18:44:24 -05001*** Settings ***
2Documentation The main interface for interacting with MSO. It handles low level stuff like managing the http request library and MSO required fields
3Library RequestsLibrary
4Library UUID
5Library OperatingSystem
6Library Collections
7Resource global_properties.robot
8Resource ../resources/json_templater.robot
9*** Variables ***
10${MSO_HEALTH_CHECK_PATH} /ecomp/mso/infra/globalhealthcheck
DR695Hbf5a3a32017-06-30 13:09:57 -040011${MSO_ENDPOINT} ${GLOBAL_MSO_SERVER_PROTOCOL}://${GLOBAL_INJECTED_MSO_IP_ADDR}:${GLOBAL_MSO_SERVER_PORT}
DR695Hccff30b2017-02-17 18:44:24 -050012
13*** Keywords ***
14Run MSO Health Check
15 [Documentation] Runs an MSO global health check
16 ${auth}= Create List ${GLOBAL_MSO_USERNAME} ${GLOBAL_MSO_PASSWORD}
DR695Hbf5a3a32017-06-30 13:09:57 -040017 ${session}= Create Session mso ${MSO_ENDPOINT}
DR695Hccff30b2017-02-17 18:44:24 -050018 ${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
23Run 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}
DR695Hbf5a3a32017-06-30 13:09:57 -040027 Log Creating session ${MSO_ENDPOINT}
28 ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050029 ${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
35Poll 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}
DR695Hbf5a3a32017-06-30 13:09:57 -040039 Log Creating session ${MSO_ENDPOINT}
40 ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050041 ${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
54
55