blob: 359c62d53bc5cf7672866120d602a6fa54dd6e38 [file] [log] [blame]
Marco Platania992832a2019-02-08 15:25:19 -08001*** Settings ***
2Documentation Create VNFC in AAI
3
4Resource ../json_templater.robot
5Resource aai_interface.robot
6Library OperatingSystem
7Library Collections
8
9
10*** Variables ***
Brian Freemana44f3ee2019-02-19 13:47:04 -050011${VNFC_ROOT_PATH} /network/vnfcs/vnfc
Marco Platania992832a2019-02-08 15:25:19 -080012
Marco Platania992832a2019-02-08 15:25:19 -080013${AAI_ADD_VNFC_BODY}= robot/assets/templates/aai/add_vnfc_body.template
14
15*** Keywords ***
16Create VNFC If Not Exists
17 [Documentation] Creates VNFC in A&AI if it doesn't exist
18 [Arguments] ${vnfc_name} ${vnfc_nc} ${vnfc_func}
Brian Freemana44f3ee2019-02-19 13:47:04 -050019 ${get_resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name}
Marco Platania992832a2019-02-08 15:25:19 -080020 Return From Keyword If '${get_resp.status_code}' == '200'
21 Create VNFC ${vnfc_name} ${vnfc_nc} ${vnfc_func}
22
23Create VNFC
24 [Documentation] Creates VNFC in A&AI
25 [Arguments] ${vnfc_name} ${vnfc_nc} ${vnfc_func}
26 ${arguments}= Create Dictionary vnfc_name=${vnfc_name} vnfc_nc=${vnfc_nc} vnfc_func=${vnfc_func}
27 ${data}= Fill JSON Template File ${AAI_ADD_VNFC_BODY} ${arguments}
Brian Freemana44f3ee2019-02-19 13:47:04 -050028 ${put_resp}= Run A&AI Put Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name} ${data}
Marco Platania992832a2019-02-08 15:25:19 -080029 ${status_string}= Convert To String ${put_resp.status_code}
30 Should Match Regexp ${status_string} ^(201|200)$
31
32Delete VNFC If Exists
33 [Documentation] Removes VNFC from AAI if it exists
34 [Arguments] ${vnfc_name}
Brian Freemana44f3ee2019-02-19 13:47:04 -050035 ${get_resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name}
Marco Platania992832a2019-02-08 15:25:19 -080036 Run Keyword If '${get_resp.status_code}' == '200' Delete VNFC ${vnfc_name} ${get_resp.json()}
37
38Delete VNFC
39 [Documentation] Removes VNFC from AAI
40 [Arguments] ${vnfc_name} ${json}
41 ${resource_version}= Catenate ${json['resource-version']}
Brian Freemana44f3ee2019-02-19 13:47:04 -050042 ${put_resp}= Run A&AI Delete Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name} ${resource_version}
Marco Platania992832a2019-02-08 15:25:19 -080043 Should Be Equal As Strings ${put_resp.status_code} 204
44
45Get VNFC
46 [Documentation] Return VNFC
47 [Arguments] ${vnfc_name}
Brian Freemana44f3ee2019-02-19 13:47:04 -050048 ${resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name}
Marco Platania992832a2019-02-08 15:25:19 -080049 Should Be Equal As Strings ${resp.status_code} 200
Brian Freemana44f3ee2019-02-19 13:47:04 -050050 [Return] ${resp.json()}