blob: 8fed0c792f1fc2232dcad2c89f9eeef72f688aa8 [file] [log] [blame]
Jerry Flood8a6b0b52017-11-12 15:44:21 -05001*** Settings ***
2Documentation Create A&AI Customer API.
Jerry Flood8a6b0b52017-11-12 15:44:21 -05003
Jerry Flood8a6b0b52017-11-12 15:44:21 -05004Resource aai_interface.robot
5Library OperatingSystem
6Library Collections
DR695H3bb6cf42019-06-20 15:04:04 -04007Library ONAPLibrary.Templating
Jerry Flood8a6b0b52017-11-12 15:44:21 -05008
9
10*** Variables ***
11${COMPLEX_INDEX_PATH} /aai/v11
12${ROOT_COMPLEXES_PATH} /cloud-infrastructure/complexes
13${ROOT_COMPLEX_PATH} /cloud-infrastructure/complexes/complex
14
DR695H3bb6cf42019-06-20 15:04:04 -040015${AAI_ADD_COMPLEX_BODY} aai/add_complex_body.jinja
Jerry Flood8a6b0b52017-11-12 15:44:21 -050016
17*** Keywords ***
18Inventory Complex If Not Exists
19 [Documentation] Creates a service in A&AI if it doesn't exist
20 [Arguments] ${complex_name} ${physical_location_id} ${cloud_owner} ${region} ${owner_defined_type}
21 ${get_resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}
22 Return From Keyword If '${get_resp.status_code}' == '200'
23 Inventory Complex ${complex_name} ${physical_location_id} ${cloud_owner} ${region} ${owner_defined_type}
24
25Inventory Complex
DR695H3bb6cf42019-06-20 15:04:04 -040026 [Documentation] Inventorys a Complex in A&AI
Jerry Flood8a6b0b52017-11-12 15:44:21 -050027 [Arguments] ${complex_name} ${physical_location_id} ${cloud_owner} ${region} ${owner_defined_type}
28 ${arguments}= Create Dictionary complex_name=${complex_name}
29 Set To Dictionary ${arguments} physical_location_id=${physical_location_id}
30 Set To Dictionary ${arguments} cloud_owner=${cloud_owner}
31 Set To Dictionary ${arguments} region=${region}
32 Set To Dictionary ${arguments} owner_defined_type=${owner_defined_type}
DR695H3bb6cf42019-06-20 15:04:04 -040033 Create Environment aai ${GLOBAL_TEMPLATE_FOLDER}
34 ${data}= Apply Template aai ${AAI_ADD_COMPLEX_BODY} ${arguments}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050035 ${put_resp}= Run A&AI Put Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id} ${data}
36 ${status_string}= Convert To String ${put_resp.status_code}
37 Should Match Regexp ${status_string} ^(201|200)$
38
39Delete Complex If Exists
40 [Documentation] Removes a complex
41 [Arguments] ${physical_location_id}
42 ${get_resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}
DR695H910097e2019-05-08 13:55:32 -040043 Run Keyword If '${get_resp.status_code}' == '200' Delete Complex ${physical_location_id} ${get_resp.json()}
Jerry Flood8a6b0b52017-11-12 15:44:21 -050044
45Delete Complex
46 [Arguments] ${physical_location_id} ${json}
47 ${resource_version}= Catenate ${json['resource-version']}
48 ${put_resp}= Run A&AI Delete Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id} ${resource_version}
49 Should Be Equal As Strings ${put_resp.status_code} 204
50
51Get Complex
52 [Documentation] Return a complex
53 [Arguments] ${physical_location_id}
54 ${resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}
55 Should Be Equal As Strings ${resp.status_code} 200
56 [Return] ${resp.json()}
57
58Get Complexes
59 [Documentation] Return all complexes
Jerry Flood8a6b0b52017-11-12 15:44:21 -050060 ${resp}= Run A&AI Get Request ${COMPLEX_INDEX_PATH}${ROOT_COMPLEXES_PATH}
61 Should Be Equal As Strings ${resp.status_code} 200
62 Log ${resp.json()}
DR695Hb034c282018-02-23 18:33:19 -050063 [Return] ${resp.json()}