replace aai, closeloop, sdc with jinja
[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    
8
9
10 *** Variables ***
11 ${ZONE_INDEX_PATH}     /aai/v11
12 ${ROOT_ZONE_PATH}  /network/zones/zone
13
14 ${AAI_ADD_ZONE_BODY}=    aai/add_zone_body.jinja
15
16 *** Keywords ***
17 Inventory Zone If Not Exists
18     [Documentation]    Creates a service in A&AI if it doesn't exist
19     [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}
20     ${get_resp}=    Run A&AI Get Request     ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}
21     Return From Keyword If    '${get_resp.status_code}' == '200'
22     Inventory Zone  ${zone_id}  ${zone_name}  ${design_type}    ${zone_context}
23
24 Inventory Zone
25     [Documentation]    Inventorys a Tenant in A&AI
26     [Arguments]    ${zone_id}  ${zone_name}  ${design_type}    ${zone_context}
27     ${arguments}=    Create Dictionary     zone_id=${zone_id}  zone_name=${zone_name}  design_type=${design_type}    zone_context=${zone_context}
28     Create Environment    aai    ${GLOBAL_TEMPLATE_FOLDER}
29     ${data}=   Apply Template    aai   ${AAI_ADD_ZONE_BODY}    ${arguments}
30         ${put_resp}=    Run A&AI Put Request     ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}     ${data}
31     ${status_string}=    Convert To String    ${put_resp.status_code}
32     Should Match Regexp    ${status_string}     ^(201|200)$
33
34 Delete Zone
35     [Documentation]    Removes both Tenant
36     [Arguments]    ${zone_id}=${GLOBAL_AAI_ZONE_ID}
37     ${get_resp}=    Run A&AI Get Request     ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}
38     Run Keyword If    '${get_resp.status_code}' == '200'    Delete Zone Exists    ${zone_id}   ${get_resp.json()}
39
40 Delete Zone Exists
41     [Arguments]    ${zone_id}    ${json}
42     ${resource_version}=   Catenate   ${json['resource-version']}
43     ${put_resp}=    Run A&AI Delete Request    ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}    ${resource_version}
44     Should Be Equal As Strings  ${put_resp.status_code}         204
45
46 Get Zone
47     [Documentation]   Return zone
48     [Arguments]    ${zone_id}
49         ${resp}=    Run A&AI Get Request     ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}
50     Should Be Equal As Strings  ${resp.status_code}     200
51         [Return]  ${resp.json()}