Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Create availability zone in A&AI. |
| 3 | |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 4 | Resource aai_interface.robot |
| 5 | Library OperatingSystem |
| 6 | Library Collections |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame^] | 7 | Library ONAPLibrary.Templating WITH NAME Templating |
| 8 | Library ONAPLibrary.AAI WITH NAME AAI |
| 9 | |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 10 | |
| 11 | *** Variables *** |
Brian Freeman | a44f3ee | 2019-02-19 13:47:04 -0500 | [diff] [blame] | 12 | ${AZ_ROOT_PATH} /cloud-infrastructure/cloud-regions/cloud-region |
| 13 | ${AZ_ZONE_PATH} /availability-zones/availability-zone |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 14 | |
DR695H | 3bb6cf4 | 2019-06-20 15:04:04 -0400 | [diff] [blame] | 15 | ${AAI_ADD_AVAILABILITY_ZONE_BODY} aai/add_availability_zone_body.jinja |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 16 | |
| 17 | *** Keywords *** |
| 18 | Create Availability Zone If Not Exists |
| 19 | [Documentation] Creates availability zone in A&AI if it doesn't exist |
| 20 | [Arguments] ${cloud-owner} ${cloud-region-id} ${availability_zone_name}=${GLOBAL_AAI_AVAILABILITY_ZONE_NAME} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame^] | 21 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
| 22 | ${get_resp}= AAI.Run Get Request ${AAI_FRONTEND_ENDPOINT} ${GLOBAL_AAI_INDEX_PATH}${AZ_ROOT_PATH}/${cloud-owner}/${cloud-region-id}${AZ_ZONE_PATH}/${availability_zone_name} auth=${auth} |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 23 | Return From Keyword If '${get_resp.status_code}' == '200' |
| 24 | Create Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id} |
| 25 | |
| 26 | Create Availability Zone |
| 27 | [Documentation] Creates availability zone in A&AI |
| 28 | [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id} |
| 29 | ${arguments}= Create Dictionary availability_zone_name=${availability_zone_name} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame^] | 30 | Templating.Create Environment aai ${GLOBAL_TEMPLATE_FOLDER} |
| 31 | ${data}= Templating.Apply Template aai ${AAI_ADD_AVAILABILITY_ZONE_BODY} ${arguments} |
| 32 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
| 33 | ${put_resp}= AAI.Run Put Request ${AAI_FRONTEND_ENDPOINT} ${GLOBAL_AAI_INDEX_PATH}${AZ_ROOT_PATH}/${cloud-owner}/${cloud-region-id}${AZ_ZONE_PATH}/${availability_zone_name} ${data} auth=${auth} |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 34 | ${status_string}= Convert To String ${put_resp.status_code} |
| 35 | Should Match Regexp ${status_string} ^(201|200)$ |
| 36 | |
| 37 | Delete Availability Zone If Exists |
| 38 | [Documentation] Removes availability zone |
| 39 | [Arguments] ${cloud-owner} ${cloud-region-id} ${availability_zone_name}=${GLOBAL_AAI_AVAILABILITY_ZONE_NAME} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame^] | 40 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
| 41 | ${get_resp}= AAI.Run Get Request ${AAI_FRONTEND_ENDPOINT} ${GLOBAL_AAI_INDEX_PATH}${AZ_ROOT_PATH}/${cloud-owner}/${cloud-region-id}${AZ_ZONE_PATH}/${availability_zone_name} auth=${auth} |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 42 | Run Keyword If '${get_resp.status_code}' == '200' Delete Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${get_resp.json()} |
| 43 | |
| 44 | Delete Availability Zone |
| 45 | [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${json} |
| 46 | ${resource_version}= Catenate ${json['resource-version']} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame^] | 47 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
| 48 | ${put_resp}= AAI.Run Delete Request ${AAI_FRONTEND_ENDPOINT} ${GLOBAL_AAI_INDEX_PATH}${AZ_ROOT_PATH}/${cloud-owner}/${cloud-region-id}${AZ_ZONE_PATH}/${availability_zone_name} ${resource_version} auth=${auth} |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 49 | Should Be Equal As Strings ${put_resp.status_code} 204 |
| 50 | |
| 51 | Get Availability Zone |
| 52 | [Documentation] Return availability zone |
| 53 | [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame^] | 54 | ${auth}= Create List ${GLOBAL_AAI_USERNAME} ${GLOBAL_AAI_PASSWORD} |
| 55 | ${resp}= AAI.Run Get Request ${AAI_FRONTEND_ENDPOINT} ${GLOBAL_AAI_INDEX_PATH}${AZ_ROOT_PATH}/${cloud-owner}/${cloud-region-id}${AZ_ZONE_PATH}/${availability_zone_name} auth=${auth} |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 56 | Should Be Equal As Strings ${resp.status_code} 200 |
Brian Freeman | a44f3ee | 2019-02-19 13:47:04 -0500 | [diff] [blame] | 57 | [Return] ${resp.json()} |