Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Create VNFC in AAI |
| 3 | |
| 4 | Resource ../json_templater.robot |
| 5 | Resource aai_interface.robot |
| 6 | Library OperatingSystem |
| 7 | Library Collections |
| 8 | |
| 9 | |
| 10 | *** Variables *** |
Brian Freeman | a44f3ee | 2019-02-19 13:47:04 -0500 | [diff] [blame] | 11 | ${VNFC_ROOT_PATH} /network/vnfcs/vnfc |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 12 | |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 13 | ${AAI_ADD_VNFC_BODY}= robot/assets/templates/aai/add_vnfc_body.template |
| 14 | |
| 15 | *** Keywords *** |
| 16 | Create 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 Freeman | a44f3ee | 2019-02-19 13:47:04 -0500 | [diff] [blame] | 19 | ${get_resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name} |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 20 | Return From Keyword If '${get_resp.status_code}' == '200' |
| 21 | Create VNFC ${vnfc_name} ${vnfc_nc} ${vnfc_func} |
| 22 | |
| 23 | Create 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 Freeman | a44f3ee | 2019-02-19 13:47:04 -0500 | [diff] [blame] | 28 | ${put_resp}= Run A&AI Put Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name} ${data} |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 29 | ${status_string}= Convert To String ${put_resp.status_code} |
| 30 | Should Match Regexp ${status_string} ^(201|200)$ |
| 31 | |
| 32 | Delete VNFC If Exists |
| 33 | [Documentation] Removes VNFC from AAI if it exists |
| 34 | [Arguments] ${vnfc_name} |
Brian Freeman | a44f3ee | 2019-02-19 13:47:04 -0500 | [diff] [blame] | 35 | ${get_resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name} |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 36 | Run Keyword If '${get_resp.status_code}' == '200' Delete VNFC ${vnfc_name} ${get_resp.json()} |
| 37 | |
| 38 | Delete VNFC |
| 39 | [Documentation] Removes VNFC from AAI |
| 40 | [Arguments] ${vnfc_name} ${json} |
| 41 | ${resource_version}= Catenate ${json['resource-version']} |
Brian Freeman | a44f3ee | 2019-02-19 13:47:04 -0500 | [diff] [blame] | 42 | ${put_resp}= Run A&AI Delete Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name} ${resource_version} |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 43 | Should Be Equal As Strings ${put_resp.status_code} 204 |
| 44 | |
| 45 | Get VNFC |
| 46 | [Documentation] Return VNFC |
| 47 | [Arguments] ${vnfc_name} |
Brian Freeman | a44f3ee | 2019-02-19 13:47:04 -0500 | [diff] [blame] | 48 | ${resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name} |
Marco Platania | 992832a | 2019-02-08 15:25:19 -0800 | [diff] [blame] | 49 | Should Be Equal As Strings ${resp.status_code} 200 |
Brian Freeman | a44f3ee | 2019-02-19 13:47:04 -0500 | [diff] [blame] | 50 | [Return] ${resp.json()} |