blob: 09d6ea6e477291d7a0dec05d90c3f08bfbfd21b5 [file] [log] [blame]
Jerry Floodc00a7c32017-10-10 08:09:07 -04001*** Settings ***
2Documentation Create A&AI Customer API.
3...
4... Create A&AI Customer API
5
6Resource ../json_templater.robot
7Resource aai_interface.robot
8Library OperatingSystem
9Library 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 ***
21Inventory 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
28Inventory 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
37Delete 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
43Delete 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
49Get Zone
50 [Documentation] Return zone
Jerry Flood8a6b0b52017-11-12 15:44:21 -050051 [Arguments] ${zone_id}
Jerry Floodc00a7c32017-10-10 08:09:07 -040052 ${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