Release image version 1.12.2
[testsuite.git] / robot / resources / aai / create_zone.robot
1 *** Settings ***
2 Documentation     Create A&AI Customer API.
3
4 Resource    aai_interface.robot
5 Library    OperatingSystem
6 Library    Collections
7 Library    ONAPLibrary.Templating    WITH NAME    Templating
8 Library    ONAPLibrary.AAI    WITH NAME    AAI
9
10
11 *** Variables ***
12 ${ZONE_INDEX_PATH}     /aai/v11
13 ${ROOT_ZONE_PATH}  /network/zones/zone
14
15 ${AAI_ADD_ZONE_BODY}=    aai/add_zone_body.jinja
16
17 *** Keywords ***
18 Inventory Zone If Not Exists
19     [Documentation]    Creates a service in A&AI if it doesn't exist
20     [Arguments]    ${zone_id}=${GLOBAL_AAI_ZONE_ID}  ${zone_name}=${GLOBAL_AAI_ZONE_NAME}  ${design_type}=${GLOBAL_AAI_DESIGN_TYPE}    ${zone_context}=${GLOBAL_AAI_ZONE_CONTEXT}
21     ${get_resp}=    AAI.Run Get Request     ${AAI_FRONTEND_ENDPOINT}    ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}        auth=${GLOBAL_AAI_AUTHENTICATION}
22     Return From Keyword If    '${get_resp.status_code}' == '200'
23     Inventory Zone  ${zone_id}  ${zone_name}  ${design_type}    ${zone_context}
24
25 Inventory Zone
26     [Documentation]    Inventorys a Tenant in A&AI
27     [Arguments]    ${zone_id}  ${zone_name}  ${design_type}    ${zone_context}
28     ${arguments}=    Create Dictionary     zone_id=${zone_id}  zone_name=${zone_name}  design_type=${design_type}    zone_context=${zone_context}
29     Templating.Create Environment    aai    ${GLOBAL_TEMPLATE_FOLDER}
30     ${data}=   Templating.Apply Template    aai   ${AAI_ADD_ZONE_BODY}    ${arguments}
31         ${put_resp}=    AAI.Run Put Request     ${AAI_FRONTEND_ENDPOINT}    ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}     ${data}        auth=${GLOBAL_AAI_AUTHENTICATION}
32     ${status_string}=    Convert To String    ${put_resp.status_code}
33     Should Match Regexp    ${status_string}     ^(201|200)$
34
35 Delete Zone
36     [Documentation]    Removes both Tenant
37     [Arguments]    ${zone_id}=${GLOBAL_AAI_ZONE_ID}
38     ${get_resp}=    AAI.Run Get Request     ${AAI_FRONTEND_ENDPOINT}    ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}        auth=${GLOBAL_AAI_AUTHENTICATION}
39     Run Keyword If    '${get_resp.status_code}' == '200'    Delete Zone Exists    ${zone_id}   ${get_resp.json()}
40
41 Delete Zone Exists
42     [Arguments]    ${zone_id}    ${json}
43     ${resource_version}=   Catenate   ${json['resource-version']}
44     ${put_resp}=    AAI.Run Delete Request    ${AAI_FRONTEND_ENDPOINT}    ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}    ${resource_version}        auth=${GLOBAL_AAI_AUTHENTICATION}
45     Should Be Equal As Strings  ${put_resp.status_code}         204
46
47 Get Zone
48     [Documentation]   Return zone
49     [Arguments]    ${zone_id}
50         ${resp}=    AAI.Run Get Request     ${AAI_FRONTEND_ENDPOINT}    ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}        auth=${GLOBAL_AAI_AUTHENTICATION}
51     Should Be Equal As Strings  ${resp.status_code}     200
52         [Return]  ${resp.json()}