Release image version 1.12.2
[testsuite.git] / robot / resources / aai / create_complex.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 ${COMPLEX_INDEX_PATH}     /aai/v11
13 ${ROOT_COMPLEXES_PATH}  /cloud-infrastructure/complexes
14 ${ROOT_COMPLEX_PATH}  /cloud-infrastructure/complexes/complex
15
16 ${AAI_ADD_COMPLEX_BODY}    aai/add_complex_body.jinja
17
18 *** Keywords ***
19 Inventory Complex If Not Exists
20     [Documentation]    Creates a service in A&AI if it doesn't exist
21     [Arguments]    ${complex_name}   ${physical_location_id}   ${cloud_owner}   ${region}   ${owner_defined_type}
22     ${get_resp}=    AAI.Run Get Request     ${AAI_FRONTEND_ENDPOINT}    ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}        auth=${GLOBAL_AAI_AUTHENTICATION}
23     Return From Keyword If    '${get_resp.status_code}' == '200'
24     Inventory Complex  ${complex_name}   ${physical_location_id}   ${cloud_owner}   ${region}   ${owner_defined_type}
25
26 Inventory Complex
27     [Documentation]    Inventorys a Complex in A&AI
28     [Arguments]    ${complex_name}   ${physical_location_id}   ${cloud_owner}   ${region}   ${owner_defined_type}
29     ${arguments}=    Create Dictionary     complex_name=${complex_name}
30     Set To Dictionary   ${arguments}     physical_location_id=${physical_location_id}
31     Set To Dictionary   ${arguments}     cloud_owner=${cloud_owner}
32     Set To Dictionary   ${arguments}     region=${region}
33     Set To Dictionary   ${arguments}     owner_defined_type=${owner_defined_type}
34     Create Environment    aai    ${GLOBAL_TEMPLATE_FOLDER}
35     ${data}=   Apply Template    aai   ${AAI_ADD_COMPLEX_BODY}    ${arguments}
36         ${put_resp}=    AAI.Run Put Request     ${AAI_FRONTEND_ENDPOINT}    ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}     ${data}        auth=${GLOBAL_AAI_AUTHENTICATION}
37     ${status_string}=    Convert To String    ${put_resp.status_code}
38     Should Match Regexp    ${status_string}     ^(201|200)$
39
40 Delete Complex If Exists
41     [Documentation]    Removes a complex
42     [Arguments]    ${physical_location_id}
43     ${get_resp}=    AAI.Run Get Request     ${AAI_FRONTEND_ENDPOINT}    ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}
44     Run Keyword If    '${get_resp.status_code}' == '200'    Delete Complex    ${physical_location_id}   ${get_resp.json()}
45
46 Delete Complex
47     [Arguments]    ${physical_location_id}    ${json}
48     ${resource_version}=   Catenate   ${json['resource-version']}
49     ${put_resp}=    AAI.Run Delete Request     ${AAI_FRONTEND_ENDPOINT}    ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}    ${resource_version}        auth=${GLOBAL_AAI_AUTHENTICATION}
50     Should Be Equal As Strings  ${put_resp.status_code}         204
51
52 Get Complex
53     [Documentation]   Return a complex
54     [Arguments]    ${physical_location_id}
55         ${resp}=    AAI.Run Get Request     ${AAI_FRONTEND_ENDPOINT}    ${COMPLEX_INDEX_PATH}${ROOT_COMPLEX_PATH}/${physical_location_id}        auth=${GLOBAL_AAI_AUTHENTICATION}
56     Should Be Equal As Strings  ${resp.status_code}     200
57         [Return]  ${resp.json()}
58
59 Get Complexes
60     [Documentation]   Return all complexes
61         ${resp}=    AAI.Run Get Request     ${AAI_FRONTEND_ENDPOINT}    ${COMPLEX_INDEX_PATH}${ROOT_COMPLEXES_PATH}        auth=${GLOBAL_AAI_AUTHENTICATION}
62     Should Be Equal As Strings  ${resp.status_code}     200
63     Log    ${resp.json()}
64         [Return]  ${resp.json()}