kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library json |
| 3 | Library eteutils/HTTPUtils.py |
| 4 | Library ONAPLibrary.Utilities |
| 5 | |
| 6 | Resource json_templater.robot |
| 7 | Resource common.robot |
| 8 | |
| 9 | *** Variables *** |
| 10 | ${DCAE_PATH} /dcae |
| 11 | ${DCAE_CREATE_BLUEPRINT_PATH} /SERVICE/createBluePrint |
| 12 | ${DCAE_VFCMT_TEMPLATE} ${ASSETS_DIR}create_vfcmt.template |
| 13 | ${DCAE_COMPOSITION_TEMPLATE} ${ASSETS_DIR}dcae_composition.template |
| 14 | ${DCAE_MONITORING_CONFIGURATION_TEMPLATE} ${ASSETS_DIR}dcae_monitoring_configuration.template |
| 15 | ${DCAE_BE_ENDPOINT} http://localhost:8082 |
| 16 | |
| 17 | *** Keywords *** |
| 18 | |
| 19 | Add VFCMT To DCAE-DS |
| 20 | [Documentation] Create VFCMT with the given name and return its uuid |
| 21 | [Arguments] ${vfcmt_name} |
| 22 | ${map}= Create Dictionary vfcmtName=${vfcmt_name} description=VFCMT created by robot |
| 23 | ${data}= Fill JSON Template File ${DCAE_VFCMT_TEMPLATE} ${map} |
| 24 | ${resp}= Run DCAE-DS Post Request ${DCAE_PATH}/createVFCMT ${data} ${ASDC_DESIGNER_USER_ID} |
| 25 | Should Be Equal As Strings ${resp.status_code} 200 |
| 26 | [Return] ${resp.json()['uuid']} |
| 27 | |
| 28 | Run DCAE-DS Post Request |
| 29 | [Documentation] Runs a DCAE-DS post request |
| 30 | [Arguments] ${data_path} ${data} ${user}=${ASDC_DESIGNER_USER_ID} ${MY_DCAE_BE_ENDPOINT}=${DCAE_BE_ENDPOINT} |
| 31 | Log Creating session ${MY_DCAE_BE_ENDPOINT} |
| 32 | ${session}= Create Session sdc_dcae_ds ${MY_DCAE_BE_ENDPOINT} |
| 33 | ${uuid}= Generate UUID4 |
| 34 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json USER_ID=${user} X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 35 | ${resp}= Post Request sdc_dcae_ds ${data_path} data=${data} headers=${headers} |
| 36 | Log Received response from DCAE-BE: ${resp.text} |
| 37 | [Return] ${resp} |
| 38 | |
| 39 | Run DCAE-DS Put Request |
| 40 | [Documentation] Runs a DCAE-DS put request |
| 41 | [Arguments] ${data_path} ${user}=${ASDC_DESIGNER_USER_ID} ${MY_DCAE_BE_ENDPOINT}=${DCAE_BE_ENDPOINT} |
| 42 | Log Creating session ${MY_DCAE_BE_ENDPOINT} |
| 43 | ${session}= Create Session sdc_dcae_ds ${MY_DCAE_BE_ENDPOINT} |
| 44 | ${uuid}= Generate UUID4 |
| 45 | ${headers}= Create Dictionary Accept=application/json Content-Type=application/json USER_ID=${user} X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} |
| 46 | ${resp}= Put Request sdc_dcae_ds ${data_path} headers=${headers} |
| 47 | Log Received response from DCAE-BE: ${resp.text} |
| 48 | [Return] ${resp} |
| 49 | |
| 50 | Save Composition |
| 51 | [Arguments] ${vfcmt_uuid} ${vf_uuid} |
| 52 | ${map}= Create Dictionary cid=${vfcmt_uuid} vf_id=${vf_uuid} |
| 53 | ${data}= Fill JSON Template File ${DCAE_COMPOSITION_TEMPLATE} ${map} |
| 54 | ${resp}= Run DCAE-DS Post Request ${DCAE_PATH}/saveComposition/${vfcmt_uuid} ${data} ${ASDC_DESIGNER_USER_ID} |
| 55 | Should Be Equal As Strings ${resp.status_code} 200 |
| 56 | |
| 57 | Certify VFCMT |
| 58 | [Arguments] ${vfcmt_uuid} |
| 59 | ${resp}= Run DCAE-DS Put Request ${DCAE_PATH}/certify/vfcmt/${vfcmt_uuid} |
| 60 | Should Be Equal As Strings ${resp.status_code} 200 |
| 61 | [Return] ${resp.json()['uuid']} |
| 62 | |
| 63 | Add Monitoring Configuration To DCAE-DS |
| 64 | [Arguments] ${vfcmt_uuid} ${cs_uuid} ${vfi_name} ${mc_name} |
| 65 | ${map}= Create Dictionary template_uuid=${vfcmt_uuid} service_uuid=${cs_uuid} vfi_name=${vfi_name} name=${mc_name} |
| 66 | ${data}= Fill JSON Template File ${DCAE_MONITORING_CONFIGURATION_TEMPLATE} ${map} |
| 67 | ${resp}= Run DCAE-DS Post Request ${DCAE_PATH}/importMC ${data} ${ASDC_DESIGNER_USER_ID} |
| 68 | Should Be Equal As Strings ${resp.status_code} 200 |
| 69 | [Return] ${resp.json()['vfcmt']['uuid']} |
| 70 | |
| 71 | Submit Monitoring Configuration To DCAE-DS |
| 72 | [Arguments] ${mc_uuid} ${cs_uuid} ${vfi_name} |
| 73 | ${url_vfi_name} HTTPUtils.url_encode_string ${vfi_name} |
| 74 | ${resp}= Run DCAE-DS Post Request ${DCAE_PATH}${DCAE_CREATE_BLUEPRINT_PATH}/${mc_uuid}/${cs_uuid}/${url_vfi_name} ${None} ${ASDC_DESIGNER_USER_ID} |
| 75 | Should Be Equal As Strings ${resp.status_code} 200 |
| 76 | |