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