blob: af05faf9dac430daffa799cc3ea2dae559ffcdb5 [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}
DR695Hd9794652019-07-19 18:20:40 -040021 ${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 Platania9d992ae2019-01-23 17:20:05 -050023 Return From Keyword If '${get_resp.status_code}' == '200'
24 Create Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id}
25
26Create 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}
DR695Hd9794652019-07-19 18:20:40 -040030 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 Platania9d992ae2019-01-23 17:20:05 -050034 ${status_string}= Convert To String ${put_resp.status_code}
35 Should Match Regexp ${status_string} ^(201|200)$
36
37Delete Availability Zone If Exists
38 [Documentation] Removes availability zone
39 [Arguments] ${cloud-owner} ${cloud-region-id} ${availability_zone_name}=${GLOBAL_AAI_AVAILABILITY_ZONE_NAME}
DR695Hd9794652019-07-19 18:20:40 -040040 ${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 Platania9d992ae2019-01-23 17:20:05 -050042 Run Keyword If '${get_resp.status_code}' == '200' Delete Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${get_resp.json()}
43
44Delete Availability Zone
45 [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${json}
46 ${resource_version}= Catenate ${json['resource-version']}
DR695Hd9794652019-07-19 18:20:40 -040047 ${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 Platania9d992ae2019-01-23 17:20:05 -050049 Should Be Equal As Strings ${put_resp.status_code} 204
50
51Get Availability Zone
52 [Documentation] Return availability zone
53 [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id}
DR695Hd9794652019-07-19 18:20:40 -040054 ${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 Platania9d992ae2019-01-23 17:20:05 -050056 Should Be Equal As Strings ${resp.status_code} 200
Brian Freemana44f3ee2019-02-19 13:47:04 -050057 [Return] ${resp.json()}