Add API calls for creating network zone -defaults
[testsuite.git] / robot / resources / aai / create_zone.robot
1 *** Settings ***
2 Documentation     Create A&AI Customer API.
3 ...
4 ...                   Create A&AI Customer API
5
6 Resource    ../json_templater.robot
7 Resource    aai_interface.robot
8 Library    OperatingSystem
9 Library    Collections
10
11
12
13 *** Variables ***
14 ${ZONE_INDEX_PATH}     /aai/v11
15 ${ROOT_ZONE_PATH}  /network/zones/zone
16
17 ${SYSTEM USER}    robot-ete
18 ${AAI_ADD_ZONE_BODY}=    robot/assets/templates/aai/add_zone_body.template
19
20 *** Keywords ***
21 Inventory Zone If Not Exists
22     [Documentation]    Creates a service in A&AI if it doesn't exist
23     [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}
24     ${get_resp}=    Run A&AI Get Request     ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}
25     Return From Keyword If    '${get_resp.status_code}' == '200'
26     Inventory Zone  ${zone_id}  ${zone_name}  ${design_type}    ${zone_context}
27
28 Inventory Zone
29     [Documentation]    Inventorys a Tenant in A&AI
30     [Arguments]    ${zone_id}  ${zone_name}  ${design_type}    ${zone_context}
31     ${arguments}=    Create Dictionary     zone_id=${zone_id}  zone_name=${zone_name}  design_type=${design_type}    zone_context=${zone_context}
32     ${data}=    Fill JSON Template File    ${AAI_ADD_ZONE_BODY}    ${arguments}
33         ${put_resp}=    Run A&AI Put Request     ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}     ${data}
34     ${status_string}=    Convert To String    ${put_resp.status_code}
35     Should Match Regexp    ${status_string}     ^(201|200)$
36
37 Delete Zone
38     [Documentation]    Removes both Tenant
39     [Arguments]    ${zone_id}=${GLOBAL_AAI_ZONE_ID}
40     ${get_resp}=    Run A&AI Get Request     ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}
41     Run Keyword If    '${get_resp.status_code}' == '200'    Delete Zone Exists    ${zone_id}   ${get_resp.json()}
42
43 Delete Zone Exists
44     [Arguments]    ${zone_id}    ${json}
45     ${resource_version}=   Catenate   ${json['resource-version']}
46     ${put_resp}=    Run A&AI Delete Request    ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}    ${resource_version}
47     Should Be Equal As Strings  ${put_resp.status_code}         204
48
49 Get Zone
50     [Documentation]   Return zone
51     [Arguments]    ${zone_id} 
52         ${resp}=    Run A&AI Get Request     ${ZONE_INDEX_PATH}${ROOT_ZONE_PATH}/${zone_id}
53     Should Be Equal As Strings  ${resp.status_code}     200
54         [Return]  ${resp.json()}
55
56
57
58
59