summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--robot/assets/templates/aai/add_availability_zone_body.template4
-rw-r--r--robot/resources/aai/create_availability_zone.robot52
-rw-r--r--robot/resources/demo_preload.robot4
-rw-r--r--robot/resources/global_properties.robot1
4 files changed, 60 insertions, 1 deletions
diff --git a/robot/assets/templates/aai/add_availability_zone_body.template b/robot/assets/templates/aai/add_availability_zone_body.template
new file mode 100644
index 00000000..d7b79130
--- /dev/null
+++ b/robot/assets/templates/aai/add_availability_zone_body.template
@@ -0,0 +1,4 @@
+{
+"availability-zone-name":"${availability_zone_name}",
+"hypervisor-type": "hypervisor"
+} \ No newline at end of file
diff --git a/robot/resources/aai/create_availability_zone.robot b/robot/resources/aai/create_availability_zone.robot
new file mode 100644
index 00000000..3d6176b6
--- /dev/null
+++ b/robot/resources/aai/create_availability_zone.robot
@@ -0,0 +1,52 @@
+*** Settings ***
+Documentation Create availability zone in A&AI.
+
+Resource ../json_templater.robot
+Resource aai_interface.robot
+Library OperatingSystem
+Library Collections
+
+
+*** Variables ***
+${INDEX_PATH} /aai/v14
+${ROOT_PATH} /cloud-infrastructure/cloud-regions/cloud-region
+${ZONE_PATH} /availability-zones/availability-zone
+
+${SYSTEM USER} robot-ete
+${AAI_ADD_AVAILABILITY_ZONE_BODY}= robot/assets/templates/aai/add_availability_zone_body.template
+
+*** Keywords ***
+Create Availability Zone If Not Exists
+ [Documentation] Creates availability zone in A&AI if it doesn't exist
+ [Arguments] ${cloud-owner} ${cloud-region-id} ${availability_zone_name}=${GLOBAL_AAI_AVAILABILITY_ZONE_NAME}
+ ${get_resp}= Run A&AI Get Request ${INDEX_PATH}${ROOT_PATH}/${cloud-owner}/${cloud-region-id}${ZONE_PATH}/${availability_zone_name}
+ Return From Keyword If '${get_resp.status_code}' == '200'
+ Create Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id}
+
+Create Availability Zone
+ [Documentation] Creates availability zone in A&AI
+ [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id}
+ ${arguments}= Create Dictionary availability_zone_name=${availability_zone_name}
+ ${data}= Fill JSON Template File ${AAI_ADD_AVAILABILITY_ZONE_BODY} ${arguments}
+ ${put_resp}= Run A&AI Put Request ${INDEX_PATH}${ROOT_PATH}/${cloud-owner}/${cloud-region-id}${ZONE_PATH}/${availability_zone_name} ${data}
+ ${status_string}= Convert To String ${put_resp.status_code}
+ Should Match Regexp ${status_string} ^(201|200)$
+
+Delete Availability Zone If Exists
+ [Documentation] Removes availability zone
+ [Arguments] ${cloud-owner} ${cloud-region-id} ${availability_zone_name}=${GLOBAL_AAI_AVAILABILITY_ZONE_NAME}
+ ${get_resp}= Run A&AI Get Request ${INDEX_PATH}${ROOT_PATH}/${cloud-owner}/${cloud-region-id}${ZONE_PATH}/${availability_zone_name}
+ Run Keyword If '${get_resp.status_code}' == '200' Delete Availability Zone ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${get_resp.json()}
+
+Delete Availability Zone
+ [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id} ${json}
+ ${resource_version}= Catenate ${json['resource-version']}
+ ${put_resp}= Run A&AI Delete Request ${INDEX_PATH}${ROOT_PATH}/${cloud-owner}/${cloud-region-id}${ZONE_PATH}/${availability_zone_name} ${resource_version}
+ Should Be Equal As Strings ${put_resp.status_code} 204
+
+Get Availability Zone
+ [Documentation] Return availability zone
+ [Arguments] ${availability_zone_name} ${cloud-owner} ${cloud-region-id}
+ ${resp}= Run A&AI Get Request ${INDEX_PATH}${ROOT_PATH}/${cloud-owner}/${cloud-region-id}${ZONE_PATH}/${availability_zone_name}
+ Should Be Equal As Strings ${resp.status_code} 200
+ [Return] ${resp.json()} \ No newline at end of file
diff --git a/robot/resources/demo_preload.robot b/robot/resources/demo_preload.robot
index 4f937e3b..ee09dc5b 100644
--- a/robot/resources/demo_preload.robot
+++ b/robot/resources/demo_preload.robot
@@ -6,7 +6,8 @@ Resource test_templates/vnf_orchestration_test_template.robot
Resource asdc_interface.robot
Resource so_interface.robot
Resource vid/vid_interface.robot
-Resource policy_interface.robot
+Resource policy_interface.robot
+Resource aai/create_availability_zone.robot
Library UUID
Library Collections
@@ -56,6 +57,7 @@ Load Customer
${region}= Get Openstack Region
Create Customer For VNF Demo ${CUSTOMER_NAME} ${CUSTOMER_NAME} INFRA ${GLOBAL_AAI_CLOUD_OWNER} ${region} ${TENANT_ID}
Create Customer For VNF Demo ${CUSTOMER_NAME} ${CUSTOMER_NAME} INFRA ${GLOBAL_AAI_CLOUD_OWNER} RegionTlab 50b190410b2a4c229d8a6044a80ab7c1
+ Create Availability Zone If Not Exists ${GLOBAL_AAI_CLOUD_OWNER} ${region} ${GLOBAL_AAI_AVAILABILITY_ZONE_NAME}
Load Models
[Documentation] Use openECOMP to Orchestrate a service.
diff --git a/robot/resources/global_properties.robot b/robot/resources/global_properties.robot
index fc202acd..023b4a00 100644
--- a/robot/resources/global_properties.robot
+++ b/robot/resources/global_properties.robot
@@ -23,6 +23,7 @@ ${GLOBAL_AAI_CLOUD_OWNER} CloudOwner
${GLOBAL_AAI_CLOUD_OWNER_DEFINED_TYPE} OwnerType
${GLOBAL_AAI_COMPLEX_NAME} clli1
${GLOBAL_AAI_PHYSICAL_LOCATION_ID} clli1
+${GLOBAL_AAI_AVAILABILITY_ZONE_NAME} AZ1
${GLOBAL_BUILD_NUMBER} 0
${GLOBAL_VID_UI_TIMEOUT_SHORT} 20s
${GLOBAL_VID_UI_TIMEOUT_MEDIUM} 60s