blob: bded5282a8df34b731f4747940c91b5fbd3d9e57 [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
Brian Freemanca5e32e2018-07-23 12:47:21 -050023Run MSO Get ModelInvariantId
24 [Documentation] Runs an MSO Get ModelInvariantID for ClosedLoop Polieis
Brian Freemand65e2aa2018-07-26 11:13:46 -050025 [Arguments] ${service_model_name} ${vf_module_label}=NULL
Brian Freemanca5e32e2018-07-23 12:47:21 -050026 ${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 Freemand65e2aa2018-07-26 11:13:46 -050031 # ${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 Freemanca5e32e2018-07-23 12:47:21 -050039
DR695Hccff30b2017-02-17 18:44:24 -050040Run 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}
DR695Hbf5a3a32017-06-30 13:09:57 -040044 Log Creating session ${MSO_ENDPOINT}
45 ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050046 ${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 Flood176d1da2017-10-02 10:38:30 -040051
DR695Hccff30b2017-02-17 18:44:24 -050052Poll 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}
DR695Hbf5a3a32017-06-30 13:09:57 -040056 Log Creating session ${MSO_ENDPOINT}
57 ${session}= Create Session mso ${MSO_ENDPOINT} auth=${auth}
DR695Hccff30b2017-02-17 18:44:24 -050058 ${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 Flood176d1da2017-10-02 10:38:30 -040064 \ Log ${resp.json()['request']['requestStatus']['requestState']}
DR695Hccff30b2017-02-17 18:44:24 -050065 \ ${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 Dabastany186c3582017-08-07 16:14:19 +030071Run 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 Dabastany262d9d42017-08-14 15:27:36 +030080 Log Received response from mso ${resp.text}
Mor Dabastany186c3582017-08-07 16:14:19 +030081 [Return] ${resp}
Tal Karbachinskyc3bf5512018-01-25 10:27:17 +020082
83Run MSO Delete request
84 [Documentation] Runs an MSO Delete request
85 [Arguments] ${data_path} ${data}
Tal Karbachinskyc3bf5512018-01-25 10:27:17 +020086 ${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}
DR695Hb034c282018-02-23 18:33:19 -050091 ${resp}= Delete Request mso ${data_path} ${data} headers=${headers}
Tal Karbachinskyc3bf5512018-01-25 10:27:17 +020092 Log Received response from mso ${resp.text}
93 [Return] ${resp}