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 | c618427 | 2019-07-26 15:50:23 -0400 | [diff] [blame^] | 21 | ${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=${GLOBAL_AAI_AUTHENTICATION} |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 22 | Return From Keyword If '${get_resp.status_code}' == '200' |
| 23 | Create Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id} |
| 24 | |
| 25 | Create Availability Zone |
| 26 | [Documentation] Creates availability zone in A&AI |
| 27 | [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id} |
| 28 | ${arguments}= Create Dictionary availability_zone_name=${availability_zone_name} |
DR695H | d979465 | 2019-07-19 18:20:40 -0400 | [diff] [blame] | 29 | Templating.Create Environment aai ${GLOBAL_TEMPLATE_FOLDER} |
| 30 | ${data}= Templating.Apply Template aai ${AAI_ADD_AVAILABILITY_ZONE_BODY} ${arguments} |
DR695H | c618427 | 2019-07-26 15:50:23 -0400 | [diff] [blame^] | 31 | ${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=${GLOBAL_AAI_AUTHENTICATION} |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 32 | ${status_string}= Convert To String ${put_resp.status_code} |
| 33 | Should Match Regexp ${status_string} ^(201|200)$ |
| 34 | |
| 35 | Delete Availability Zone If Exists |
| 36 | [Documentation] Removes availability zone |
| 37 | [Arguments] ${cloud-owner} ${cloud-region-id} ${availability_zone_name}=${GLOBAL_AAI_AVAILABILITY_ZONE_NAME} |
DR695H | c618427 | 2019-07-26 15:50:23 -0400 | [diff] [blame^] | 38 | ${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=${GLOBAL_AAI_AUTHENTICATION} |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 39 | Run Keyword If '${get_resp.status_code}' == '200' Delete Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${get_resp.json()} |
| 40 | |
| 41 | Delete Availability Zone |
| 42 | [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${json} |
| 43 | ${resource_version}= Catenate ${json['resource-version']} |
DR695H | c618427 | 2019-07-26 15:50:23 -0400 | [diff] [blame^] | 44 | ${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=${GLOBAL_AAI_AUTHENTICATION} |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 45 | Should Be Equal As Strings ${put_resp.status_code} 204 |
| 46 | |
| 47 | Get Availability Zone |
| 48 | [Documentation] Return availability zone |
| 49 | [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id} |
DR695H | c618427 | 2019-07-26 15:50:23 -0400 | [diff] [blame^] | 50 | ${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=${GLOBAL_AAI_AUTHENTICATION} |
Marco Platania | 9d992ae | 2019-01-23 17:20:05 -0500 | [diff] [blame] | 51 | Should Be Equal As Strings ${resp.status_code} 200 |
DR695H | c618427 | 2019-07-26 15:50:23 -0400 | [diff] [blame^] | 52 | [Return] ${resp.json()} |