blob: a90c9770c7d89e5340aab17f8994a31bb9e818ba [file] [log] [blame]
Marco Platania9d992ae2019-01-23 17:20:05 -05001*** Settings ***
2Documentation Create availability zone in A&AI.
3
Marco Platania9d992ae2019-01-23 17:20:05 -05004Resource aai_interface.robot
5Library OperatingSystem
6Library Collections
DR695Hd9794652019-07-19 18:20:40 -04007Library ONAPLibrary.Templating WITH NAME Templating
8Library ONAPLibrary.AAI WITH NAME AAI
9
Marco Platania9d992ae2019-01-23 17:20:05 -050010
11*** Variables ***
Brian Freemana44f3ee2019-02-19 13:47:04 -050012${AZ_ROOT_PATH} /cloud-infrastructure/cloud-regions/cloud-region
13${AZ_ZONE_PATH} /availability-zones/availability-zone
Marco Platania9d992ae2019-01-23 17:20:05 -050014
DR695H3bb6cf42019-06-20 15:04:04 -040015${AAI_ADD_AVAILABILITY_ZONE_BODY} aai/add_availability_zone_body.jinja
Marco Platania9d992ae2019-01-23 17:20:05 -050016
17*** Keywords ***
18Create 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}
DR695Hc6184272019-07-26 15:50:23 -040021 ${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 Platania9d992ae2019-01-23 17:20:05 -050022 Return From Keyword If '${get_resp.status_code}' == '200'
23 Create Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id}
24
25Create 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}
DR695Hd9794652019-07-19 18:20:40 -040029 Templating.Create Environment aai ${GLOBAL_TEMPLATE_FOLDER}
30 ${data}= Templating.Apply Template aai ${AAI_ADD_AVAILABILITY_ZONE_BODY} ${arguments}
DR695Hc6184272019-07-26 15:50:23 -040031 ${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 Platania9d992ae2019-01-23 17:20:05 -050032 ${status_string}= Convert To String ${put_resp.status_code}
33 Should Match Regexp ${status_string} ^(201|200)$
34
35Delete Availability Zone If Exists
36 [Documentation] Removes availability zone
37 [Arguments] ${cloud-owner} ${cloud-region-id} ${availability_zone_name}=${GLOBAL_AAI_AVAILABILITY_ZONE_NAME}
DR695Hc6184272019-07-26 15:50:23 -040038 ${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 Platania9d992ae2019-01-23 17:20:05 -050039 Run Keyword If '${get_resp.status_code}' == '200' Delete Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${get_resp.json()}
40
41Delete Availability Zone
42 [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${json}
43 ${resource_version}= Catenate ${json['resource-version']}
DR695Hc6184272019-07-26 15:50:23 -040044 ${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 Platania9d992ae2019-01-23 17:20:05 -050045 Should Be Equal As Strings ${put_resp.status_code} 204
46
47Get Availability Zone
48 [Documentation] Return availability zone
49 [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id}
DR695Hc6184272019-07-26 15:50:23 -040050 ${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 Platania9d992ae2019-01-23 17:20:05 -050051 Should Be Equal As Strings ${resp.status_code} 200
DR695Hc6184272019-07-26 15:50:23 -040052 [Return] ${resp.json()}