blob: d8b6111ebde4375dbfd052fc737de1060cef3f50 [file] [log] [blame]
Marco Platania9d992ae2019-01-23 17:20:05 -05001*** Settings ***
2Documentation Create availability zone in A&AI.
3
4Resource ../json_templater.robot
5Resource aai_interface.robot
6Library OperatingSystem
7Library Collections
8
9
10*** Variables ***
Brian Freemana44f3ee2019-02-19 13:47:04 -050011${AZ_ROOT_PATH} /cloud-infrastructure/cloud-regions/cloud-region
12${AZ_ZONE_PATH} /availability-zones/availability-zone
Marco Platania9d992ae2019-01-23 17:20:05 -050013
Marco Platania9d992ae2019-01-23 17:20:05 -050014${AAI_ADD_AVAILABILITY_ZONE_BODY}= robot/assets/templates/aai/add_availability_zone_body.template
15
16*** Keywords ***
17Create 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 Freemana44f3ee2019-02-19 13:47:04 -050020 ${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 Platania9d992ae2019-01-23 17:20:05 -050021 Return From Keyword If '${get_resp.status_code}' == '200'
22 Create Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id}
23
24Create 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 Freemana44f3ee2019-02-19 13:47:04 -050029 ${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 Platania9d992ae2019-01-23 17:20:05 -050030 ${status_string}= Convert To String ${put_resp.status_code}
31 Should Match Regexp ${status_string} ^(201|200)$
32
33Delete 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 Freemana44f3ee2019-02-19 13:47:04 -050036 ${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 Platania9d992ae2019-01-23 17:20:05 -050037 Run Keyword If '${get_resp.status_code}' == '200' Delete Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${get_resp.json()}
38
39Delete Availability Zone
40 [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${json}
41 ${resource_version}= Catenate ${json['resource-version']}
Brian Freemana44f3ee2019-02-19 13:47:04 -050042 ${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 Platania9d992ae2019-01-23 17:20:05 -050043 Should Be Equal As Strings ${put_resp.status_code} 204
44
45Get Availability Zone
46 [Documentation] Return availability zone
47 [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id}
Brian Freemana44f3ee2019-02-19 13:47:04 -050048 ${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 Platania9d992ae2019-01-23 17:20:05 -050049 Should Be Equal As Strings ${resp.status_code} 200
Brian Freemana44f3ee2019-02-19 13:47:04 -050050 [Return] ${resp.json()}