blob: 49965c893cde48bd294ceb60cf7a5be5a4d383d5 [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
Jerry Flood176d1da2017-10-02 10:38:30 -04004Library UUID
DR695Hccff30b2017-02-17 18:44:24 -05005Library OperatingSystem
6Library Collections
7Resource global_properties.robot
8Resource ../resources/json_templater.robot
9*** Variables ***
10${MSO_HEALTH_CHECK_PATH} /ecomp/mso/infra/globalhealthcheck
Jerry Flood176d1da2017-10-02 10:38:30 -040011${MSO_ENDPOINT} ${GLOBAL_MSO_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SO_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}
Jerry Flood176d1da2017-10-02 10:38:30 -040034
DR695Hccff30b2017-02-17 18:44:24 -050035Poll 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
Jerry Flood176d1da2017-10-02 10:38:30 -040047 \ Log ${resp.json()['request']['requestStatus']['requestState']}
DR695Hccff30b2017-02-17 18:44:24 -050048 \ ${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 Dabastany186c3582017-08-07 16:14:19 +030054Run 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 Dabastany262d9d42017-08-14 15:27:36 +030063 Log Received response from mso ${resp.text}
Mor Dabastany186c3582017-08-07 16:14:19 +030064 [Return] ${resp}
Tal Karbachinskyc3bf5512018-01-25 10:27:17 +020065
66Run MSO Delete request
67 [Documentation] Runs an MSO Delete request
68 [Arguments] ${data_path} ${data}
Tal Karbachinskyc3bf5512018-01-25 10:27:17 +020069 ${auth}= Create List ${GLOBAL_MSO_USERNAME} ${GLOBAL_MSO_PASSWORD}
70 Log Creating session ${MSO_ENDPOINT}
71 ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth}
72 ${uuid}= Generate UUID
73 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
DR695Hb034c282018-02-23 18:33:19 -050074 ${resp}= Delete Request mso ${data_path} ${data} headers=${headers}
Tal Karbachinskyc3bf5512018-01-25 10:27:17 +020075 Log Received response from mso ${resp.text}
76 [Return] ${resp}